Merge wireless into wireless-next
authorJohannes Berg <johannes.berg@intel.com>
Thu, 5 Oct 2023 20:57:34 +0000 (22:57 +0200)
committerKalle Valo <kvalo@kernel.org>
Fri, 6 Oct 2023 14:08:47 +0000 (17:08 +0300)
Resolve several conflicts, mostly between changes/fixes in
wireless and the locking rework in wireless-next. One of
the conflicts actually shows a bug in wireless that we'll
want to fix separately.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
17 files changed:
1  2 
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h
drivers/net/wireless/intel/iwlwifi/mvm/fw.c
drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c
drivers/net/wireless/intel/iwlwifi/mvm/tx.c
include/net/cfg80211.h
net/mac80211/cfg.c
net/mac80211/ibss.c
net/mac80211/ieee80211_i.h
net/mac80211/key.c
net/mac80211/mesh.c
net/mac80211/mlme.c
net/mac80211/tx.c
net/wireless/core.c
net/wireless/core.h
net/wireless/mlme.c
net/wireless/nl80211.c
net/wireless/scan.c

Simple merge
index 5bc6b13294654d0de42311de1a6a0b75937e93f3,0e3a1753a51c6dcc904b004ec15aa2f9f2e1a413..5cec0c251e86ac0ba3f6c3737ccc70083e459824
@@@ -470,9 -472,8 +470,10 @@@ static int ieee80211_add_key(struct wip
        struct ieee80211_local *local = sdata->local;
        struct sta_info *sta = NULL;
        struct ieee80211_key *key;
+       int err;
  
 +      lockdep_assert_wiphy(local->hw.wiphy);
 +
        if (!ieee80211_sdata_running(sdata))
                return -ENETDOWN;
  
                break;
        }
  
-       return ieee80211_key_link(key, link, sta);
+       err = ieee80211_key_link(key, link, sta);
+       /* KRACK protection, shouldn't happen but just silently accept key */
+       if (err == -EALREADY)
+               err = 0;
 - out_unlock:
 -      mutex_unlock(&local->sta_mtx);
 -
+       return err;
  }
  
  static struct ieee80211_key *
Simple merge
Simple merge
index ac410f6632b541d71f9536801c5bcef6fe317cf6,0665ff5e456eb43605393ef193c9342760c71381..e0ff3a753e15d1dc3d39d69f29739a70c78f4036
@@@ -902,8 -911,8 +909,8 @@@ int ieee80211_key_link(struct ieee80211
         * new version of the key to avoid nonce reuse or replay issues.
         */
        if (ieee80211_key_identical(sdata, old_key, key)) {
-               ieee80211_key_free_unused(key);
-               return 0;
+               ret = -EALREADY;
 -              goto unlock;
++              goto out;
        }
  
        key->local = sdata->local;
                ieee80211_key_free(key, delay_tailroom);
        }
  
 - unlock:
 -      mutex_unlock(&sdata->local->key_mtx);
 -
+       key = NULL;
+  out:
+       ieee80211_key_free_unused(key);
        return ret;
  }
  
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 87b21c0c0f2551832bfd4a893be3329a5221bb50,931a03f4549c9fc1e85e20870742c935baca83a2..2650543dcebeea3b6182975a70f2cbbeb581100b
@@@ -6150,8 -6191,12 +6165,12 @@@ static int nl80211_start_ap(struct sk_b
  
        err = nl80211_calculate_ap_params(params);
        if (err)
 -              goto out_unlock;
 +              goto out;
  
 -              goto out_unlock;
+       err = nl80211_validate_ap_phy_operation(params);
+       if (err)
++              goto out;
        if (info->attrs[NL80211_ATTR_AP_SETTINGS_FLAGS])
                params->flags = nla_get_u32(
                        info->attrs[NL80211_ATTR_AP_SETTINGS_FLAGS]);
@@@ -12827,10 -12884,11 +12847,11 @@@ static int nl80211_set_cqm_rssi(struct 
                                u32 hysteresis)
  {
        struct cfg80211_registered_device *rdev = info->user_ptr[0];
+       struct cfg80211_cqm_config *cqm_config = NULL, *old;
        struct net_device *dev = info->user_ptr[1];
        struct wireless_dev *wdev = dev->ieee80211_ptr;
 -      int i, err;
        s32 prev = S32_MIN;
-       int i;
++      int i, err;
  
        /* Check all values negative and sorted */
        for (i = 0; i < n_thresholds; i++) {
        if (n_thresholds == 1 && thresholds[0] == 0) /* Disabling */
                n_thresholds = 0;
  
-       if (n_thresholds) {
-               struct cfg80211_cqm_config *cqm_config;
 -      wdev_lock(wdev);
 -      old = rcu_dereference_protected(wdev->cqm_config,
 -                                      lockdep_is_held(&wdev->mtx));
++      old = wiphy_dereference(wdev->wiphy, wdev->cqm_config);
  
+       if (n_thresholds) {
                cqm_config = kzalloc(struct_size(cqm_config, rssi_thresholds,
                                                 n_thresholds),
                                     GFP_KERNEL);
                       flex_array_size(cqm_config, rssi_thresholds,
                                       n_thresholds));
  
-               wdev->cqm_config = cqm_config;
+               rcu_assign_pointer(wdev->cqm_config, cqm_config);
+       } else {
+               RCU_INIT_POINTER(wdev->cqm_config, NULL);
+       }
+       err = cfg80211_cqm_rssi_update(rdev, dev, cqm_config);
+       if (err) {
+               rcu_assign_pointer(wdev->cqm_config, old);
+               kfree_rcu(cqm_config, rcu_head);
+       } else {
+               kfree_rcu(old, rcu_head);
        }
 -unlock:
 -      wdev_unlock(wdev);
  
-       return cfg80211_cqm_rssi_update(rdev, dev);
+       return err;
  }
  
  static int nl80211_set_cqm(struct sk_buff *skb, struct genl_info *info)
@@@ -18959,18 -19107,41 +18987,39 @@@ void cfg80211_cqm_rssi_notify(struct ne
                    rssi_event != NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH))
                return;
  
-       if (wdev->cqm_config) {
-               wdev->cqm_config->last_rssi_event_value = rssi_level;
+       rcu_read_lock();
+       cqm_config = rcu_dereference(wdev->cqm_config);
+       if (cqm_config) {
+               cqm_config->last_rssi_event_value = rssi_level;
+               cqm_config->last_rssi_event_type = rssi_event;
+               wiphy_work_queue(wdev->wiphy, &wdev->cqm_rssi_work);
+       }
+       rcu_read_unlock();
+ }
+ EXPORT_SYMBOL(cfg80211_cqm_rssi_notify);
  
-               cfg80211_cqm_rssi_update(rdev, dev);
+ void cfg80211_cqm_rssi_notify_work(struct wiphy *wiphy, struct wiphy_work *work)
+ {
+       struct wireless_dev *wdev = container_of(work, struct wireless_dev,
+                                                cqm_rssi_work);
+       struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
+       enum nl80211_cqm_rssi_threshold_event rssi_event;
+       struct cfg80211_cqm_config *cqm_config;
+       struct sk_buff *msg;
+       s32 rssi_level;
  
-               if (rssi_level == 0)
-                       rssi_level = wdev->cqm_config->last_rssi_event_value;
-       }
 -      wdev_lock(wdev);
 -      cqm_config = rcu_dereference_protected(wdev->cqm_config,
 -                                             lockdep_is_held(&wdev->mtx));
++      cqm_config = wiphy_dereference(wdev->wiphy, wdev->cqm_config);
+       if (!wdev->cqm_config)
 -              goto unlock;
++              return;
+       cfg80211_cqm_rssi_update(rdev, wdev->netdev, cqm_config);
+       rssi_level = cqm_config->last_rssi_event_value;
+       rssi_event = cqm_config->last_rssi_event_type;
  
-       msg = cfg80211_prepare_cqm(dev, NULL, gfp);
+       msg = cfg80211_prepare_cqm(wdev->netdev, NULL, GFP_KERNEL);
        if (!msg)
 -              goto unlock;
 +              return;
  
        if (nla_put_u32(msg, NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT,
                        rssi_event))
                                      rssi_level))
                goto nla_put_failure;
  
-       cfg80211_send_cqm(msg, gfp);
+       cfg80211_send_cqm(msg, GFP_KERNEL);
  
 -      goto unlock;
 +      return;
  
   nla_put_failure:
        nlmsg_free(msg);
 - unlock:
 -      wdev_unlock(wdev);
  }
- EXPORT_SYMBOL(cfg80211_cqm_rssi_notify);
  
  void cfg80211_cqm_txe_notify(struct net_device *dev,
                             const u8 *peer, u32 num_packets,
Simple merge