The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Antoine Tenart <atenart@kernel.org>
To: Chengfeng Ye <nicoyip.dev@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	 Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
	 Kuniyuki Iwashima <kuniyu@google.com>,
	Richard Gobert <richardbgobert@gmail.com>,
	 Xuanqiang Luo <luoxuanqiang@kylinos.cn>,
	Xin Long <lucien.xin@gmail.com>, William Tu <u9012063@gmail.com>,
	 netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH net] fou: ensure GUE headers have enough headroom
Date: Tue, 4 Aug 2026 14:22:24 +0200	[thread overview]
Message-ID: <anHVNZdaVfxzbXCO@kwain> (raw)
In-Reply-To: <20260801060115.3538849-1-nicoyip.dev@gmail.com>

On Sat, Aug 01, 2026 at 02:01:15PM +0800, Chengfeng Ye wrote:
> ipgre_changelink() installs GUE encapsulation before it publishes the
> new GRE header length and updates dev->needed_headroom.  The transmit
> path does not serialize with RTNL, so it can interleave as follows:
> 
>   CPU 0 (ipgre_changelink)        CPU 1 (ipgre_xmit)
>   install GUE encapsulation
>                                   reserve the old needed_headroom
>   publish larger GRE flags
>   update tunnel->tun_hlen
>                                   push the larger GRE header
>                                   push the GUE and UDP headers
>   update dev->needed_headroom
> 
> With REMCSUM, the new layout can push 16 bytes of GRE and 20 bytes of
> GUE/UDP headers into an skb with only 32 bytes of actual headroom.  The
> final UDP push writes four bytes before skb->head.
> 
> With the update window widened, the kernel reported:
> 
>   skbuff: skb_under_panic: ... len:128 put:8 ... dev:gre0poc
>   kernel BUG at net/core/skbuff.c:214!
>   Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI
>   Call Trace:
>    skb_push
>    fou_build_udp
>    gue_build_header
>    ip_tunnel_xmit
>    __gre_xmit
>    ipgre_xmit
> 
> Make __gue_build_header() ensure space for both the GUE header it is
> about to push and the UDP header that follows.  On normally sized skbs
> the check is a no-op.  If configuration changes race with transmission,
> skb_cow_head() expands the head before either GUE write, or returns an
> error without modifying the packet.
> 
> Fixes: dd9d598c6657 ("ip_gre: add the support for i/o_flags update via netlink")
> Cc: stable@vger.kernel.org
> Assisted-by: Codex:gpt-5
> Signed-off-by: Chengfeng Ye <nicoyip.dev@gmail.com>
> ---
>  net/ipv4/fou_core.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/net/ipv4/fou_core.c b/net/ipv4/fou_core.c
> index ab09dfcdecbd..8cf0d43acb41 100644
> --- a/net/ipv4/fou_core.c
> +++ b/net/ipv4/fou_core.c
> @@ -980,6 +980,8 @@ int __gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,
>  						skb, 0, 0, false);
>  
>  	hdrlen = sizeof(struct guehdr) + optlen;
> +	if (skb_cow_head(skb, hdrlen + sizeof(struct udphdr)))
> +		return -ENOMEM;

My understanding is this takes into account the UDP header pushed in
fou_build_udp. Isn't fou_build_header also affected by the same issue
then? (If so check the IPv6 paths too).

Also please check Sashiko's output,
https://sashiko.dev/#/patchset/20260801060115.3538849-1-nicoyip.dev%40gmail.com

      reply	other threads:[~2026-08-04 12:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-01  6:01 [PATCH net] fou: ensure GUE headers have enough headroom Chengfeng Ye
2026-08-04 12:22 ` Antoine Tenart [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=anHVNZdaVfxzbXCO@kwain \
    --to=atenart@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucien.xin@gmail.com \
    --cc=luoxuanqiang@kylinos.cn \
    --cc=netdev@vger.kernel.org \
    --cc=nicoyip.dev@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=richardbgobert@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=u9012063@gmail.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