Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Lin Jiapeng <ljp1205831794@gmail.com>
To: aconole@redhat.com, echaudro@redhat.com, i.maximets@ovn.org,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org, jbenc@redhat.com,
	netdev@vger.kernel.org, dev@openvswitch.org
Cc: Lin Jiapeng <jiapenglin@tencent.com>,
	stable@vger.kernel.org, TencentOS Corvus AI <corvus@tencent.com>
Subject: [PATCH net] openvswitch: reject negative L2 length in ovs_fragment()
Date: Thu, 26 Nov 2026 16:31:41 +0800	[thread overview]
Message-ID: <20261126083218.55429-1-ljp1205831794@gmail.com> (raw)

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


             reply	other threads:[~2026-11-26  8:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  8:31 Lin Jiapeng [this message]
2026-11-26  9:14 ` [PATCH net] openvswitch: reject negative L2 length in ovs_fragment() Jiri Benc
2026-11-26  9:34   ` Lin Jiapeng
2026-11-26 10:08     ` Jiri Benc

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=20261126083218.55429-1-ljp1205831794@gmail.com \
    --to=ljp1205831794@gmail.com \
    --cc=aconole@redhat.com \
    --cc=corvus@tencent.com \
    --cc=davem@davemloft.net \
    --cc=dev@openvswitch.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=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stable@vger.kernel.org \
    /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