Repository navigation
wifi: brcmfmac: skip a scanned BSS on a band or channel the wiphy doesn't have - #191
Conversation
fbe485d to
12a4a80
Compare
|
This is the small PR on checkpatch --strict (the quoted oops line, and the upstream commit ID this grafted tree doesn't have), W=1 arm64 clang build of cfg80211.o, kernel-pr-check: clean. Still to come: the 9a test note ( |
|
Thank you, @W4HO-ham, for turning this into its own small PR so quickly, and for the 6 GHz rework. I checked the crash path: with a NULL channel, cfg80211 reads My 7 Pro has the same latent bug: its BCM4389 logs "Ignoring unexpected firmware channel 169/173/177" at every boot, so an access point on those channels would crash it too. The fix is right for both phones. The 6 GHz skip also changes what my 7 Pro shows, though. Until now a 6 GHz BSS whose channel number also exists on 2.4 or 5 GHz (1, 5, 9, 149 and so on) was reported on the wrong band, and now it drops out of the scan list. That's correct, but my run on the 1st covered only the NULL check, so I'll run this version on the 7 Pro (join, scans compared with the base kernel) before I merge. From you, before it lands: the 9a note you mentioned, with Small things, none blocking:
|
…sn't have
brcmf_inform_single_bss() picks the band from the channel number alone,
turns it into a frequency and hands cfg80211 the result of
ieee80211_get_channel() unchecked. For a channel the wiphy doesn't
carry that lookup returns NULL, and cfg80211 dereferences it.
The firmware does report such BSSes. A 6 GHz chanspec's channel number
is read as a 2.4 or 5 GHz one (6 GHz channel 37 becomes 5185 MHz,
which no band has), and since brcmf_construct_chaninfo() skips 6 GHz
chanspecs there is no 6 GHz band to find it in anyway. A 5 GHz channel
the band table doesn't have does the same: on a Pixel 9a (BCM4383)
every boot with Wi-Fi logs "brcmf_construct_chaninfo: Ignoring
unexpected firmware channel 177" (UNII-4). The boot that crashed had
just warned "Invalid chanspec 0x5001" (6 GHz, channel 1) from an older
brcmutil without the 6 GHz band; which BSS the scan was reporting when
it crashed wasn't logged. Once, from the escan timeout worker:
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
Workqueue: events brcmf_cfg80211_escan_timeout_worker [brcmfmac]
pc : cfg80211_inform_single_bss_data+0xb0/0x4fc [cfg80211]
Call trace:
cfg80211_inform_single_bss_data+0xb0/0x4fc [cfg80211] (P)
cfg80211_inform_bss_data+0xbc/0x12d4 [cfg80211]
brcmf_inform_single_bss+0x190/0x20c [brcmfmac]
brcmf_cfg80211_escan_timeout_worker+0x80/0xec [brcmfmac]
The worker died inside cfg80211's RCU read-side section, so the next
system suspend couldn't freeze khugepaged (stuck in lru_add_drain_all())
and the phone reset a few seconds later.
Decode the chanspec for every BSS and skip a 6 GHz one first, then keep
a NULL check on the channel as the backstop. A 6 GHz BSS whose channel
number also exists on 2.4 or 5 GHz (1, 5, 9, 149 and so on) was
reported until now on the wrong band; it now drops out of the scan list,
which is a visible change on any chip whose firmware reports 6 GHz. Both return 0 with a debug
message, so the rest of the scan list is still reported:
brcmf_inform_bss() stops at the first error.
Fixes: 5b435de0d786 ("net: wireless: add brcm80211 drivers")
Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
12a4a80 to
6d03f12
Compare
|
Done (6d03f12): |
|
The 9a note. Release |
|
Thank you, @W4HO-ham, for the quick follow-up and for the 9a note. I rebuilt That's everything I needed from you. What's left is on my side: the 7 Pro run One tiny thing, only if you push again for another reason: the new sentence |
|
@W4HO-ham thank you, this ran clean on my Pixel 7 Pro (BCM4389). The kernel was
Merging now. |
brcmf_inform_single_bss() hands cfg80211 the result of ieee80211_get_channel() without checking it. The BCM4383 on the palmtop reports channel 177 (5 GHz UNII-4), which brcmf_construct_chaninfo() drops from the band table at every boot ("Ignoring unexpected firmware channel 177"), so a nearby access point on it gives a NULL channel. Today, during a sleep series, the escan timeout worker oopsed on it in cfg80211_inform_single_bss_data(). The worker died inside cfg80211's RCU read-side section, the next suspend couldn't freeze khugepaged (stuck in lru_add_drain_all()), ACPM stopped answering and the palmtop reset. pstore kept the console, and the trace is in the commit message.
The fix skips such a BSS with a debug message and returns 0, so brcmf_inform_bss() still reports the rest of the list. Upstream wireless-next has the same unchecked lookup.
Checked: checkpatch --strict (one long line, the quoted oops), W=1 arm64 build of cfg80211.o with clang, tools/kernel-pr-check. Not yet run on the palmtop: the oops was rare (one boot of the last fifteen), so the test there is that scanning and connecting still work. I'll add that result here.