mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kyuwon Cho <kyuwoncho18@gmail.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: Sergey Matyukevich <geomatsi@gmail.com>,
	linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH wireless] wifi: cfg80211: unlink hidden SSID members of the merged BSS on CSA
Date: Mon, 23 Nov 2026 07:11:19 +0900	[thread overview]
Message-ID: <179538424838.2896923.3237950934209281172@gmail.com> (raw)
In-Reply-To: <179538423867.2896802.12596731671226623616@gmail.com>

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@gmail.com>
---
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


      reply	other threads:[~2026-11-22 22:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22 22:11 [BUG] wifi: cfg80211: CSA onto a hidden SSID group warns in cfg80211_update_assoc_bss_entry() and leaves freed beacon IEs Kyuwon Cho
2026-11-22 22:11 ` Kyuwon Cho [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179538424838.2896923.3237950934209281172@gmail.com \
    --to=kyuwoncho18@gmail.com \
    --cc=geomatsi@gmail.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®