Skip to content

Commit 66e4c8d

Browse files
Eric Dumazetdavem330
authored andcommitted
net: warn if transport header was not set
Make sure skb_transport_header() and skb_transport_offset() uses are not fooled if the transport header has not been set. This change will likely expose existing bugs in linux networking stacks. Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d268c1f commit 66e4c8d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

include/linux/skbuff.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
4343
#include <linux/netfilter/nf_conntrack_common.h>
4444
#endif
45+
#include <net/net_debug.h>
4546

4647
/**
4748
* DOC: skb checksums
@@ -2904,6 +2905,7 @@ static inline bool skb_transport_header_was_set(const struct sk_buff *skb)
29042905

29052906
static inline unsigned char *skb_transport_header(const struct sk_buff *skb)
29062907
{
2908+
DEBUG_NET_WARN_ON_ONCE(!skb_transport_header_was_set(skb));
29072909
return skb->head + skb->transport_header;
29082910
}
29092911

0 commit comments

Comments
 (0)