Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH mt76] wifi: mt76: mt7603: drop RX frame with a header gap past its end
@ 2026-11-30 13:58 Maoyi Xie
  0 siblings, 0 replies; only message in thread
From: Maoyi Xie @ 2026-11-30 13:58 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_mac_fill_rx() does not check the header 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 the header 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 the header gap is not within the linear data.

Found with a CodeQL-based static analysis tool that we are developing.
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>
---
This is the same check as the mt7915 patch at [1], for mt7603.

I used an LLM to help write the harness and this patch.

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

 drivers/net/wireless/mediatek/mt76/mt7603/mac.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/mac.c b/drivers/net/wireless/mediatek/mt76/mt7603/mac.c
index c884576c9385..a1a2aa5b47a0 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7603/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7603/mac.c
@@ -692,6 +692,9 @@ mt7603_mac_fill_rx(struct mt7603_dev *dev, struct sk_buff *skb)
 		return -EINVAL;
 	}
 
+	if ((u8 *)rxd - skb->data + 2 * remove_pad >= skb_headlen(skb))
+		return -EINVAL;
+
 	skb_pull(skb, (u8 *)rxd - skb->data + 2 * remove_pad);
 
 	if (insert_ccmp_hdr) {

base-commit: 87868333220b542ff6237c93abdca84c71337f59
-- 
2.34.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-30 13:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 13:58 [PATCH mt76] wifi: mt76: mt7603: drop RX frame with a header gap past its end Maoyi Xie

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