All of lore.kernel.org
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Zihan Xi <zihanx@nebusec.ai>,  netdev@vger.kernel.org
Cc: davem@davemloft.net,  edumazet@google.com,  pabeni@redhat.com,
	 horms@kernel.org,  steffen.klassert@secunet.com,
	 herbert@gondor.apana.org.au,  kerneljasonxing@gmail.com,
	 kuniyu@google.com,  bjorn@kernel.org,  bigeasy@linutronix.de,
	 jiayuan.chen@linux.dev,  gustavoars@kernel.org,
	 jlayton@kernel.org,  runyu.xiao@seu.edu.cn,  kees@kernel.org,
	 willemb@google.com,  lirongqing@baidu.com,  vega@nebusec.ai,
	 zihanx@nebusec.ai
Subject: Re: [PATCH net v2 1/1] net: skbuff: reject skb header offset updates that truncate
Date: Sun, 02 Aug 2026 10:49:34 -0400	[thread overview]
Message-ID: <willemdebruijn.kernel.65e6c22f2aa7@gmail.com> (raw)
In-Reply-To: <98097df6369ec684ede15b3658bfe7acd0cd5daf.1785529351.git.zihanx@nebusec.ai>

Zihan Xi wrote:
> raw_send_hdrinc() and rawv6_send_hdrinc() reserve LL headroom before
> storing skb header offsets in 16-bit fields. If the reserved headroom
> grows past the representable range, skb_reset_network_header() truncates
> the stored offset and the hdrincl path later copies the user header to
> the wrong location.
> 
> On IPv4 this can also happen after the user header is copied, because the
> transport header is advanced by iphlen. The value U16_MAX itself is not a
> valid transport header offset either, because it is used as the unset
> sentinel.
> 
> The initial raw route is not the only place that matters. LOCAL_OUT can
> reroute the skb, XFRM can add dst->header_len, and LWT or other output
> paths can grow the skb head later. More generally, positive calls into
> skb_headers_offset_update() can wrap these 16-bit offsets, while later
> paths that recompute transport_header from network_header can still
> overflow it or turn it into the U16_MAX sentinel.
> 
> Reject hdrincl sends when the initial reserved LL headroom cannot fit in
> the skb header offset fields, and reject later positive skb header offset
> updates or transport-header recomputations before they would overflow the
> stored 16-bit values.
> 
> Fixes: 1a37e412a022 ("net: Use 16bits for *_headers fields of struct skbuff")
> Cc: stable@vger.kernel.org
> Reported-by: Vega <vega@nebusec.ai>
> Assisted-by: Codex:gpt-5.4
> Signed-off-by: Zihan Xi <zihanx@nebusec.ai>

This is an enormous amount of code change, including in the hot path,
for a rare edge case.

Can we instead address this at the source at control time. E.g., fail
GRETAP (or similar) stacking if it exceeds a safe headroom?

The patch also seems to combine multiple paths. It mentions raw (and
those changes are fairly small), but then also adds checks to XFRM.
That should likely be a separate patch. If needed at all. As said,
hopefully we can catch this by restricting the bad configurations,
rather than by testing each packet over such a configuration.

      reply	other threads:[~2026-08-02 14:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-31 21:08 [PATCH net v2 0/1] net: skbuff: reject skb header offset updates that truncate Zihan Xi
2026-07-31 21:08 ` [PATCH net v2 1/1] " Zihan Xi
2026-08-02 14:49   ` Willem de Bruijn [this message]

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=willemdebruijn.kernel.65e6c22f2aa7@gmail.com \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=bigeasy@linutronix.de \
    --cc=bjorn@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gustavoars@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=horms@kernel.org \
    --cc=jiayuan.chen@linux.dev \
    --cc=jlayton@kernel.org \
    --cc=kees@kernel.org \
    --cc=kerneljasonxing@gmail.com \
    --cc=kuniyu@google.com \
    --cc=lirongqing@baidu.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=runyu.xiao@seu.edu.cn \
    --cc=steffen.klassert@secunet.com \
    --cc=vega@nebusec.ai \
    --cc=willemb@google.com \
    --cc=zihanx@nebusec.ai \
    /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.