]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: mac80211: add link id to ieee80211_gtk_rekey_add()
authorShaul Triebitz <shaul.triebitz@intel.com>
Wed, 28 Feb 2024 08:44:56 +0000 (09:44 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 4 Mar 2024 13:31:28 +0000 (14:31 +0100)
In MLO, we need the link id in the GTK key to be given by
the driver after rekeying in wowlan, so add that.

Signed-off-by: Shaul Triebitz <shaul.triebitz@intel.com>
Reviewed-by: Miriam Rachel Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240228094500.ce1bfc83a680.I43a6f8ab2804ee07116a37d5b9ec601b843464b1@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/mvm/d3.c
include/net/mac80211.h
net/mac80211/key.c

index 6d5ed79b9fff0b21fede24a3728e580385cefbfd..ca2c6d0b605efc4879c0cb07bb934aaf9a4a4657 100644 (file)
@@ -1976,6 +1976,7 @@ static bool iwl_mvm_gtk_rekey(struct iwl_wowlan_status_data *status,
        } conf = {
                .conf.cipher = gtk_cipher,
        };
+       int link_id = vif->active_links ? __ffs(vif->active_links) : -1;
 
        BUILD_BUG_ON(WLAN_KEY_LEN_CCMP != WLAN_KEY_LEN_GCMP);
        BUILD_BUG_ON(sizeof(conf.key) < WLAN_KEY_LEN_CCMP);
@@ -2009,7 +2010,7 @@ static bool iwl_mvm_gtk_rekey(struct iwl_wowlan_status_data *status,
                memcpy(conf.conf.key, status->gtk[i].key,
                       sizeof(status->gtk[i].key));
 
-               key = ieee80211_gtk_rekey_add(vif, &conf.conf);
+               key = ieee80211_gtk_rekey_add(vif, &conf.conf, link_id);
                if (IS_ERR(key))
                        return false;
 
@@ -2040,6 +2041,7 @@ iwl_mvm_d3_igtk_bigtk_rekey_add(struct iwl_wowlan_status_data *status,
                .conf.keyidx = key_data->id,
        };
        struct ieee80211_key_seq seq;
+       int link_id = vif->active_links ? __ffs(vif->active_links) : -1;
 
        if (!key_data->len)
                return true;
@@ -2065,17 +2067,17 @@ iwl_mvm_d3_igtk_bigtk_rekey_add(struct iwl_wowlan_status_data *status,
        BUILD_BUG_ON(sizeof(conf.key) < sizeof(key_data->key));
        memcpy(conf.conf.key, key_data->key, conf.conf.keylen);
 
-       key_config = ieee80211_gtk_rekey_add(vif, &conf.conf);
+       key_config = ieee80211_gtk_rekey_add(vif, &conf.conf, link_id);
        if (IS_ERR(key_config))
                return false;
        ieee80211_set_key_rx_seq(key_config, 0, &seq);
 
        if (key_config->keyidx == 4 || key_config->keyidx == 5) {
                struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
-               int link_id = vif->active_links ? __ffs(vif->active_links) : 0;
-               struct iwl_mvm_vif_link_info *mvm_link =
-                       mvmvif->link[link_id];
+               struct iwl_mvm_vif_link_info *mvm_link;
 
+               link_id = link_id < 0 ? 0 : link_id;
+               mvm_link = mvmvif->link[link_id];
                mvm_link->igtk = key_config;
        }
 
index 56c6ecb2c10a230683e2840e9b6a5a0688ad0053..34d66d0a24b159a963d58f6e03fec8c789398cb3 100644 (file)
@@ -5912,6 +5912,7 @@ void ieee80211_remove_key(struct ieee80211_key_conf *keyconf);
  * ieee80211_gtk_rekey_add - add a GTK key from rekeying during WoWLAN
  * @vif: the virtual interface to add the key on
  * @keyconf: new key data
+ * @link_id: the link id of the key or -1 for non-MLO
  *
  * When GTK rekeying was done while the system was suspended, (a) new
  * key(s) will be available. These will be needed by mac80211 for proper
@@ -5939,7 +5940,8 @@ void ieee80211_remove_key(struct ieee80211_key_conf *keyconf);
  */
 struct ieee80211_key_conf *
 ieee80211_gtk_rekey_add(struct ieee80211_vif *vif,
-                       struct ieee80211_key_conf *keyconf);
+                       struct ieee80211_key_conf *keyconf,
+                       int link_id);
 
 /**
  * ieee80211_gtk_rekey_notify - notify userspace supplicant of rekeying
index a2cce62c97b70840d180ec1694f1a33553dd0dd8..eecdd2265eaa6351ff6653f6af7b3ce7dc72b0f7 100644 (file)
@@ -6,7 +6,7 @@
  * Copyright 2007-2008 Johannes Berg <johannes@sipsolutions.net>
  * Copyright 2013-2014  Intel Mobile Communications GmbH
  * Copyright 2015-2017 Intel Deutschland GmbH
- * Copyright 2018-2020, 2022-2023  Intel Corporation
+ * Copyright 2018-2020, 2022-2024  Intel Corporation
  */
 
 #include <crypto/utils.h>
@@ -1372,12 +1372,19 @@ EXPORT_SYMBOL_GPL(ieee80211_remove_key);
 
 struct ieee80211_key_conf *
 ieee80211_gtk_rekey_add(struct ieee80211_vif *vif,
-                       struct ieee80211_key_conf *keyconf)
+                       struct ieee80211_key_conf *keyconf,
+                       int link_id)
 {
        struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
        struct ieee80211_local *local = sdata->local;
        struct ieee80211_key *key;
        int err;
+       struct ieee80211_link_data *link_data =
+               link_id < 0 ? &sdata->deflink :
+               sdata_dereference(sdata->link[link_id], sdata);
+
+       if (WARN_ON(!link_data))
+               return ERR_PTR(-EINVAL);
 
        if (WARN_ON(!local->wowlan))
                return ERR_PTR(-EINVAL);
@@ -1394,8 +1401,9 @@ ieee80211_gtk_rekey_add(struct ieee80211_vif *vif,
        if (sdata->u.mgd.mfp != IEEE80211_MFP_DISABLED)
                key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
 
-       /* FIXME: this function needs to get a link ID */
-       err = ieee80211_key_link(key, &sdata->deflink, NULL);
+       key->conf.link_id = link_id;
+
+       err = ieee80211_key_link(key, link_data, NULL);
        if (err)
                return ERR_PTR(err);