Skip to content

Commit

Permalink
cfg80211: scan: fix RCU in cfg80211_add_nontrans_list()
Browse files Browse the repository at this point in the history
commit a2083ee upstream.

The SSID pointer is pointing to RCU protected data, so we
need to have it under rcu_read_lock() for the entire use.
Fix this.

Cc: [email protected]
Fixes: 0b8fb82 ("cfg80211: Parsing of Multiple BSSID information in scanning")
Link: https://lore.kernel.org/r/20210930131120.6ddfc603aa1d.I2137344c4e2426525b1a8e4ce5fca82f8ecbfe7e@changeid
Signed-off-by: Johannes Berg <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
jmberg-intel authored and gregkh committed Nov 2, 2021
1 parent 590abe5 commit a37c5e7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions net/wireless/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,14 +379,17 @@ cfg80211_add_nontrans_list(struct cfg80211_bss *trans_bss,
}
ssid_len = ssid[1];
ssid = ssid + 2;
rcu_read_unlock();

/* check if nontrans_bss is in the list */
list_for_each_entry(bss, &trans_bss->nontrans_list, nontrans_list) {
if (is_bss(bss, nontrans_bss->bssid, ssid, ssid_len))
if (is_bss(bss, nontrans_bss->bssid, ssid, ssid_len)) {
rcu_read_unlock();
return 0;
}
}

rcu_read_unlock();

/* add to the list */
list_add_tail(&nontrans_bss->nontrans_list, &trans_bss->nontrans_list);
return 0;
Expand Down

0 comments on commit a37c5e7

Please sign in to comment.