mt7921_mac_fill_rx() does not check hdr_gap against the linear data of the skb. A frame of several DMA buffers is not linear, and the hardware sets the length of the first buffer. If hdr_gap is too large, skb_pull() hits the BUG() in __skb_pull(), or 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 linear data. Fixes: 163f4d22c118 ("mt76: mt7921: add MAC support") Cc: stable@vger.kernel.org Signed-off-by: Felix Fietkau --- drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c index 7f80ffbd278c..23bc0d946c56 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c @@ -383,6 +383,9 @@ mt7921_mac_fill_rx(struct mt792x_dev *dev, struct sk_buff *skb) } hdr_gap = (u8 *)rxd - skb->data + 2 * remove_pad; + if (hdr_gap >= skb_headlen(skb)) + return -EINVAL; + if (hdr_trans && ieee80211_has_morefrags(fc)) { struct ieee80211_vif *vif; int err; -- 2.47.3