From: Lin Jiapeng <[email protected]>
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: [email protected]
Reported-by: TencentOS Corvus AI <[email protected]>
Signed-off-by: Lin Jiapeng <[email protected]>
---
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
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev