[PATCH wireless] wifi: cfg80211: don't parse the SNAP header of a too-short A-MSDU subframe
From: Xiang Mei
Date: Tue Nov 24 2026 - 03:33:42 EST
ieee80211_amsdu_to_8023s() bounds a subframe only from above
(subframe_len > remaining), so an associated peer can declare a payload
Length of 0..7, yet ieee80211_get_8023_tunnel_proto() always reads 8
bytes from frame->data. With Length = 6 and payload aa aa 03 00 00 00,
the rfc1042_header match succeeds on the peer's own bytes, and the two
bytes past the frame are copied into h_proto and delivered up the stack.
The frame length sets where they sit in the skb head, so the read is
aimable and repeatable. Injected over mac80211_hwsim (init_on_alloc=0),
the delivered EtherType is stale heap content instead of the declared
0x0006:
aimed at object offset 410 -> leaked 7372
aimed at object offset 410 -> leaked 3d31
aimed at object offset 414 -> leaked 225f
aimed at object offset 418 -> leaked 7573
With this patch the same frames deliver 0006. syzbot reported the same
read as a KMSAN uninit-value.
Only parse the header when the subframe holds those 8 bytes; a shorter
one keeps the 802.3 length semantics it already gets on a SNAP mismatch.
Cc: stable@xxxxxxxxxxxxxxx
Fixes: eaf85ca7fecb ("wireless: add ieee80211_amsdu_to_8023s")
Reported-by: syzbot+3d9e2c65bdd43a254924@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=3d9e2c65bdd43a254924
Reported-by: co+0b5d5f4d3472df53@xxxxxxx
Signed-off-by: Xiang Mei <xmei5@xxxxxxx>
---
net/wireless/util.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/wireless/util.c b/net/wireless/util.c
index ebb1f6ec7efc..0a0823d1d517 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -1034,7 +1034,9 @@ void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list,
frame->priority = skb->priority;
if (likely(iftype != NL80211_IFTYPE_MESH_POINT &&
- ieee80211_get_8023_tunnel_proto(frame->data, &hdr.eth.h_proto)))
+ pskb_may_pull(frame, ETH_ALEN + 2) &&
+ ieee80211_get_8023_tunnel_proto(frame->data,
+ &hdr.eth.h_proto)))
skb_pull(frame, ETH_ALEN + 2);
memcpy(skb_push(frame, sizeof(hdr.eth)), &hdr.eth, sizeof(hdr.eth));
--
2.43.0