Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH wireless v3] wifi: brcmfmac: zero-pad SDIO write buffer to 4-byte boundary
@ 2026-11-26 21:24 Tristan Madani
  0 siblings, 0 replies; only message 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] only message in thread

only message in thread, other threads:[~2026-11-26 21:24 UTC | newest]

Thread overview: (only message) (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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox