blob: dd3e934c00b2d8cba20f01b33bc0ee940cb1fb26 [file] [log] [blame]
developer33907d42022-09-19 14:33:58 +08001From 552ba102a6898630a7d16887f29e606d6fabe508 Mon Sep 17 00:00:00 2001
2From: Siddh Raman Pant <code@siddh.me>
3Date: Sun, 14 Aug 2022 20:45:12 +0530
4Subject: [PATCH] wifi: mac80211: Don't finalize CSA in IBSS mode if state is
5 disconnected
6
7commit 15bc8966b6d3a5b9bfe4c9facfa02f2b69b1e5f0 upstream.
8
9When we are not connected to a channel, sending channel "switch"
10announcement doesn't make any sense.
11
12The BSS list is empty in that case. This causes the for loop in
13cfg80211_get_bss() to be bypassed, so the function returns NULL
14(check line 1424 of net/wireless/scan.c), causing the WARN_ON()
15in ieee80211_ibss_csa_beacon() to get triggered (check line 500
16of net/mac80211/ibss.c), which was consequently reported on the
17syzkaller dashboard.
18
19Thus, check if we have an existing connection before generating
20the CSA beacon in ieee80211_ibss_finish_csa().
21
22Cc: stable@vger.kernel.org
23Fixes: cd7760e62c2a ("mac80211: add support for CSA in IBSS mode")
24Link: https://syzkaller.appspot.com/bug?id=05603ef4ae8926761b678d2939a3b2ad28ab9ca6
25Reported-by: syzbot+b6c9fe29aefe68e4ad34@syzkaller.appspotmail.com
26Signed-off-by: Siddh Raman Pant <code@siddh.me>
27Tested-by: syzbot+b6c9fe29aefe68e4ad34@syzkaller.appspotmail.com
28Link: https://lore.kernel.org/r/20220814151512.9985-1-code@siddh.me
29Signed-off-by: Johannes Berg <johannes.berg@intel.com>
30Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
31---
32 net/mac80211/ibss.c | 4 ++++
33 1 file changed, 4 insertions(+)
34
35--- a/net/mac80211/ibss.c
36+++ b/net/mac80211/ibss.c
37@@ -534,6 +534,10 @@ int ieee80211_ibss_finish_csa(struct iee
38
39 sdata_assert_lock(sdata);
40
41+ /* When not connected/joined, sending CSA doesn't make sense. */
42+ if (ifibss->state != IEEE80211_IBSS_MLME_JOINED)
43+ return -ENOLINK;
44+
45 /* update cfg80211 bss information with the new channel */
46 if (!is_zero_ether_addr(ifibss->bssid)) {
47 cbss = cfg80211_get_bss(sdata->local->hw.wiphy,