wifi: mac80211: fix RCU list iterations

[ Upstream commit ac35180032fbc5d80b29af00ba4881815ceefcb6 ]

There are a number of places where RCU list iteration is
used, but that aren't (always) called with RCU held. Use
just list_for_each_entry() in most, and annotate iface
iteration with the required locks.

Reviewed-by: Miriam Rachel Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20240827094939.ed8ac0b2f897.I8443c9c3c0f8051841353491dae758021b53115e@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Johannes Berg 2024-08-27 09:49:40 +02:00 committed by Greg Kroah-Hartman
parent 6dcadb2ed3
commit f373196093
4 changed files with 8 additions and 4 deletions

View file

@ -245,7 +245,9 @@ ieee80211_get_max_required_bw(struct ieee80211_sub_if_data *sdata,
enum nl80211_chan_width max_bw = NL80211_CHAN_WIDTH_20_NOHT; enum nl80211_chan_width max_bw = NL80211_CHAN_WIDTH_20_NOHT;
struct sta_info *sta; struct sta_info *sta;
list_for_each_entry_rcu(sta, &sdata->local->sta_list, list) { lockdep_assert_wiphy(sdata->local->hw.wiphy);
list_for_each_entry(sta, &sdata->local->sta_list, list) {
if (sdata != sta->sdata && if (sdata != sta->sdata &&
!(sta->sdata->bss && sta->sdata->bss == sdata->bss)) !(sta->sdata->bss && sta->sdata->bss == sdata->bss))
continue; continue;

View file

@ -732,7 +732,7 @@ static bool ieee80211_add_vht_ie(struct ieee80211_sub_if_data *sdata,
bool disable_mu_mimo = false; bool disable_mu_mimo = false;
struct ieee80211_sub_if_data *other; struct ieee80211_sub_if_data *other;
list_for_each_entry_rcu(other, &local->interfaces, list) { list_for_each_entry(other, &local->interfaces, list) {
if (other->vif.bss_conf.mu_mimo_owner) { if (other->vif.bss_conf.mu_mimo_owner) {
disable_mu_mimo = true; disable_mu_mimo = true;
break; break;

View file

@ -489,7 +489,7 @@ static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
* the scan was in progress; if there was none this will * the scan was in progress; if there was none this will
* just be a no-op for the particular interface. * just be a no-op for the particular interface.
*/ */
list_for_each_entry_rcu(sdata, &local->interfaces, list) { list_for_each_entry(sdata, &local->interfaces, list) {
if (ieee80211_sdata_running(sdata)) if (ieee80211_sdata_running(sdata))
wiphy_work_queue(sdata->local->hw.wiphy, &sdata->work); wiphy_work_queue(sdata->local->hw.wiphy, &sdata->work);
} }

View file

@ -745,7 +745,9 @@ static void __iterate_interfaces(struct ieee80211_local *local,
struct ieee80211_sub_if_data *sdata; struct ieee80211_sub_if_data *sdata;
bool active_only = iter_flags & IEEE80211_IFACE_ITER_ACTIVE; bool active_only = iter_flags & IEEE80211_IFACE_ITER_ACTIVE;
list_for_each_entry_rcu(sdata, &local->interfaces, list) { list_for_each_entry_rcu(sdata, &local->interfaces, list,
lockdep_is_held(&local->iflist_mtx) ||
lockdep_is_held(&local->hw.wiphy->mtx)) {
switch (sdata->vif.type) { switch (sdata->vif.type) {
case NL80211_IFTYPE_MONITOR: case NL80211_IFTYPE_MONITOR:
if (!(sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE)) if (!(sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE))