Netdev List
 help / color / mirror / Atom feed
* [PATCH net] openvswitch: reject negative L2 length in ovs_fragment()
@ 2026-11-26  8:31 Lin Jiapeng
  2026-11-26  9:14 ` Jiri Benc
  0 siblings, 1 reply; 4+ messages in thread
From: Lin Jiapeng @ 2026-11-26  8:31 UTC (permalink / raw)
  To: aconole, echaudro, i.maximets, davem, edumazet, kuba, pabeni,
	horms, jbenc, netdev, dev
  Cc: Lin Jiapeng, stable, TencentOS Corvus AI

From: Lin Jiapeng <jiapenglin@tencent.com>

ovs_fragment() refragments MPLS packets from their inner network header
and saves the L2 header in a MAX_L2_LEN-byte buffer before fragmenting.

POP_MPLS can leave inner_network_header behind skb->data. The signed
offset is then negative and passes the "> MAX_L2_LEN" check, so
prepare_frag() widens it to 0xfffffffc for memcpy() into l2_data. An
unprivileged user can trigger this on both IPv4 and IPv6 paths. KASAN
reports:
     BUG: KASAN: slab-out-of-bounds in prepare_frag+0x3c2/0x4c0
     Read of size 4294967292 at addr ff110001059cf044 by task
     ovs_frag_trigge/132
     __asan_memcpy+0x23/0x60
     prepare_frag+0x3c2/0x4c0
     ovs_fragment+0x578/0x860

Reject a negative offset together with an oversized one and drop the
packet through OVS_DROP_FRAG_L2_TOO_LONG. Valid offsets are unchanged.

Fixes: c66549ffd666 ("openvswitch: correctly fragment packet with mpls headers")
Cc: stable@vger.kernel.org
Reported-by: TencentOS Corvus AI <corvus@tencent.com>
Signed-off-by: Lin Jiapeng <jiapenglin@tencent.com>
---
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 12e339cbf791..9c19fe8676a7 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -788,7 +788,8 @@ static void ovs_fragment(struct net *net, struct vport *vport,
 		skb->network_header = skb->inner_network_header;
 	}
 
-	if (skb_network_offset(skb) > MAX_L2_LEN) {
+	if (skb_network_offset(skb) > MAX_L2_LEN ||
+	    skb_network_offset(skb) < 0) {
 		OVS_NLERR(1, "L2 header too long to fragment");
 		reason = OVS_DROP_FRAG_L2_TOO_LONG;
 		goto err;

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-26 10:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26  8:31 [PATCH net] openvswitch: reject negative L2 length in ovs_fragment() Lin Jiapeng
2026-11-26  9:14 ` Jiri Benc
2026-11-26  9:34   ` Lin Jiapeng
2026-11-26 10:08     ` Jiri Benc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox