[PATCH] wifi: cfg80211: initialize BSS nodes after failed rehash
From: Jaeyeong Lee
Date: Wed Nov 18 2026 - 09:01:02 EST
cfg80211_rehash_bss() removes the BSS from the rbtree before trying to
insert it under its new key. If insertion fails because another BSS has
the same key, the function removes the BSS from bss_list with
list_del().
The list node is then poisoned rather than initialized. As a result,
cfg80211_unlink_bss() does not recognize the BSS as already unpublished
and calls __cfg80211_unlink_bss(), which deletes the poisoned list node
and the already removed rbtree node again. This can corrupt both
containers and crash the kernel.
Clear the rbtree node immediately after erasing it, and use
list_del_init() on the failure path, so later unlink attempts recognize
that the BSS is no longer published.
Fixes: 7f12e26a194d ("wifi: cfg80211: make hash table duplicates more survivable")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Jaeyeong Lee <lee@xxxxxxxxxxx>
---
net/wireless/scan.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index 1c50a16c0e9be..c285c60f5b6d8 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -1785,8 +1785,9 @@ static void cfg80211_rehash_bss(struct cfg80211_registered_device *rdev,
lockdep_assert_held(&rdev->bss_lock);
rb_erase(&bss->rbn, &rdev->bss_tree);
+ RB_CLEAR_NODE(&bss->rbn);
if (!rb_insert_bss(rdev, bss)) {
- list_del(&bss->list);
+ list_del_init(&bss->list);
if (!list_empty(&bss->hidden_list))
list_del_init(&bss->hidden_list);
if (!list_empty(&bss->pub.nontrans_list))
--
2.43.0