From: Maoyi Xie <maoyixie.tju@gmail.com>
To: Arend van Spriel <arend.vanspriel@broadcom.com>
Cc: linux-wireless@vger.kernel.org, brcm80211@lists.linux.dev,
brcm80211-dev-list.pdl@broadcom.com
Subject: [PATCH wireless 1/2] wifi: brcmfmac: sdio: reject glom chains longer than U16_MAX
Date: Tue, 1 Dec 2026 17:12:14 +0800 [thread overview]
Message-ID: <20261201091215.3661018-2-maoyixie.tju@gmail.com> (raw)
In-Reply-To: <20261201091215.3661018-1-maoyixie.tju@gmail.com>
brcmf_sdio_rxglom() passes the length of the glom chain to
brcmf_sdiod_recv_chain() as a u16. If the descriptor lengths, padded to
a whole block, add up to more than 65535, the length wraps. On a host
without scatter-gather support, brcmf_sdiod_recv_chain() then allocates
glom_skb with the wrapped length and reads up to 64 KiB past its end.
A valid superframe is at most U16_MAX bytes, since its header holds a
16-bit length. Sum the descriptor lengths in a uint and reject a longer
chain.
Found with a CodeQL-based static analysis tool. Reproduced in a
userspace harness under AddressSanitizer. Not tested on hardware.
Fixes: a413e39a3857 ("brcmfmac: fix brcmf_sdcard_recv_chain() for host without sg support")
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/broadcom/brcm80211/brcmfmac/sdio.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index d30468cac360..d428372bddd3 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -1514,7 +1514,8 @@ static void brcmf_sdio_hdpack(struct brcmf_sdio *bus, u8 *header,
static u8 brcmf_sdio_rxglom(struct brcmf_sdio *bus, u8 rxseq)
{
- u16 dlen, totlen;
+ u16 dlen;
+ uint totlen;
u8 *dptr, num = 0;
u16 sublen;
struct sk_buff *pfirst, *pnext;
@@ -1566,6 +1567,12 @@ static u8 brcmf_sdio_rxglom(struct brcmf_sdio *bus, u8 rxseq)
(roundup(totlen, bus->blocksize) - totlen);
totlen = roundup(totlen, bus->blocksize);
}
+ if (totlen > U16_MAX) {
+ brcmf_err("descriptor total len %u too long\n",
+ totlen);
+ pnext = NULL;
+ break;
+ }
/* Allocate/chain packet for next subframe */
pnext = brcmu_pkt_buf_get_skb(sublen + bus->sgentry_align);
--
2.34.1
next prev parent reply other threads:[~2026-12-01 9:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 9:12 [PATCH wireless 0/2] wifi: brcmfmac: check a glom length and a ring index from the device Maoyi Xie
2026-12-01 9:12 ` Maoyi Xie [this message]
2026-12-01 9:12 ` [PATCH wireless 2/2] wifi: brcmfmac: msgbuf: reject an out-of-range D2H ring write index Maoyi Xie
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=20261201091215.3661018-2-maoyixie.tju@gmail.com \
--to=maoyixie.tju@gmail.com \
--cc=arend.vanspriel@broadcom.com \
--cc=brcm80211-dev-list.pdl@broadcom.com \
--cc=brcm80211@lists.linux.dev \
--cc=linux-wireless@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