* [PATCH] mpls: reject headroom that overflows skb header offsets
@ 2026-10-30 4:22 Kyle Zeng
2026-10-30 4:29 ` netdev-bot+sinfo
0 siblings, 1 reply; 2+ messages in thread
From: Kyle Zeng @ 2026-10-30 4:22 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
linux-kernel, outbounddisclosures
MPLS output reserves LL_RESERVED_SPACE(out_dev) plus the size of the
new label stack with skb_cow_head() or skb_cow(). The aligned expansion
can leave skb->data more than U16_MAX bytes past skb->head. Resetting
the network header then truncates the offset, so mpls_hdr() addresses
the wrong location. The subsequent neighbour output passes the negative
skb_network_offset() to __skb_pull() as an unsigned length and can write
an Ethernet header outside the skb allocation.
For example, a netkit device with needed_headroom 65488 gives an initial
network offset of 65504. Pushing one MPLS label requests 65508 bytes of
headroom, but with NET_SKB_PAD=64 the COW adds 64 bytes. The new network
offset is 65564 and truncates to 28. This can be reached with an ordinary
non-GSO IPv4 packet in a user-owned network namespace.
Check the actual headroom after COW, including its alignment slack,
before installing the inner header or pushing labels. Apply the same
check to native MPLS forwarding, including its penultimate-hop popping
path. Use the existing transmit-error and skb disposal paths.
Fixes: e3e4712ec096 ("mpls: ip tunnel support")
Fixes: 0189197f4416 ("mpls: Basic routing support")
Cc: stable@vger.kernel.org
Signed-off-by: Kyle Zeng <kylebot@openai.com>
---
I have a reproducer for this issue and can share via DM
net/mpls/af_mpls.c | 4 ++++
net/mpls/mpls_iptunnel.c | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index ad4ad6f2001a..4bfdb7c81f04 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -453,6 +453,10 @@ static int mpls_forward(struct sk_buff *skb, struct net_device *dev,
if (skb_cow(skb, hh_len + new_header_size))
goto tx_err;
+ /* The aligned expansion must still fit the u16 header offsets. */
+ if (unlikely(skb_headroom(skb) > U16_MAX))
+ goto tx_err;
+
skb->dev = out_dev;
skb->protocol = htons(ETH_P_MPLS_UC);
diff --git a/net/mpls/mpls_iptunnel.c b/net/mpls/mpls_iptunnel.c
index 1a1a0eb5b787..4eccbd911fe1 100644
--- a/net/mpls/mpls_iptunnel.c
+++ b/net/mpls/mpls_iptunnel.c
@@ -109,6 +109,10 @@ static int mpls_xmit(struct sk_buff *skb)
if (skb_cow_head(skb, hh_len + new_header_size))
goto drop;
+ /* The aligned expansion must still fit the u16 header offsets. */
+ if (unlikely(skb_headroom(skb) > U16_MAX))
+ goto drop;
+
skb_set_inner_protocol(skb, skb->protocol);
skb_reset_inner_network_header(skb);
base-commit: d89e1d186ec9271bf78e62771779e9fc03bf0fc3
--
2.56.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mpls: reject headroom that overflows skb header offsets
2026-10-30 4:22 [PATCH] mpls: reject headroom that overflows skb header offsets Kyle Zeng
@ 2026-10-30 4:29 ` netdev-bot+sinfo
0 siblings, 0 replies; 2+ messages in thread
From: netdev-bot+sinfo @ 2026-10-30 4:29 UTC (permalink / raw)
To: Kyle Zeng
Cc: netdev, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, linux-kernel, outbounddisclosures
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account. If the series needs another revision for
other reasons, please include the information in the commit messages
then.
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-30 4:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-30 4:22 [PATCH] mpls: reject headroom that overflows skb header offsets Kyle Zeng
2026-10-30 4:29 ` netdev-bot+sinfo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox