Skip to contentSkip to conversation

wifi: mt76: mt7925: drop RX frame with a header gap past its end

PATCH New Eason Lai 1 participant 1 message Nov 27

Subsystems (2)
lore
Share & tools
lore

Eason Lai

author
#0 lore raw

PATCH 1/1 wifi: mt76: mt7925: drop RX frame with a header gap past its end

hdr_gap includes the header padding from the RXD, but is not checked against skb->len. If it is too large, skb_pull() fails and leaves no headroom, so the __skb_push() in mt76_insert_ccmp_hdr() writes before skb->head.

Drop the frame if hdr_gap is not within the skb.

Fixes c948b5da6bbe ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips")
---
 drivers/net/wireless/mediatek/mt76/mt7925/mac.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7925/mac.c +3 -0
index 3389a3236187..b5eae71c5285 100644
@@ -599,6 +599,9 @@ mt7925_mac_fill_rx(struct mt792x_dev *dev, struct sk_buff *skb)
 	}
 
 	hdr_gap = (u8 *)rxd - skb->data + 2 * remove_pad;
+	if (hdr_gap >= skb->len)
+		return -EINVAL;
+
 	if (hdr_trans && ieee80211_has_morefrags(fc)) {
 		if (mt7925_reverse_frag0_hdr_trans(skb, hdr_gap))
 			return -EINVAL;
Signature · 1 line
2.45.2