From: Eric Dumazet <eric.dumazet@gmail.com>
To: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev <netdev@vger.kernel.org>,
Eric Dumazet <edumazet@google.com>,
Eric Dumazet <eric.dumazet@gmail.com>
Subject: [PATCH net-next 3/4] net: warn if transport header was not set
Date: Mon, 9 May 2022 12:08:50 -0700 [thread overview]
Message-ID: <20220509190851.1107955-4-eric.dumazet@gmail.com> (raw)
In-Reply-To: <20220509190851.1107955-1-eric.dumazet@gmail.com>
From: Eric Dumazet <edumazet@google.com>
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 <edumazet@google.com>
---
include/linux/skbuff.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index d58669d6cb91aa30edc70d59a0a7e9d4e2298842..a1c73fccccc68641fe46066e6d1195b31483ca4c 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -42,6 +42,7 @@
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
#include <linux/netfilter/nf_conntrack_common.h>
#endif
+#include <net/net_debug.h>
/* The interface for checksum offload between the stack and networking drivers
* is as follows...
@@ -2804,6 +2805,7 @@ static inline bool skb_transport_header_was_set(const struct sk_buff *skb)
static inline unsigned char *skb_transport_header(const struct sk_buff *skb)
{
+ DEBUG_NET_WARN_ON_ONCE(!skb_transport_header_was_set(skb));
return skb->head + skb->transport_header;
}
--
2.36.0.512.ge40c2bad7a-goog
next prev parent reply other threads:[~2022-05-09 19:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-09 19:08 [PATCH net-next 0/4] net: CONFIG_DEBUG_NET and friends Eric Dumazet
2022-05-09 19:08 ` [PATCH net-next 1/4] net: add include/net/net_debug.h Eric Dumazet
2022-05-09 19:08 ` [PATCH net-next 2/4] net: add CONFIG_DEBUG_NET Eric Dumazet
2022-05-09 19:08 ` Eric Dumazet [this message]
2022-05-09 23:31 ` [PATCH net-next 3/4] net: warn if transport header was not set kernel test robot
2022-05-09 23:52 ` Eric Dumazet
2022-05-10 1:30 ` Jakub Kicinski
2022-05-10 2:11 ` Eric Dumazet
2022-05-10 2:23 ` Jakub Kicinski
2022-05-09 23:31 ` kernel test robot
2022-05-09 23:51 ` kernel test robot
2022-05-09 19:08 ` [PATCH net-next 4/4] net: remove two BUG() from skb_checksum_help() Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220509190851.1107955-4-eric.dumazet@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).