> mt7996_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. For a > first fragment, mt7996_reverse_frag0_hdr_trans() reads an Ethernet > header after hdr_gap, and a frame too short for it makes the skb_push() > of the LLC header hit skb_under_panic(). > > Drop the frame if hdr_gap is not within the linear data, or if a first > fragment holds no full Ethernet header there. > > Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices") > Cc: stable@vger.kernel.org > Signed-off-by: Felix Fietkau Reviewed-by: Lorenzo Bianconi > --- > drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c > index b2e871b679dd..dfce362a0cc9 100644 > --- a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c > +++ b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c > @@ -203,6 +203,9 @@ static int mt7996_reverse_frag0_hdr_trans(struct sk_buff *skb, u16 hdr_gap) > struct mt7996_sta *msta; > u16 frame_control; > > + if (skb_headlen(skb) < hdr_gap + sizeof(*eth_hdr)) > + return -EINVAL; > + > if (le32_get_bits(rxd[3], MT_RXD3_NORMAL_ADDR_TYPE) != > MT_RXD3_NORMAL_U2M) > return -EINVAL; > @@ -642,6 +645,9 @@ mt7996_mac_fill_rx(struct mt7996_dev *dev, enum mt76_rxq_id q, > return -EINVAL; > > hdr_gap = (u8 *)rxd - skb->data + 2 * remove_pad; > + if (hdr_gap >= skb_headlen(skb)) > + return -EINVAL; > + > if (hdr_trans && ieee80211_has_morefrags(fc)) { > if (mt7996_reverse_frag0_hdr_trans(skb, hdr_gap)) > return -EINVAL; > -- > 2.47.3 > >