[PATCH mt76] wifi: mt76: mt7603: drop RX frame with a header gap past its end

Maoyi Xie maoyixie.tju at gmail.com
Mon Nov 30 05:58:43 PST 2026


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




More information about the linux-arm-kernel mailing list