wifi: cfg80211: avoid nontransmitted BSS list corruption
authorJohannes Berg <johannes.berg@intel.com>
Fri, 30 Sep 2022 22:01:44 +0000 (00:01 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 10 Oct 2022 07:51:01 +0000 (09:51 +0200)
If a non-transmitted BSS shares enough information (both
SSID and BSSID!) with another non-transmitted BSS of a
different AP, then we can find and update it, and then
try to add it to the non-transmitted BSS list. We do a
search for it on the transmitted BSS, but if it's not
there (but belongs to another transmitted BSS), the list
gets corrupted.

Since this is an erroneous situation, simply fail the
list insertion in this case and free the non-transmitted
BSS.

This fixes CVE-2022-42721.

Reported-by: Sönke Huster <shuster@seemoo.tu-darmstadt.de>
Tested-by: Sönke Huster <shuster@seemoo.tu-darmstadt.de>
Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/scan.c

index 249107212c099ff9d071e89399e0cdf60bceca54..703b05c6c43e7bdc51602681b8d73a753a3c4461 100644 (file)
@@ -423,6 +423,15 @@ cfg80211_add_nontrans_list(struct cfg80211_bss *trans_bss,
 
        rcu_read_unlock();
 
+       /*
+        * This is a bit weird - it's not on the list, but already on another
+        * one! The only way that could happen is if there's some BSSID/SSID
+        * shared by multiple APs in their multi-BSSID profiles, potentially
+        * with hidden SSID mixed in ... ignore it.
+        */
+       if (!list_empty(&nontrans_bss->nontrans_list))
+               return -EINVAL;
+
        /* add to the list */
        list_add_tail(&nontrans_bss->nontrans_list, &trans_bss->nontrans_list);
        return 0;