The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH wireless] wifi: brcmfmac: fix join parameter length in IBSS join
@ 2026-11-21  9:27 Chad Aldreda
  0 siblings, 0 replies; only message in thread
From: Chad Aldreda @ 2026-11-21  9:27 UTC (permalink / raw)
  To: Arend van Spriel
  Cc: Johannes Berg, linux-wireless, brcm80211, brcm80211-dev-list.pdl,
	linux-kernel, stable

brcmf_cfg80211_join_ibss() builds the length of the SET_SSID payload in
steps. It starts with the SSID record (36 bytes), adds
BRCMF_ASSOC_PARAMS_FIXED_SIZE (14) when a BSSID is given, and adds
sizeof(join_params.params_le) (16) when the channel is fixed. With both a
BSSID and a fixed channel the result is 66, but struct brcmf_join_params
is 52 bytes (sizes as on x86-64, where __le32 is 4-byte aligned). The
length is passed unchanged to the protocol layer, which copies that many
bytes from the on-stack record (brcmf_proto_bcdc_msg(),
brcmf_msgbuf_tx_ioctl()), so 14 bytes of kernel stack beyond it are sent
to the firmware.

When the channel is fixed the whole record is in use whether or not a
BSSID was given, so set the length to sizeof(join_params) in that branch.
The other three cases (36, 50 and 52 bytes) are unchanged.

The double count dates from the commit that added this calculation: the
BSSID case counted WL_ASSOC_PARAMS_FIXED_SIZE, and the existing
wl_ch_to_chanspec(), which that commit called after the BSSID case,
added WL_ASSOC_PARAMS_FIXED_SIZE plus one chanspec again.

Fixes: 69274f020a92 ("staging: brcm80211: Fixed ibss join/leave functionality in brcmfmac driver")
Cc: stable@vger.kernel.org
Signed-off-by: Chad Aldreda <ca@modelmiser.com>
---
Not run on hardware, and no reproducer was run. Reaching the line
needs a brcmfmac device in IBSS mode and a join with both a BSSID and
a fixed frequency:
  iw dev wlan0 ibss join <ssid> <freq> fixed-freq <bssid>
The four lengths (36, 50, 52, 66) were checked at compile time against
the driver's headers on x86-64, and cfg80211.o builds with W=1.

Not checked: that firmware accepts 52 bytes in this case. It is the
length the driver already sends for a fixed channel without a BSSID,
from the SET_SSID fallback in brcmf_cfg80211_connect() when a channel
is known, and from the AP start and stop paths.

Also not checked: on msgbuf the same length bounds the copy of the
firmware's response back into the record (brcmf_msgbuf_query_dcmd()),
so a response longer than 52 bytes would be written up to 14 bytes
past it. Whether firmware returns data for SET_SSID is not known here.

The BSSID-only length (50) is left alone to keep this a pure fix.

Based on wireless/main dcf495789037. It also applies unchanged to
wireless-next/main e1dd8486807c, where the length goes through
brcmf_set_ssid() (39cae1c203a3) and is still passed on as is when the
firmware does not use versioned join requests.

Tools: the over-length was flagged by an AI model (Grok 4.7) asked to
check notes on the driver's firmware interface against the source,
and confirmed by an AI assistant (Claude Fable 5.2) reading the code.
The patch, this description, the size check and the build were done
by that assistant.

 drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 46714d871260..9e5955a98051 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -1901,7 +1901,7 @@ brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *ndev,
 			join_params.params_le.chanspec_list[0] =
 				cpu_to_le16(chanspec);
 			join_params.params_le.chanspec_num = cpu_to_le32(1);
-			join_params_size += sizeof(join_params.params_le);
+			join_params_size = sizeof(join_params);
 		}
 
 		/* set channel for starter */

base-commit: dcf495789037ab78d8ddf5844239cf85d92ac5f1
-- 
2.43.0



^ permalink raw reply related	[flat|nested] only message in thread

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

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-21  9:27 [PATCH wireless] wifi: brcmfmac: fix join parameter length in IBSS join Chad Aldreda

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