Re: [PATCH wireless 1/2] wifi: brcmfmac: zero-pad SDIO write to 4-byte boundary
From: Arend van Spriel
Date: Thu Nov 26 2026 - 07:52:55 EST
On Mon, 2 Nov 2026 12:23:10 +0000, Tristan Madani <tristmd@xxxxxxxxx> wrote:
> brcmf_sdiod_skbuff_write() rounds skb->len up to the next 4-byte
> boundary and passes the larger size to sdio_memcpy_toio(). The 1-3
> extra bytes come from heap memory past skb->data, leaking stale kernel
> data to the wireless device.
>
> Zero-fill the padding before the SDIO write.
>
> Fixes: 8f13c87ccc49 ("brcmfmac: Split brcmf_sdiod_buffrw function up.")
[...]
> ---
> drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 3 +++
> 1 file changed, 3 insertions(+)
[...]
> @@ -323,6 +323,9 @@ static int brcmf_sdiod_skbuff_write(struct brcmf_sdio_dev *sdiodev,
> req_sz = skb->len + 3;
> req_sz &= (uint)~3;
>
> + if (req_sz > skb->len)
> + memset(skb->data + skb->len, 0, req_sz - skb->len);
> +
> err = sdio_memcpy_toio(func, addr, ((u8 *)(skb->data)), req_sz);
>
> if (err == -ENOMEDIUM)
The padding lies beyond skb->len, so this memset is only safe when
skb_tailroom(skb) >= req_sz - skb->len, and nothing guarantees that for
the skbs reaching this function (e.g. a data skb in the non-glom path).
If the tailroom is short the memset overwrites skb_shared_info. Please
check the tailroom (brcmf_sdio_txpkt_prep_sg() does so before it adds
tail padding) and handle the short case, e.g. by expanding the tail.
Also, the 4-byte rounding of the length predates the commit in the
Fixes tag, which only split the function up. Please point the tag at
the commit that introduced the rounding. The SDPCM header carries the
unpadded frame length so the device should ignore the padding bytes; a
word on the actual impact and how this was tested would be good.
Regards,
Arend