Linux wireless drivers development
 help / color / mirror / Atom feed
From: Tristan Madani <tristmd@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, stable@vger.kernel.org,
	Tristan Madani <tristan@talencesecurity.com>
Subject: [PATCH wireless] wifi: brcmfmac: ensure tailroom before zero-padding SDIO writes
Date: Wed,  2 Dec 2026 14:44:22 +0000	[thread overview]
Message-ID: <20261202144422.4187803-1-tristmd@gmail.com> (raw)

From: Tristan Madani <tristan@talencesecurity.com>

brcmf_sdiod_skbuff_write() zero-fills up to 3 bytes past skb->len
before passing the aligned size to sdio_memcpy_toio().  When the skb
has less tailroom than the padding needed, the memset writes past
the allocated buffer.

Check skb_tailroom() and call pskb_expand_head() to extend the skb
when necessary.  This is always called from thread context so
GFP_KERNEL is appropriate.

Fixes: f935e48bd9a60 ("wifi: brcmfmac: zero-pad SDIO write to 4-byte boundary")
Cc: stable@vger.kernel.org
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
Compile-tested only; no SDIO hardware available for runtime testing.
The tailroom expansion pattern matches brcmf_sdio_txpkt_prep_sg()
in the same driver's SDIO TX path.

 .../wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c    | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
index c6dd4148a44ce..315e64ee206f1 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
@@ -323,8 +323,16 @@ 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);
+	if (req_sz > skb->len) {
+		unsigned int pad = req_sz - skb->len;
+
+		if (skb_tailroom(skb) < pad) {
+			err = pskb_expand_head(skb, 0, pad, GFP_KERNEL);
+			if (err)
+				return err;
+		}
+		memset(skb->data + skb->len, 0, pad);
+	}
 
 	err = sdio_memcpy_toio(func, addr, ((u8 *)(skb->data)), req_sz);
 
-- 
2.47.3


                 reply	other threads:[~2026-12-02 14:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261202144422.4187803-1-tristmd@gmail.com \
    --to=tristmd@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 \
    --cc=stable@vger.kernel.org \
    --cc=tristan@talencesecurity.com \
    /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