Skip to contentSkip to conversation

wifi: cfg80211: initialize BSS nodes after failed rehash

PATCH New Jaeyeong Lee 1 participant 1 message Nov 18

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: cfg80211: initialize BSS nodes after failed rehash

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")
---
 net/wireless/scan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/wireless/scan.c +2 -1
index 1c50a16c0e9be..c285c60f5b6d8 100644
@@ -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))
Signature · 1 line
2.43.0