[PATCH wireless] wifi: cfg80211: unlink hidden SSID members of the merged BSS on CSA
From: Kyuwon Cho
Date: Sun Nov 22 2026 - 17:11:30 EST
When the associated BSS moves to a new channel,
cfg80211_update_assoc_bss_entry() gives the IEs of a matching entry on
that channel (new) to the associated BSS and unlinks new. If new is the
beacon entry of a hidden SSID group, __cfg80211_unlink_bss() refuses
while the group has probe response entries, so the WARN_ON() fires and
new stays on the list. The probe response entries keep sharing the
beacon IEs that now belong to the associated BSS, and read them after
that BSS is freed:
BUG: KASAN: slab-use-after-free in nl80211_send_bss.constprop.0 (net/wireless/nl80211.c:12959)
Read of size 1 at addr ff1100001428e61c by task test/115
Call Trace:
nl80211_send_bss.constprop.0 (net/wireless/nl80211.c:12959)
nl80211_dump_scan (net/wireless/nl80211.c:13105)
genl_dumpit (net/netlink/genetlink.c:1026)
netlink_dump (net/netlink/af_netlink.c:2360)
Unlink the probe response entries of new before new itself, and clear
their beacon IEs, which they no longer share with any entry.
Fixes: 0afd425b1b64 ("cfg80211: fix duplicated scan entries after channel switch")
Signed-off-by: Kyuwon Cho <kyuwoncho18@xxxxxxxxx>
---
The patch was written with LLM assistance; we reviewed and tested it.
It applies to the wireless tree. With it, the reproducer runs without
the WARN and the use-after-free, and the station still follows the
channel switch.
net/wireless/scan.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index 1c50a16c0e9b..898cc65d6b1a 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -3490,7 +3490,7 @@ void cfg80211_update_assoc_bss_entry(struct wireless_dev *wdev,
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
struct cfg80211_internal_bss *cbss = wdev->links[link_id].client.current_bss;
struct cfg80211_internal_bss *new = NULL;
- struct cfg80211_internal_bss *bss;
+ struct cfg80211_internal_bss *bss, *next;
struct cfg80211_bss *nontrans_bss;
struct cfg80211_bss *tmp;
@@ -3533,6 +3533,15 @@ void cfg80211_update_assoc_bss_entry(struct wireless_dev *wdev,
rdev->bss_generation++;
}
+ if (!new->pub.hidden_beacon_bss) {
+ list_for_each_entry_safe(bss, next, &new->hidden_list,
+ hidden_list) {
+ RCU_INIT_POINTER(bss->pub.beacon_ies, NULL);
+ if (__cfg80211_unlink_bss(rdev, bss))
+ rdev->bss_generation++;
+ }
+ }
+
WARN_ON(atomic_read(&new->hold));
if (!WARN_ON(!__cfg80211_unlink_bss(rdev, new)))
rdev->bss_generation++;
--
2.43.0