Linux-mediatek Archive on lore.kernel.org
 help / color / mirror / Atom feed
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, stable@vger.kernel.org
Subject: [PATCH] wifi: mt76: sdio: check the RX packet length in mt76s_rx_run_queue()
Date: Thu, 19 Nov 2026 20:49:28 +0800	[thread overview]
Message-ID: <20261119124928.1398520-1-maoyixie.tju@gmail.com> (raw)

mt76s_rx_run_queue() reads the packets that the chip announced in the
interrupt status into one buffer. It then takes the length of each
packet from the first word of the packet and does not compare it with
the bytes read. A larger length can make the driver read TX status
records past the end of the buffer and build an skb that extends past
it.

Stop at a packet that does not fit in the bytes read.

Found with a CodeQL-based static analysis tool that we are developing.
Reproduced in a userspace harness under ASan, which reports no such
read with this patch. Not tested on hardware, only compile-tested with
W=1 on next-20261116.

Fixes: dacf0acfe2ce ("mt76: sdio: extend sdio module to support CONNAC2")
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/sdio_txrx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/sdio_txrx.c b/drivers/net/wireless/mediatek/mt76/sdio_txrx.c
index 3f314e8e1e69f92..86dd1165d2c7f1f 100644
--- a/drivers/net/wireless/mediatek/mt76/sdio_txrx.c
+++ b/drivers/net/wireless/mediatek/mt76/sdio_txrx.c
@@ -127,6 +127,8 @@ mt76s_rx_run_queue(struct mt76_dev *dev, enum mt76_rxq_id qid,
 
 		/* parse rxd to get the actual packet length */
 		len = le32_get_bits(rxd[0], GENMASK(15, 0));
+		if (len > end - buf)
+			break;
 
 		/* Optimized path for TXS */
 		if (!dev->drv->rx_check || dev->drv->rx_check(dev, buf, len)) {

base-commit: 7e1392a42ea288d70a266f6553fe06f57f8647ea
-- 
2.34.1



             reply	other threads:[~2026-11-19 12:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 12:49 Maoyi Xie [this message]
2026-11-19 16:49 ` [PATCH] wifi: mt76: sdio: check the RX packet length in mt76s_rx_run_queue() Lorenzo Bianconi

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=20261119124928.1398520-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 \
    --cc=stable@vger.kernel.org \
    /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