Repository navigation
Conversation
On kernels >= 3.19, rtw_cfg80211_allow_ch_switch_notify() allows a channel switch notification for every interface type. For a station, the only caller is the join path, rtw_chk_start_clnt_join(), which reports the channel of the BSS that it joins. During a roam, cfg80211 still holds the old AP as current_bss when the join path runs. cfg80211_ch_switch_notify() then calls cfg80211_update_assoc_bss_entry(), which moves that old entry to the new channel and rehashes it into the BSS rbtree, although the driver has already removed it with rtw_cfg80211_unlink_bss(). The entry is freed while it is still in the tree, and the next BSS expiry crashes on slab poison: Unable to handle kernel paging request at virtual address 006b6b6b6b6b6b7b Comm: iw pc : rb_erase+0x24/0x3a4 lr : __cfg80211_unlink_bss+0x7c/0x174 [cfg80211] Call trace: rb_erase+0x24/0x3a4 (P) __cfg80211_bss_expire+0x5c/0xc0 [cfg80211] cfg80211_bss_expire+0x20/0x38 [cfg80211] nl80211_dump_scan+0x19c/0x1e0 [cfg80211] The join path also runs from the command thread without the wiphy lock that cfg80211_ch_switch_notify() requires. The driver implements .connect, not .auth/.assoc, so cfg80211 takes the channel of a newly joined BSS from the connect or roam result. The comment at the call site about MLME frames sent by the supplicant does not apply. Return 0 for every interface that is not AP, ad-hoc or mesh on all kernels, as the function already did before 3.19. Tested on a NEXBOX A95X (Amlogic S905, RTL8189ES on SDIO) with Linux 6.18.32 arm64. Before the change, the box crashed four times in one day, each time after a roam. With the change, 20 rounds of a forced roam between two APs, each followed by a scan, "iw dev wlan0 link" and "iw dev wlan0 scan dump", gave 24 AP changes without a warning or a crash, and kprobes counted no call of cfg80211_ch_switch_notify().
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On kernels >= 3.19,
rtw_cfg80211_allow_ch_switch_notify()lets the station join path (rtw_chk_start_clnt_join()) callcfg80211_ch_switch_notify(). During a roam, cfg80211 still holds the old AP ascurrent_bss, socfg80211_update_assoc_bss_entry()rehashes that old entry into the BSS rbtree after the driver has already removed it withrtw_cfg80211_unlink_bss(). The entry is freed while still in the tree, and the next BSS expiry crashes:The call also runs from the command thread without the wiphy lock that
cfg80211_ch_switch_notify()requires.Change
rtw_cfg80211_allow_ch_switch_notify()returns 0 for every interface that is not AP, ad-hoc or mesh on all kernels, as it already did before 3.19. The driver implements.connect, not.auth/.assoc, so cfg80211 takes the channel of a newly joined BSS from the connect or roam result. The other two callers (rtw_join_done_chk_ch()andstart_bss_network()) notify AP-side interfaces and are unchanged.Testing
NEXBOX A95X (Amlogic S905, RTL8189ES on SDIO), Linux 6.18.32 arm64,
slub_debug=FZP:cfg80211_update_assoc_bss_entry()andcfg80211_rehash_bss()running on the unlinked entry of the previous AP.Roam), each followed by a scan,iw dev wlan0 linkandiw dev wlan0 scan dump. Result: 24 AP changes, no warning, no crash, and no call ofcfg80211_ch_switch_notify(),cfg80211_update_assoc_bss_entry()orcfg80211_rehash_bss().The test build was commit 36d917d plus this change. The commits on master since then add support for newer kernels and fix compiler warnings; none of them changes behavior on 6.18.