All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	Paolo Abeni <pabeni@redhat.com>, netdev <netdev@vger.kernel.org>,
	Eric Dumazet <edumazet@google.com>
Subject: Re: [PATCH net-next] net: warn if transport header was not set
Date: Mon, 9 May 2022 10:20:59 -0700	[thread overview]
Message-ID: <20220509102059.26f1f16f@kernel.org> (raw)
In-Reply-To: <20220509165716.745111-1-eric.dumazet@gmail.com>

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.

  reply	other threads:[~2022-05-09 17:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2022-05-09 17:28   ` 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=20220509102059.26f1f16f@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --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 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.