Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH mt76 0/3] wifi: mt76: bound the TXS walk by the head buffer in three drivers
@ 2026-12-02  1:01 Maoyi Xie
  2026-12-02  1:01 ` [PATCH mt76 1/3] wifi: mt76: mt7603: fix out-of-bounds read in mt7603_mac_add_txs Maoyi Xie
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Maoyi Xie @ 2026-12-02  1:01 UTC (permalink / raw)
  To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee
  Cc: Shayne Chen, Sean Wang, Matthias Brugger,
	AngeloGioacchino Del Regno, linux-wireless, linux-arm-kernel,
	linux-mediatek

This is the same fix as the mt7921 and mt7925 patches at [1] and [2],
for mt7603, mt7915 and mt7996.

Found with a CodeQL-based static analysis tool that we are developing.
Each case was reproduced in a userspace harness under AddressSanitizer.
Not tested on hardware. Compile-tested with W=1 on the mt76 tree.

I used an LLM to help write the harnesses and these patches.

[1] https://lore.kernel.org/linux-wireless/20261129193131.3367661-17-nbd@nbd.name/
[2] https://lore.kernel.org/linux-wireless/20261129193131.3367661-18-nbd@nbd.name/

Maoyi Xie (3):
  wifi: mt76: mt7603: fix out-of-bounds read in mt7603_mac_add_txs
  wifi: mt76: mt7915: fix out-of-bounds read in mt7915_mac_add_txs
  wifi: mt76: mt7996: fix out-of-bounds read in mt7996_mac_add_txs

 drivers/net/wireless/mediatek/mt76/mt7603/dma.c | 2 +-
 drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 2 +-
 drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

-- 
2.34.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH mt76 1/3] wifi: mt76: mt7603: fix out-of-bounds read in mt7603_mac_add_txs
  2026-12-02  1:01 [PATCH mt76 0/3] wifi: mt76: bound the TXS walk by the head buffer in three drivers Maoyi Xie
@ 2026-12-02  1:01 ` Maoyi Xie
  2026-12-02  1:01 ` [PATCH mt76 2/3] wifi: mt76: mt7915: fix out-of-bounds read in mt7915_mac_add_txs Maoyi Xie
  2026-12-02  1:01 ` [PATCH mt76 3/3] wifi: mt76: mt7996: fix out-of-bounds read in mt7996_mac_add_txs Maoyi Xie
  2 siblings, 0 replies; 4+ messages in thread
From: Maoyi Xie @ 2026-12-02  1:01 UTC (permalink / raw)
  To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee
  Cc: Shayne Chen, Sean Wang, Matthias Brugger,
	AngeloGioacchino Del Regno, linux-wireless, linux-arm-kernel,
	linux-mediatek

mt7603_queue_rx_skb() walks the TXS entries up to skb->len. A frame of
several DMA buffers 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: c8846e101502 ("mt76: add driver for MT7603E and MT7628/7688")
Cc: stable@vger.kernel.org
Signed-off-by: Maoyi Xie <maoyixie.tju@gmail.com>
---
I used an LLM to help write the harness and this patch.

 drivers/net/wireless/mediatek/mt76/mt7603/dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/dma.c b/drivers/net/wireless/mediatek/mt76/mt7603/dma.c
index 491c8c937031..b7cddd3e56d8 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7603/dma.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7603/dma.c
@@ -113,7 +113,7 @@ void mt7603_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
 {
 	struct mt7603_dev *dev = container_of(mdev, struct mt7603_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



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH mt76 2/3] wifi: mt76: mt7915: fix out-of-bounds read in mt7915_mac_add_txs
  2026-12-02  1:01 [PATCH mt76 0/3] wifi: mt76: bound the TXS walk by the head buffer in three drivers Maoyi Xie
  2026-12-02  1:01 ` [PATCH mt76 1/3] wifi: mt76: mt7603: fix out-of-bounds read in mt7603_mac_add_txs Maoyi Xie
@ 2026-12-02  1:01 ` Maoyi Xie
  2026-12-02  1:01 ` [PATCH mt76 3/3] wifi: mt76: mt7996: fix out-of-bounds read in mt7996_mac_add_txs Maoyi Xie
  2 siblings, 0 replies; 4+ messages in thread
From: Maoyi Xie @ 2026-12-02  1:01 UTC (permalink / raw)
  To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee
  Cc: Shayne Chen, Sean Wang, Matthias Brugger,
	AngeloGioacchino Del Regno, linux-wireless, linux-arm-kernel,
	linux-mediatek

mt7915_queue_rx_skb() walks the TXS entries up to skb->len. A frame of
several DMA buffers 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: 3de4cb175656 ("mt76: mt7915: add support for tx status reporting")
Cc: stable@vger.kernel.org
Signed-off-by: Maoyi Xie <maoyixie.tju@gmail.com>
---
I used an LLM to help write the harness and this patch.

 drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
index 334af60f543e..2265f9adb336 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
@@ -1060,7 +1060,7 @@ void mt7915_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
 {
 	struct mt7915_dev *dev = container_of(mdev, struct mt7915_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



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH mt76 3/3] wifi: mt76: mt7996: fix out-of-bounds read in mt7996_mac_add_txs
  2026-12-02  1:01 [PATCH mt76 0/3] wifi: mt76: bound the TXS walk by the head buffer in three drivers Maoyi Xie
  2026-12-02  1:01 ` [PATCH mt76 1/3] wifi: mt76: mt7603: fix out-of-bounds read in mt7603_mac_add_txs Maoyi Xie
  2026-12-02  1:01 ` [PATCH mt76 2/3] wifi: mt76: mt7915: fix out-of-bounds read in mt7915_mac_add_txs Maoyi Xie
@ 2026-12-02  1:01 ` Maoyi Xie
  2 siblings, 0 replies; 4+ messages in thread
From: Maoyi Xie @ 2026-12-02  1:01 UTC (permalink / raw)
  To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee
  Cc: Shayne Chen, Sean Wang, Matthias Brugger,
	AngeloGioacchino Del Regno, linux-wireless, linux-arm-kernel,
	linux-mediatek

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@vger.kernel.org
Signed-off-by: Maoyi Xie <maoyixie.tju@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



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-02  1:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02  1:01 [PATCH mt76 0/3] wifi: mt76: bound the TXS walk by the head buffer in three drivers Maoyi Xie
2026-12-02  1:01 ` [PATCH mt76 1/3] wifi: mt76: mt7603: fix out-of-bounds read in mt7603_mac_add_txs Maoyi Xie
2026-12-02  1:01 ` [PATCH mt76 2/3] wifi: mt76: mt7915: fix out-of-bounds read in mt7915_mac_add_txs Maoyi Xie
2026-12-02  1:01 ` [PATCH mt76 3/3] wifi: mt76: mt7996: fix out-of-bounds read in mt7996_mac_add_txs Maoyi Xie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox