Skip to contentSkip to conversation

wifi: cfg80211: don't parse the SNAP header of a too-short A-MSDU subframe

PATCH New Xiang Mei 1 participant 1 message Nov 24

Subsystems (2)
lore
Share & tools
lore

Xiang Mei

author
#0 lore raw

PATCH 1/1 wifi: cfg80211: don't parse the SNAP header of a too-short A-MSDU subframe

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.

Fixes eaf85ca7fecb ("wireless: add ieee80211_amsdu_to_8023s")
Reported-by [email protected]
Reported-by [email protected]
---
 net/wireless/util.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/wireless/util.c +3 -1
index ebb1f6ec7efc..0a0823d1d517 100644
@@ -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));
Signature · 1 line
2.43.0