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") Signed-off-by: Eason Lai --- drivers/net/wireless/mediatek/mt76/mt7925/mac.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c index 3389a3236187..b5eae71c5285 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c @@ -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; -- 2.45.2