brcmf_sdio_rxglom() uses rd_new.len_nxtfrm and rd_new.dat_offset right after the superframe brcmf_sdio_hdparse() without checking errcode. On parse failure those fields are either uninitialized (the early -ENODATA/-EIO/-EPROTO returns) or hold a rejected value (the -ENXIO bad-offset return), so bus->cur_read.len gets garbage and skb_pull() runs with a garbage length. Check errcode first and drop the superframe with the same cleanup used for a bad subframe below. Fixes: 9d7d6f95bda1 ("brcmfmac: streamline header parse code of sdio glom read") Cc: stable@vger.kernel.org Signed-off-by: Shirong Zhao Acked-by: Arend van Spriel --- Changes in v3: add the Fixes tag and Cc: stable as requested by Arend van Spriel. Re-verified against current wireless.git main and wireless-next main: applies with no offset and no fuzz, and build-tested with CONFIG_BRCMUTIL=m CONFIG_BRCMFMAC=m CONFIG_BRCMFMAC_SDIO=y (baseline and patched both compile clean, 0 warnings, including a W=1 pass). No code change. Changes in v2: check errcode before sdio_release_host() so the cleanup runs under the already-claimed host, avoiding the extra release/claim cycle (suggested by Arend van Spriel). drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c index cea52d4..d30468c 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c @@ -1649,6 +1649,17 @@ static u8 brcmf_sdio_rxglom(struct brcmf_sdio *bus, u8 rxseq) sdio_claim_host(bus->sdiodev->func1); errcode = brcmf_sdio_hdparse(bus, pfirst->data, &rd_new, BRCMF_SDIO_FT_SUPER); + if (errcode) { + /* Superframe header is bad; rd_new fields are not + * valid here. Drop it like a bad subframe below. + */ + brcmf_sdio_rxfail(bus, true, false); + bus->sdcnt.rxglomfail++; + brcmf_sdio_free_glom(bus); + sdio_release_host(bus->sdiodev->func1); + bus->cur_read.len = 0; + return 0; + } sdio_release_host(bus->sdiodev->func1); bus->cur_read.len = rd_new.len_nxtfrm << 4;