* [PATCH wireless v3] wifi: brcmfmac: zero-pad SDIO write buffer to 4-byte boundary
@ 2026-11-26 21:24 Tristan Madani
2026-11-29 20:53 ` Arend van Spriel
0 siblings, 1 reply; 2+ messages in thread
From: Tristan Madani @ 2026-11-26 21:24 UTC (permalink / raw)
To: Arend van Spriel
Cc: Franky Lin, linux-wireless, brcm80211, brcm80211-dev-list.pdl,
stable, Tristan Madani
From: Tristan Madani <tristan@talencesecurity.com>
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
padding bytes beyond skb->data + skb->len are sent to the wireless
device uninitialized.
The SDPCM header carries the original (unpadded) frame length, so the
device discards the padding. The window is therefore limited to the
local SDIO bus.
Ensure sufficient tailroom exists for the alignment padding before
zeroing it. If the skb tailroom is too short, expand the head to
make room.
Fixes: 78b3f1c5be8f ("brcmfmac: replace brcmf_sdioh_request_buffer with brcmf_sdio_buffrw")
Cc: stable@vger.kernel.org
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
Changes in v3:
- Check skb_tailroom() before zeroing the padding; if the skb
tailroom is too short, call pskb_expand_head() to make room
(Arend van Spriel)
- Use the correct Fixes tag: the 4-byte rounding was introduced
by 78b3f1c5be8f, not by the later function split (Arend van Spriel)
- Add impact note: SDPCM header carries unpadded length, so device
discards the extra bytes and the window is local SDIO bus only
(Arend van Spriel)
Supersedes: f935e48bd9a6 ("wifi: brcmfmac: zero-pad SDIO write to
4-byte boundary")
Changes in v2:
- Original submission as part of [PATCH wireless 1/2] series
.../net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
index 71c2f99cdb711..e5068da9672cc 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
@@ -317,12 +317,23 @@ static int brcmf_sdiod_skbuff_write(struct brcmf_sdio_dev *sdiodev,
struct sk_buff *skb)
{
unsigned int req_sz;
+ unsigned int pad;
int err;
/* Single skb use the standard mmc interface */
req_sz = skb->len + 3;
req_sz &= (uint)~3;
+ pad = req_sz - skb->len;
+ if (pad > 0) {
+ if (skb_tailroom(skb) < pad) {
+ err = pskb_expand_head(skb, 0, pad, GFP_ATOMIC);
+ if (err)
+ return err;
+ }
+ memset(skb->data + skb->len, 0, pad);
+ }
+
err = sdio_memcpy_toio(func, addr, ((u8 *)(skb->data)), req_sz);
if (err == -ENOMEDIUM)
--
2.47.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH wireless v3] wifi: brcmfmac: zero-pad SDIO write buffer to 4-byte boundary
2026-11-26 21:24 [PATCH wireless v3] wifi: brcmfmac: zero-pad SDIO write buffer to 4-byte boundary Tristan Madani
@ 2026-11-29 20:53 ` Arend van Spriel
0 siblings, 0 replies; 2+ messages in thread
From: Arend van Spriel @ 2026-11-29 20:53 UTC (permalink / raw)
To: Tristan Madani
Cc: Arend van Spriel, Franky Lin, linux-wireless, brcm80211,
brcm80211-dev-list.pdl, stable, Tristan Madani
On Thu, 26 Nov 2026 21:24:16 +0000, Tristan Madani <tristmd@gmail.com> 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
> padding bytes beyond skb->data + skb->len are sent to the wireless
> device uninitialized.
[...]
> Fixes: 78b3f1c5be8f ("brcmfmac: replace brcmf_sdioh_request_buffer with brcmf_sdio_buffrw")
> Cc: stable@vger.kernel.org
> Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
> ---
[...]
> .../net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
The original patch was already applied to wireless/main as
f935e48bd9a6 ("wifi: brcmfmac: zero-pad SDIO write to 4-byte boundary").
That actually was my mistake. I acked it, but left it in my todo list.
So I had a second look at it. As a consequence this patch no longer
applies. Please send a new incremental fix on top of current wireless/main
and use f935e48bd9a6 in the Fixes tag.
The version history is also off: the original unversioned posting was v1
and I could not find a v2. Since this is now a fix for f935e48bd9a6,
I suggest sending it as a new unversioned patch with a subject such as
"wifi: brcmfmac: ensure tailroom before zero-padding SDIO writes".
[...]
> @@ -317,12 +317,23 @@ static int brcmf_sdiod_skbuff_write(struct brcmf_sdio_dev *sdiodev,
> struct sk_buff *skb)
> {
> unsigned int req_sz;
> + unsigned int pad;
> int err;
>
> /* Single skb use the standard mmc interface */
> req_sz = skb->len + 3;
> req_sz &= (uint)~3;
>
> + pad = req_sz - skb->len;
> + if (pad > 0) {
> + if (skb_tailroom(skb) < pad) {
> + err = pskb_expand_head(skb, 0, pad, GFP_ATOMIC);
> + if (err)
> + return err;
> + }
> + memset(skb->data + skb->len, 0, pad);
> + }
> +
> err = sdio_memcpy_toio(func, addr, ((u8 *)(skb->data)), req_sz);
The tailroom handling itself looks correct, but GFP_ATOMIC is not needed
here. This function is always called in thread context, so please use
GFP_KERNEL.
Has this patch with pskb_expand_head() in place been tested or do you not
have a device for testing with this driver.
Regards,
Arend
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-29 20:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 21:24 [PATCH wireless v3] wifi: brcmfmac: zero-pad SDIO write buffer to 4-byte boundary Tristan Madani
2026-11-29 20:53 ` Arend van Spriel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.