From: Maoyi Xie <maoyixie.tju@gmail.com>
To: Felix Fietkau <nbd@nbd.name>,
Lorenzo Bianconi <lorenzo@kernel.org>,
Ryder Lee <ryder.lee@mediatek.com>
Cc: Shayne Chen <shayne.chen@mediatek.com>,
Sean Wang <sean.wang@mediatek.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
linux-wireless@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org
Subject: [PATCH mt76] wifi: mt76: mt7603: drop RX frame with a header gap past its end
Date: Mon, 30 Nov 2026 21:58:43 +0800 [thread overview]
Message-ID: <20261130135843.2678300-1-maoyixie.tju@gmail.com> (raw)
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
reply other threads:[~2026-11-30 13:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261130135843.2678300-1-maoyixie.tju@gmail.com \
--to=maoyixie.tju@gmail.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=nbd@nbd.name \
--cc=ryder.lee@mediatek.com \
--cc=sean.wang@mediatek.com \
--cc=shayne.chen@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox