[PATCH] wifi: cfg80211: initialize BSS nodes after failed rehash

From: Jaeyeong Lee

Date: Thu Nov 26 2026 - 22:10:50 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 737cf77c5d765..dff53b9b8095c 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))

base-commit: 18d0bedbb5f0538396cb7f763ed9cd1dd69c5b23
--
2.43.0