* [PATCH net-next] net: warn if transport header was not set
@ 2022-05-09 16:57 Eric Dumazet
2022-05-09 17:20 ` Jakub Kicinski
0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2022-05-09 16:57 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: netdev, Eric Dumazet, Eric Dumazet
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 | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index d58669d6cb91aa30edc70d59a0a7e9d4e2298842..043c59fa0bd6d921f2d2e211348929681bfce186 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2804,6 +2804,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)
{
+ WARN_ON_ONCE(!skb_transport_header_was_set(skb));
return skb->head + skb->transport_header;
}
--
2.36.0.512.ge40c2bad7a-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: warn if transport header was not set
2022-05-09 16:57 [PATCH net-next] net: warn if transport header was not set Eric Dumazet
@ 2022-05-09 17:20 ` Jakub Kicinski
2022-05-09 17:28 ` Eric Dumazet
0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2022-05-09 17:20 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David S . Miller, Paolo Abeni, netdev, Eric Dumazet
On Mon, 9 May 2022 09:57:16 -0700 Eric Dumazet wrote:
> 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 | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> index d58669d6cb91aa30edc70d59a0a7e9d4e2298842..043c59fa0bd6d921f2d2e211348929681bfce186 100644
> --- a/include/linux/skbuff.h
> +++ b/include/linux/skbuff.h
> @@ -2804,6 +2804,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)
> {
> + WARN_ON_ONCE(!skb_transport_header_was_set(skb));
> return skb->head + skb->transport_header;
> }
>
This is for prod or for syzbot?
What are your feelings on putting this under a kconfig?
We already have a #ifdef DEBUG in skb_checksum_none_assert()
we could generalize that into some form of kconfig-gated
SKB_CHECK(). Kconfig-gated so that people don't feel self-conscious
about using it. I wrote such a patch a few times already but never
sent it.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: warn if transport header was not set
2022-05-09 17:20 ` Jakub Kicinski
@ 2022-05-09 17:28 ` Eric Dumazet
0 siblings, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2022-05-09 17:28 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: Eric Dumazet, David S . Miller, Paolo Abeni, netdev
On Mon, May 9, 2022 at 10:21 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Mon, 9 May 2022 09:57:16 -0700 Eric Dumazet wrote:
> > 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 | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> > index d58669d6cb91aa30edc70d59a0a7e9d4e2298842..043c59fa0bd6d921f2d2e211348929681bfce186 100644
> > --- a/include/linux/skbuff.h
> > +++ b/include/linux/skbuff.h
> > @@ -2804,6 +2804,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)
> > {
> > + WARN_ON_ONCE(!skb_transport_header_was_set(skb));
> > return skb->head + skb->transport_header;
> > }
> >
>
> This is for prod or for syzbot?
>
> What are your feelings on putting this under a kconfig?
>
> We already have a #ifdef DEBUG in skb_checksum_none_assert()
> we could generalize that into some form of kconfig-gated
> SKB_CHECK(). Kconfig-gated so that people don't feel self-conscious
> about using it. I wrote such a patch a few times already but never
> sent it.
Sure, we can add a CONFIG_DEBUG_NET, I think it has been suggested in the past.
Then we can ask syzbot teams to turn on this option.
I will send a series with this.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-05-09 17:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-09 16:57 [PATCH net-next] net: warn if transport header was not set Eric Dumazet
2022-05-09 17:20 ` Jakub Kicinski
2022-05-09 17:28 ` Eric Dumazet
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.