mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gabriel Goller <g.goller@proxmox.com>
To: Yuya Kusakabe <yuya.kusakabe@gmail.com>
Cc: Andrea Mayer <andrea.mayer@uniroma2.it>,
	 "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>,
	 Justin Iurman <justin.iurman@gmail.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v3] net: ipv6: keep room for the mac header in dst_dev_overhead()
Date: Tue, 22 Sep 2026 13:24:50 +0200	[thread overview]
Message-ID: <arJlHYp_IfNJG7jg@luna.proxmox.com> (raw)
In-Reply-To: <20260922-seg6-maclen-headroom-v3-1-7b2f982ef79d@gmail.com>

On 22.09.2026 05:49, Yuya Kusakabe wrote:
> The seg6, ioam6 and rpl lwtunnels size their skb_cow_head() request as
> the length they are about to push plus dst_dev_overhead(), then push the
> new headers and rebuild the mac header below them with
> skb_mac_header_rebuild().  That rebuild needs skb->mac_len of headroom,
> but dst_dev_overhead() leaves LL_RESERVED_SPACE() of the egress device,
> 16 bytes for plain Ethernet.
> 
> Where the mac header is longer than that, as it is on ingress through a
> VLAN device with reorder_hdr off, the rebuild runs out of room:
> skb_set_mac_header(skb, -skb->mac_len) computes a negative offset,
> stores it unchecked in the u16 skb->mac_header, and the memmove that
> follows writes skb->mac_len bytes about 64 KB past skb->head.
> Forwarding plain ping6 traffic through such a device reproduces it on
> all five seg6 encapsulation modes and on the rpl and ioam6 inline paths;
> skb->mac_header comes back as 65534 on a 704-byte head.
> 
> Return the larger of the two.  The helper already returns skb->mac_len
> when it has no dst, so this only makes the other branch agree, and it
> covers every caller rather than each call site in turn.
> 
> Fixes: 40475b63761a ("net: ipv6: seg6_iptunnel: mitigate 2-realloc issue")
> Fixes: dce525185bc9 ("net: ipv6: ioam6_iptunnel: mitigate 2-realloc issue")
> Fixes: 985ec6f5e623 ("net: ipv6: rpl_iptunnel: mitigate 2-realloc issue")
> Suggested-by: Andrea Mayer <andrea.mayer@uniroma2.it>
> Assisted-by: LLM
> Signed-off-by: Yuya Kusakabe <yuya.kusakabe@gmail.com>

LGTM

Did a quick test and could reproduce the issue:

FAIL seg6 inline nsegs=4
[    3.557169] BUG: KASAN: slab-use-after-free in __seg6_do_srh_inline+0x34b/0x620

Couldn't reproduce it after applying this patch.

Consider:
Reviewed-by: Gabriel Goller <g.goller@proxmox.com>
Tested-by: Gabriel Goller <g.goller@proxmox.com>




  parent reply	other threads:[~2026-09-22 11:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21 20:49 Yuya Kusakabe
2026-09-21 21:59 ` Justin Iurman
2026-09-22 11:24 ` Gabriel Goller [this message]
2026-09-22 14:49   ` Eric Dumazet
2026-09-22 15:13 ` Andrea Mayer

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=arJlHYp_IfNJG7jg@luna.proxmox.com \
    --to=g.goller@proxmox.com \
    --cc=andrea.mayer@uniroma2.it \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=justin.iurman@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=yuya.kusakabe@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

all inboxes | Powered by JetHome®