[PATCH mt76 3/3] wifi: mt76: mt7996: fix out-of-bounds read in mt7996_mac_add_txs
Maoyi Xie
maoyixie.tju at gmail.com
Tue Dec 1 17:01:30 PST 2026
mt7996_queue_rx_skb() walks the TXS entries up to skb->len. An skb of
several DMA buffers from mt76_dma_rx_process() is not linear, so
skb->data only covers skb_headlen(skb) bytes, and the loop reads past
the head buffer of the skb.
Bound the walk by skb_headlen(skb). For a linear skb both lengths are
equal.
Found with a CodeQL-based static analysis tool. Reproduced in a
userspace harness under AddressSanitizer. Not tested on hardware.
Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Cc: stable at vger.kernel.org
Signed-off-by: Maoyi Xie <maoyixie.tju at gmail.com>
---
I used an LLM to help write the harness and this patch.
drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
index dfce362a0cc9..7a33f5ec0551 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
@@ -1715,7 +1715,7 @@ void mt7996_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
{
struct mt7996_dev *dev = container_of(mdev, struct mt7996_dev, mt76);
__le32 *rxd = (__le32 *)skb->data;
- __le32 *end = (__le32 *)&skb->data[skb->len];
+ __le32 *end = (__le32 *)&skb->data[skb_headlen(skb)];
enum rx_pkt_type type;
type = le32_get_bits(rxd[0], MT_RXD0_PKT_TYPE);
--
2.34.1
More information about the linux-arm-kernel
mailing list