]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: mac80211: fix RCU list iterations
authorJohannes Berg <johannes.berg@intel.com>
Tue, 27 Aug 2024 07:49:40 +0000 (09:49 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 28 Aug 2024 10:39:29 +0000 (12:39 +0200)
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>
net/mac80211/chan.c
net/mac80211/mlme.c
net/mac80211/scan.c
net/mac80211/util.c

index e8567723e94d5eee887212695c8b07262d00e7ab..b72e4036526bfaa3ea97d8f39fbfe542c9f04e64 100644 (file)
@@ -286,7 +286,9 @@ ieee80211_get_max_required_bw(struct ieee80211_link_data *link)
        enum nl80211_chan_width max_bw = NL80211_CHAN_WIDTH_20_NOHT;
        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 &&
                    !(sta->sdata->bss && sta->sdata->bss == sdata->bss))
                        continue;
index 0285924269cf8f02286f2cc964943b65de5bbce2..acd4fe7039904b32d406e5a59d8ade43f71d6a34 100644 (file)
@@ -1231,7 +1231,7 @@ static bool ieee80211_add_vht_ie(struct ieee80211_sub_if_data *sdata,
                bool disable_mu_mimo = false;
                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) {
                                disable_mu_mimo = true;
                                break;
index 1c5d99975ad04df28770225c9cbcfe0371828ed8..3b2bde6360bcb6a0d4e2e7db759de1d81748c4c8 100644 (file)
@@ -504,7 +504,7 @@ static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
         * the scan was in progress; if there was none this will
         * 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))
                        wiphy_work_queue(sdata->local->hw.wiphy, &sdata->work);
        }
index 830f736f9c132a274f50e1173f327fa91538bf34..ba61de90ba3512170ca09c8c0a1df3ad16213d6e 100644 (file)
@@ -751,7 +751,9 @@ static void __iterate_interfaces(struct ieee80211_local *local,
        struct ieee80211_sub_if_data *sdata;
        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) {
                case NL80211_IFTYPE_MONITOR:
                        if (!(sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE))