Re: [PATCH] wifi: cfg80211: fix BSS RB tree collision during channel switch
Johannes Berg <[email protected]>
| Newsgroups | dev.linux.lists.syzbot |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 2026-08-05 at 20:35 +0000, syzbot wrote: > From: Slawomir Stepien <[email protected]> > > When a station processes a Channel Switch Announcement (CSA), > cfg80211_update_assoc_bss_entry() is called to update the channel of the > associated BSS. Because the channel is part of the BSS Red-Black (RB) tree > key, changing the channel requires removing the BSS from the tree and > re-inserting it. > > Before re-inserting, cfg80211_update_assoc_bss_entry() searches for any > existing BSS on the new channel that matches the associated BSS so it can > be unlinked to prevent an RB tree collision. However, the search loop > incorrectly uses cfg80211_bss_type_match() to filter candidates based on > their capabilities. If an existing BSS matches perfectly in cmp_bss() (same > channel, BSSID, and SSID) but has different capabilities (e.g., due to a > malicious or misconfigured beacon setting both ESS and IBSS bits), > cfg80211_bss_type_match() skips it. > > This leaves the colliding BSS in the tree. When cfg80211_rehash_bss() > attempts to re-insert the associated BSS, rb_insert_bss() compares them > using cmp_bss(), which ignores capabilities. It finds them identical, > resulting in an RB tree collision and triggering a warning: > > WARNING: net/wireless/scan.c:1675 at rb_insert_bss net/wireless/scan.c:1675 > [inline] > WARNING: net/wireless/scan.c:1675 at cfg80211_rehash_bss+0x1e6/0x540 > net/wireless/scan.c:1732 > Call Trace: > <TASK> > cfg80211_update_assoc_bss_entry+0x3cd/0x660 net/wireless/scan.c:3478 > cfg80211_ch_switch_notify+0x3b1/0x780 net/wireless/nl80211.c:22366 > ieee80211_sta_process_chanswitch+0xbd1/0x29e0 net/mac80211/mlme.c:-1 > ieee80211_rx_mgmt_beacon+0x1dc6/0x32a0 net/mac80211/mlme.c:8309 > ieee80211_sta_rx_queued_frame+0x6ac/0x4e40 net/mac80211/mlme.c:11793 > ieee80211_iface_process_skb net/mac80211/iface.c:1766 [inline] > ieee80211_iface_work+0x552/0x1010 net/mac80211/iface.c:1823 > cfg80211_wiphy_work+0x29e/0x420 net/wireless/core.c:538 > </TASK> > > Fix this by removing the cfg80211_bss_type_match() check from the collision > search loop. The RB tree uniqueness is defined solely by cmp_bss(), so any > BSS that evaluates to cmp == 0 must be unlinked to prevent a collision, > regardless of whether its capability matches the connection type. If the > AP's capabilities legitimately changed, cfg80211_update_known_bss() will > safely update the capability later. I think you should be able to explain the change yourself. If you can't, don't send it. This wall of text isn't helping. :-/ johannes