Netdev List
 help / color / mirror / Atom feed
From: Kyuwon Cho <kyuwoncho18@gmail.com>
To: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Willem de Bruijn <willemb@google.com>,
	Simon Horman <horms@kernel.org>, David Ahern <dsahern@kernel.org>,
	Fourie Zhang <littleddfu@gmail.com>,
	Aaron Conole <aconole@redhat.com>,
	Eelco Chaudron <echaudro@redhat.com>,
	Ilya Maximets <i.maximets@ovn.org>, Jiri Benc <jbenc@redhat.com>,
	Lin Jiapeng <jiapenglin@tencent.com>,
	netdev@vger.kernel.org
Subject: [PATCH net] net: mpls: clear inner_protocol when mpls_forward() pops the last label
Date: Tue,  1 Dec 2026 17:04:23 +0900	[thread overview]
Message-ID: <179607412883.627473.3063198838105400446@gmail.com> (raw)

Commit 78a86d75a70e ("net: mpls: clear inner_protocol when the last
label is popped") made skb_mpls_pop() drop the inner header that
skb_mpls_push() records once the packet is no longer MPLS. MPLS
forwarding pops labels without skb_mpls_pop(): mpls_forward() pulls
each label itself, and on the last one mpls_egress() switches
skb->protocol to IPv4 or IPv6 but leaves skb->inner_protocol and
skb->inner_network_header in place.

A packet that had MPLS pushed by an Open vSwitch datapath, was then
forwarded by MPLS routes, and reaches an OVS datapath again keeps the
old record. A second push_mpls does not record a new inner header,
because inner_protocol is still set, and ovs_fragment() trusts the old
one. After the forwarding hops have moved skb->data past it,
skb_network_offset() is negative and prepare_frag() copies
(unsigned int)-2 bytes:

  BUG: KASAN: slab-out-of-bounds in prepare_frag+0x3ab/0x510
  Read of size 4294967294 at addr ff11000013f16050 by task test/106
  Call Trace:
   <IRQ>
   __asan_memcpy+0x23/0x60
   prepare_frag+0x3ab/0x510
   ovs_fragment+0x517/0x840
   do_execute_actions+0x580e/0x7380
   ovs_execute_actions+0xd3/0x3e0
   ovs_dp_process_packet+0x21c/0x500
   ovs_vport_receive+0x22e/0x380
   netdev_frame_hook+0x396/0x6b0

An unprivileged user can set this up in its own user and network
namespace.

Clear inner_protocol in mpls_egress() once the packet is IP again, as
skb_mpls_pop() does.

Fixes: 48d2ab609b6b ("net: mpls: Fixups for GSO")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>
---
The issue was found by an LLM-guided test generator that we are
developing as a research prototype. I sent it privately on 2026-11-18;
it comes to the list now because security-bugs.rst asks for bugs found
with AI assistance to be handled in public. The reproducer is available
on request.

Lin Jiapeng has posted a fix for the same prepare_frag() overflow
reached through OVS PUSH_MPLS/POP_MPLS actions:
https://lore.kernel.org/all/20261126083218.55429-1-ljp1205831794@gmail.com/
That path pops labels with skb_mpls_pop(). This one is MPLS routing:
mpls_forward() pops the last label itself and never calls
skb_mpls_pop(), so a check there would not cover it.

Reproduced on mainline v7.4-rc5 (fe6ff8d5d675, with KASAN); the patch
is against net (76fca30e8d34), and with it the reproducer runs clean.

 net/mpls/af_mpls.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index ad4ad6f2001a..e2e5da8d757b 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -361,6 +361,9 @@ static bool mpls_egress(struct net *net, struct mpls_route *rt,
 		break;
 	}
 
+	if (success)
+		skb->inner_protocol = 0;
+
 	return success;
 }
 
-- 
2.43.0


             reply	other threads:[~2026-12-01  8:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  8:04 Kyuwon Cho [this message]
2026-12-04 11:04 ` [PATCH net] net: mpls: clear inner_protocol when mpls_forward() pops the last label netdev-bot+sashiko

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=179607412883.627473.3063198838105400446@gmail.com \
    --to=kyuwoncho18@gmail.com \
    --cc=aconole@redhat.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=echaudro@redhat.com \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=i.maximets@ovn.org \
    --cc=jbenc@redhat.com \
    --cc=jiapenglin@tencent.com \
    --cc=kuba@kernel.org \
    --cc=littleddfu@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.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