Lines Matching +full:key +full:-
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright 2002-2005, Instant802 Networks, Inc.
4 * Copyright 2005-2006, Devicescape Software, Inc.
5 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
6 * Copyright 2007-2008 Johannes Berg <johannes@sipsolutions.net>
7 * Copyright 2013-2014 Intel Mobile Communications GmbH
8 * Copyright 2015-2017 Intel Deutschland GmbH
9 * Copyright 2018-2020, 2022-2024 Intel Corporation
23 #include "driver-ops.h"
32 * DOC: Key handling basics
34 * Key handling in mac80211 is done based on per-interface (sub_if_data)
35 * keys and per-station keys. Since each station belongs to an interface,
36 * each station key also belongs to that interface.
38 * Hardware acceleration is done on a best-effort basis for algorithms
39 * that are implemented in software, for each key the hardware is asked
40 * to enable that key for offloading but if it cannot do that the key is
43 * There is currently no way of knowing whether a key is handled in SW
46 * All key management is internally protected by a mutex. Within all
47 * other parts of mac80211, key references are, just as STA structure
49 * unprotected, namely the key->sta dereferences within the hardware
51 * remove the key which waits for an RCU grace period.
61 if (sdata->vif.type != NL80211_IFTYPE_AP) in update_vlan_tailroom_need_count()
65 lockdep_assert_wiphy(sdata->local->hw.wiphy); in update_vlan_tailroom_need_count()
69 list_for_each_entry_rcu(vlan, &sdata->u.ap.vlans, u.vlan.list) in update_vlan_tailroom_need_count()
70 vlan->crypto_tx_tailroom_needed_cnt += delta; in update_vlan_tailroom_need_count()
82 * 1. SKB resize was skipped because no key was added but just before in increment_tailroom_need_count()
83 * the xmit key is added and SW encryption kicks off. in increment_tailroom_need_count()
86 * just before xmit one of the key is deleted and SW encryption kicks in increment_tailroom_need_count()
96 lockdep_assert_wiphy(sdata->local->hw.wiphy); in increment_tailroom_need_count()
100 if (!sdata->crypto_tx_tailroom_needed_cnt++) { in increment_tailroom_need_count()
103 * encryption at all if the count transition is from 0 -> 1. in increment_tailroom_need_count()
112 lockdep_assert_wiphy(sdata->local->hw.wiphy); in decrease_tailroom_need_count()
114 WARN_ON_ONCE(sdata->crypto_tx_tailroom_needed_cnt < delta); in decrease_tailroom_need_count()
116 update_vlan_tailroom_need_count(sdata, -delta); in decrease_tailroom_need_count()
117 sdata->crypto_tx_tailroom_needed_cnt -= delta; in decrease_tailroom_need_count()
120 static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key) in ieee80211_key_enable_hw_accel() argument
122 struct ieee80211_sub_if_data *sdata = key->sdata; in ieee80211_key_enable_hw_accel()
124 int ret = -EOPNOTSUPP; in ieee80211_key_enable_hw_accel()
127 lockdep_assert_wiphy(key->local->hw.wiphy); in ieee80211_key_enable_hw_accel()
129 if (key->flags & KEY_FLAG_TAINTED) { in ieee80211_key_enable_hw_accel()
130 /* If we get here, it's during resume and the key is in ieee80211_key_enable_hw_accel()
137 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE && in ieee80211_key_enable_hw_accel()
138 !(key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC | in ieee80211_key_enable_hw_accel()
143 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; in ieee80211_key_enable_hw_accel()
144 return -EINVAL; in ieee80211_key_enable_hw_accel()
147 if (!key->local->ops->set_key) in ieee80211_key_enable_hw_accel()
150 sta = key->sta; in ieee80211_key_enable_hw_accel()
153 * If this is a per-STA GTK, check if it in ieee80211_key_enable_hw_accel()
156 if (sta && !(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE) && in ieee80211_key_enable_hw_accel()
157 !ieee80211_hw_check(&key->local->hw, SUPPORTS_PER_STA_GTK)) in ieee80211_key_enable_hw_accel()
160 if (sta && !sta->uploaded) in ieee80211_key_enable_hw_accel()
163 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_key_enable_hw_accel()
168 if (!(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE)) { in ieee80211_key_enable_hw_accel()
174 if (key->conf.link_id >= 0 && sdata->vif.active_links && in ieee80211_key_enable_hw_accel()
175 !(sdata->vif.active_links & BIT(key->conf.link_id))) in ieee80211_key_enable_hw_accel()
178 ret = drv_set_key(key->local, SET_KEY, sdata, in ieee80211_key_enable_hw_accel()
179 sta ? &sta->sta : NULL, &key->conf); in ieee80211_key_enable_hw_accel()
182 key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE; in ieee80211_key_enable_hw_accel()
184 if (!(key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC | in ieee80211_key_enable_hw_accel()
189 WARN_ON((key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE) && in ieee80211_key_enable_hw_accel()
190 (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)); in ieee80211_key_enable_hw_accel()
192 WARN_ON((key->conf.flags & IEEE80211_KEY_FLAG_PUT_MIC_SPACE) && in ieee80211_key_enable_hw_accel()
193 (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC)); in ieee80211_key_enable_hw_accel()
198 if (ret != -ENOSPC && ret != -EOPNOTSUPP && ret != 1) in ieee80211_key_enable_hw_accel()
200 "failed to set key (%d, %pM) to hardware (%d)\n", in ieee80211_key_enable_hw_accel()
201 key->conf.keyidx, in ieee80211_key_enable_hw_accel()
202 sta ? sta->sta.addr : bcast_addr, ret); in ieee80211_key_enable_hw_accel()
205 switch (key->conf.cipher) { in ieee80211_key_enable_hw_accel()
217 /* all of these we can do in software - if driver can */ in ieee80211_key_enable_hw_accel()
220 if (ieee80211_hw_check(&key->local->hw, SW_CRYPTO_CONTROL)) in ieee80211_key_enable_hw_accel()
221 return -EINVAL; in ieee80211_key_enable_hw_accel()
224 return -EINVAL; in ieee80211_key_enable_hw_accel()
228 static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key) in ieee80211_key_disable_hw_accel() argument
236 if (!key || !key->local->ops->set_key) in ieee80211_key_disable_hw_accel()
239 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) in ieee80211_key_disable_hw_accel()
242 sta = key->sta; in ieee80211_key_disable_hw_accel()
243 sdata = key->sdata; in ieee80211_key_disable_hw_accel()
245 lockdep_assert_wiphy(key->local->hw.wiphy); in ieee80211_key_disable_hw_accel()
247 if (key->conf.link_id >= 0 && sdata->vif.active_links && in ieee80211_key_disable_hw_accel()
248 !(sdata->vif.active_links & BIT(key->conf.link_id))) in ieee80211_key_disable_hw_accel()
251 if (!(key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC | in ieee80211_key_disable_hw_accel()
256 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; in ieee80211_key_disable_hw_accel()
257 ret = drv_set_key(key->local, DISABLE_KEY, sdata, in ieee80211_key_disable_hw_accel()
258 sta ? &sta->sta : NULL, &key->conf); in ieee80211_key_disable_hw_accel()
262 "failed to remove key (%d, %pM) from hardware (%d)\n", in ieee80211_key_disable_hw_accel()
263 key->conf.keyidx, in ieee80211_key_disable_hw_accel()
264 sta ? sta->sta.addr : bcast_addr, ret); in ieee80211_key_disable_hw_accel()
267 static int _ieee80211_set_tx_key(struct ieee80211_key *key, bool force) in _ieee80211_set_tx_key() argument
269 struct sta_info *sta = key->sta; in _ieee80211_set_tx_key()
270 struct ieee80211_local *local = key->local; in _ieee80211_set_tx_key()
272 lockdep_assert_wiphy(local->hw.wiphy); in _ieee80211_set_tx_key()
276 sta->ptk_idx = key->conf.keyidx; in _ieee80211_set_tx_key()
278 if (force || !ieee80211_hw_check(&local->hw, AMPDU_KEYBORDER_SUPPORT)) in _ieee80211_set_tx_key()
285 int ieee80211_set_tx_key(struct ieee80211_key *key) in ieee80211_set_tx_key() argument
287 return _ieee80211_set_tx_key(key, false); in ieee80211_set_tx_key()
293 struct ieee80211_local *local = new->local; in ieee80211_pairwise_rekey()
294 struct sta_info *sta = new->sta; in ieee80211_pairwise_rekey()
297 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_pairwise_rekey()
299 if (new->conf.flags & IEEE80211_KEY_FLAG_NO_AUTO_TX) { in ieee80211_pairwise_rekey()
300 /* Extended Key ID key install, initial one or rekey */ in ieee80211_pairwise_rekey()
302 if (sta->ptk_idx != INVALID_PTK_KEYIDX && in ieee80211_pairwise_rekey()
303 !ieee80211_hw_check(&local->hw, AMPDU_KEYBORDER_SUPPORT)) { in ieee80211_pairwise_rekey()
304 /* Aggregation Sessions with Extended Key ID must not in ieee80211_pairwise_rekey()
305 * mix MPDUs with different keyIDs within one A-MPDU. in ieee80211_pairwise_rekey()
308 * ensure there are no A-MPDUs when the driver is not in ieee80211_pairwise_rekey()
309 * supporting A-MPDU key borders. (Blocking Tx only in ieee80211_pairwise_rekey()
319 /* Rekey without Extended Key ID. in ieee80211_pairwise_rekey()
324 if (!(old->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) in ieee80211_pairwise_rekey()
327 /* Stop Tx till we are on the new key */ in ieee80211_pairwise_rekey()
328 old->flags |= KEY_FLAG_TAINTED; in ieee80211_pairwise_rekey()
330 if (ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION)) { in ieee80211_pairwise_rekey()
335 if (!wiphy_ext_feature_isset(local->hw.wiphy, in ieee80211_pairwise_rekey()
338 sta->sta.addr); in ieee80211_pairwise_rekey()
342 ieee80211_flush_queues(local, old->sdata, false); in ieee80211_pairwise_rekey()
350 struct ieee80211_sub_if_data *sdata = link->sdata; in __ieee80211_set_default_key()
351 struct ieee80211_key *key = NULL; in __ieee80211_set_default_key() local
353 lockdep_assert_wiphy(sdata->local->hw.wiphy); in __ieee80211_set_default_key()
356 key = wiphy_dereference(sdata->local->hw.wiphy, in __ieee80211_set_default_key()
357 sdata->keys[idx]); in __ieee80211_set_default_key()
358 if (!key) in __ieee80211_set_default_key()
359 key = wiphy_dereference(sdata->local->hw.wiphy, in __ieee80211_set_default_key()
360 link->gtk[idx]); in __ieee80211_set_default_key()
364 rcu_assign_pointer(sdata->default_unicast_key, key); in __ieee80211_set_default_key()
366 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN) in __ieee80211_set_default_key()
367 drv_set_default_unicast_key(sdata->local, sdata, idx); in __ieee80211_set_default_key()
371 rcu_assign_pointer(link->default_multicast_key, key); in __ieee80211_set_default_key()
379 lockdep_assert_wiphy(link->sdata->local->hw.wiphy); in ieee80211_set_default_key()
387 struct ieee80211_sub_if_data *sdata = link->sdata; in __ieee80211_set_default_mgmt_key()
388 struct ieee80211_key *key = NULL; in __ieee80211_set_default_mgmt_key() local
390 lockdep_assert_wiphy(sdata->local->hw.wiphy); in __ieee80211_set_default_mgmt_key()
394 key = wiphy_dereference(sdata->local->hw.wiphy, in __ieee80211_set_default_mgmt_key()
395 link->gtk[idx]); in __ieee80211_set_default_mgmt_key()
397 rcu_assign_pointer(link->default_mgmt_key, key); in __ieee80211_set_default_mgmt_key()
405 lockdep_assert_wiphy(link->sdata->local->hw.wiphy); in ieee80211_set_default_mgmt_key()
413 struct ieee80211_sub_if_data *sdata = link->sdata; in __ieee80211_set_default_beacon_key()
414 struct ieee80211_key *key = NULL; in __ieee80211_set_default_beacon_key() local
416 lockdep_assert_wiphy(sdata->local->hw.wiphy); in __ieee80211_set_default_beacon_key()
421 key = wiphy_dereference(sdata->local->hw.wiphy, in __ieee80211_set_default_beacon_key()
422 link->gtk[idx]); in __ieee80211_set_default_beacon_key()
424 rcu_assign_pointer(link->default_beacon_key, key); in __ieee80211_set_default_beacon_key()
432 lockdep_assert_wiphy(link->sdata->local->hw.wiphy); in ieee80211_set_default_beacon_key()
444 struct link_sta_info *link_sta = sta ? &sta->deflink : NULL; in ieee80211_key_replace()
451 lockdep_assert_wiphy(sdata->local->hw.wiphy); in ieee80211_key_replace()
458 idx = new->conf.keyidx; in ieee80211_key_replace()
459 is_wep = new->conf.cipher == WLAN_CIPHER_SUITE_WEP40 || in ieee80211_key_replace()
460 new->conf.cipher == WLAN_CIPHER_SUITE_WEP104; in ieee80211_key_replace()
461 link_id = new->conf.link_id; in ieee80211_key_replace()
463 idx = old->conf.keyidx; in ieee80211_key_replace()
464 is_wep = old->conf.cipher == WLAN_CIPHER_SUITE_WEP40 || in ieee80211_key_replace()
465 old->conf.cipher == WLAN_CIPHER_SUITE_WEP104; in ieee80211_key_replace()
466 link_id = old->conf.link_id; in ieee80211_key_replace()
469 if (WARN(old && old->conf.link_id != link_id, in ieee80211_key_replace()
471 old->conf.link_id, link_id)) in ieee80211_key_replace()
472 return -EINVAL; in ieee80211_key_replace()
476 link = sdata_dereference(sdata->link[link_id], sdata); in ieee80211_key_replace()
478 return -ENOLINK; in ieee80211_key_replace()
482 link_sta = rcu_dereference_protected(sta->link[link_id], in ieee80211_key_replace()
483 lockdep_is_held(&sta->local->hw.wiphy->mtx)); in ieee80211_key_replace()
485 return -ENOLINK; in ieee80211_key_replace()
488 link = &sdata->deflink; in ieee80211_key_replace()
492 return -EINVAL; in ieee80211_key_replace()
494 WARN_ON(new && old && new->conf.keyidx != old->conf.keyidx); in ieee80211_key_replace()
497 /* Unicast rekey needs special handling. With Extended Key ID in ieee80211_key_replace()
504 if (old->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) { in ieee80211_key_replace()
511 if (!new->local->wowlan) in ieee80211_key_replace()
514 new->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE; in ieee80211_key_replace()
521 list_add_tail_rcu(&new->list, &sdata->key_list); in ieee80211_key_replace()
525 rcu_assign_pointer(sta->ptk[idx], new); in ieee80211_key_replace()
527 !(new->conf.flags & IEEE80211_KEY_FLAG_NO_AUTO_TX)) in ieee80211_key_replace()
530 rcu_assign_pointer(link_sta->gtk[idx], new); in ieee80211_key_replace()
532 /* Only needed for transition from no key -> key. in ieee80211_key_replace()
533 * Still triggers unnecessary when using Extended Key ID in ieee80211_key_replace()
534 * and installing the second key ID the first time. in ieee80211_key_replace()
540 old == wiphy_dereference(sdata->local->hw.wiphy, in ieee80211_key_replace()
541 sdata->default_unicast_key); in ieee80211_key_replace()
543 old == wiphy_dereference(sdata->local->hw.wiphy, in ieee80211_key_replace()
544 link->default_multicast_key); in ieee80211_key_replace()
546 old == wiphy_dereference(sdata->local->hw.wiphy, in ieee80211_key_replace()
547 link->default_mgmt_key); in ieee80211_key_replace()
549 old == wiphy_dereference(sdata->local->hw.wiphy, in ieee80211_key_replace()
550 link->default_beacon_key); in ieee80211_key_replace()
553 __ieee80211_set_default_key(link, -1, true, false); in ieee80211_key_replace()
555 __ieee80211_set_default_key(link, -1, false, true); in ieee80211_key_replace()
557 __ieee80211_set_default_mgmt_key(link, -1); in ieee80211_key_replace()
559 __ieee80211_set_default_beacon_key(link, -1); in ieee80211_key_replace()
562 rcu_assign_pointer(sdata->keys[idx], new); in ieee80211_key_replace()
564 rcu_assign_pointer(link->gtk[idx], new); in ieee80211_key_replace()
567 __ieee80211_set_default_key(link, new->conf.keyidx, in ieee80211_key_replace()
570 __ieee80211_set_default_key(link, new->conf.keyidx, in ieee80211_key_replace()
574 new->conf.keyidx); in ieee80211_key_replace()
577 new->conf.keyidx); in ieee80211_key_replace()
581 list_del_rcu(&old->list); in ieee80211_key_replace()
591 struct ieee80211_key *key; in ieee80211_key_alloc() local
597 return ERR_PTR(-EINVAL); in ieee80211_key_alloc()
599 key = kzalloc(sizeof(struct ieee80211_key) + key_len, GFP_KERNEL); in ieee80211_key_alloc()
600 if (!key) in ieee80211_key_alloc()
601 return ERR_PTR(-ENOMEM); in ieee80211_key_alloc()
605 * key to the hardware if possible. in ieee80211_key_alloc()
607 key->conf.flags = 0; in ieee80211_key_alloc()
608 key->flags = 0; in ieee80211_key_alloc()
610 key->conf.link_id = -1; in ieee80211_key_alloc()
611 key->conf.cipher = cipher; in ieee80211_key_alloc()
612 key->conf.keyidx = idx; in ieee80211_key_alloc()
613 key->conf.keylen = key_len; in ieee80211_key_alloc()
617 key->conf.iv_len = IEEE80211_WEP_IV_LEN; in ieee80211_key_alloc()
618 key->conf.icv_len = IEEE80211_WEP_ICV_LEN; in ieee80211_key_alloc()
621 key->conf.iv_len = IEEE80211_TKIP_IV_LEN; in ieee80211_key_alloc()
622 key->conf.icv_len = IEEE80211_TKIP_ICV_LEN; in ieee80211_key_alloc()
625 key->u.tkip.rx[i].iv32 = in ieee80211_key_alloc()
627 key->u.tkip.rx[i].iv16 = in ieee80211_key_alloc()
631 spin_lock_init(&key->u.tkip.txlock); in ieee80211_key_alloc()
634 key->conf.iv_len = IEEE80211_CCMP_HDR_LEN; in ieee80211_key_alloc()
635 key->conf.icv_len = IEEE80211_CCMP_MIC_LEN; in ieee80211_key_alloc()
639 key->u.ccmp.rx_pn[i][j] = in ieee80211_key_alloc()
640 seq[IEEE80211_CCMP_PN_LEN - j - 1]; in ieee80211_key_alloc()
643 * Initialize AES key state here as an optimization so that in ieee80211_key_alloc()
646 key->u.ccmp.tfm = ieee80211_aes_key_setup_encrypt( in ieee80211_key_alloc()
648 if (IS_ERR(key->u.ccmp.tfm)) { in ieee80211_key_alloc()
649 err = PTR_ERR(key->u.ccmp.tfm); in ieee80211_key_alloc()
650 kfree(key); in ieee80211_key_alloc()
655 key->conf.iv_len = IEEE80211_CCMP_256_HDR_LEN; in ieee80211_key_alloc()
656 key->conf.icv_len = IEEE80211_CCMP_256_MIC_LEN; in ieee80211_key_alloc()
659 key->u.ccmp.rx_pn[i][j] = in ieee80211_key_alloc()
660 seq[IEEE80211_CCMP_256_PN_LEN - j - 1]; in ieee80211_key_alloc()
661 /* Initialize AES key state here as an optimization so that in ieee80211_key_alloc()
664 key->u.ccmp.tfm = ieee80211_aes_key_setup_encrypt( in ieee80211_key_alloc()
666 if (IS_ERR(key->u.ccmp.tfm)) { in ieee80211_key_alloc()
667 err = PTR_ERR(key->u.ccmp.tfm); in ieee80211_key_alloc()
668 kfree(key); in ieee80211_key_alloc()
674 key->conf.iv_len = 0; in ieee80211_key_alloc()
676 key->conf.icv_len = sizeof(struct ieee80211_mmie); in ieee80211_key_alloc()
678 key->conf.icv_len = sizeof(struct ieee80211_mmie_16); in ieee80211_key_alloc()
681 key->u.aes_cmac.rx_pn[j] = in ieee80211_key_alloc()
682 seq[IEEE80211_CMAC_PN_LEN - j - 1]; in ieee80211_key_alloc()
684 * Initialize AES key state here as an optimization so that in ieee80211_key_alloc()
687 key->u.aes_cmac.tfm = in ieee80211_key_alloc()
689 if (IS_ERR(key->u.aes_cmac.tfm)) { in ieee80211_key_alloc()
690 err = PTR_ERR(key->u.aes_cmac.tfm); in ieee80211_key_alloc()
691 kfree(key); in ieee80211_key_alloc()
697 key->conf.iv_len = 0; in ieee80211_key_alloc()
698 key->conf.icv_len = sizeof(struct ieee80211_mmie_16); in ieee80211_key_alloc()
701 key->u.aes_gmac.rx_pn[j] = in ieee80211_key_alloc()
702 seq[IEEE80211_GMAC_PN_LEN - j - 1]; in ieee80211_key_alloc()
703 /* Initialize AES key state here as an optimization so that in ieee80211_key_alloc()
706 key->u.aes_gmac.tfm = in ieee80211_key_alloc()
708 if (IS_ERR(key->u.aes_gmac.tfm)) { in ieee80211_key_alloc()
709 err = PTR_ERR(key->u.aes_gmac.tfm); in ieee80211_key_alloc()
710 kfree(key); in ieee80211_key_alloc()
716 key->conf.iv_len = IEEE80211_GCMP_HDR_LEN; in ieee80211_key_alloc()
717 key->conf.icv_len = IEEE80211_GCMP_MIC_LEN; in ieee80211_key_alloc()
720 key->u.gcmp.rx_pn[i][j] = in ieee80211_key_alloc()
721 seq[IEEE80211_GCMP_PN_LEN - j - 1]; in ieee80211_key_alloc()
722 /* Initialize AES key state here as an optimization so that in ieee80211_key_alloc()
725 key->u.gcmp.tfm = ieee80211_aes_gcm_key_setup_encrypt(key_data, in ieee80211_key_alloc()
727 if (IS_ERR(key->u.gcmp.tfm)) { in ieee80211_key_alloc()
728 err = PTR_ERR(key->u.gcmp.tfm); in ieee80211_key_alloc()
729 kfree(key); in ieee80211_key_alloc()
734 memcpy(key->conf.key, key_data, key_len); in ieee80211_key_alloc()
735 INIT_LIST_HEAD(&key->list); in ieee80211_key_alloc()
737 return key; in ieee80211_key_alloc()
740 static void ieee80211_key_free_common(struct ieee80211_key *key) in ieee80211_key_free_common() argument
742 switch (key->conf.cipher) { in ieee80211_key_free_common()
745 ieee80211_aes_key_free(key->u.ccmp.tfm); in ieee80211_key_free_common()
749 ieee80211_aes_cmac_key_free(key->u.aes_cmac.tfm); in ieee80211_key_free_common()
753 ieee80211_aes_gmac_key_free(key->u.aes_gmac.tfm); in ieee80211_key_free_common()
757 ieee80211_aes_gcm_key_free(key->u.gcmp.tfm); in ieee80211_key_free_common()
760 kfree_sensitive(key); in ieee80211_key_free_common()
763 static void __ieee80211_key_destroy(struct ieee80211_key *key, in __ieee80211_key_destroy() argument
766 if (key->local) { in __ieee80211_key_destroy()
767 struct ieee80211_sub_if_data *sdata = key->sdata; in __ieee80211_key_destroy()
769 ieee80211_debugfs_key_remove(key); in __ieee80211_key_destroy()
773 sdata->crypto_tx_tailroom_pending_dec++; in __ieee80211_key_destroy()
774 wiphy_delayed_work_queue(sdata->local->hw.wiphy, in __ieee80211_key_destroy()
775 &sdata->dec_tailroom_needed_wk, in __ieee80211_key_destroy()
782 ieee80211_key_free_common(key); in __ieee80211_key_destroy()
785 static void ieee80211_key_destroy(struct ieee80211_key *key, in ieee80211_key_destroy() argument
788 if (!key) in ieee80211_key_destroy()
792 * Synchronize so the TX path and rcu key iterators in ieee80211_key_destroy()
793 * can no longer be using this key before we free/remove it. in ieee80211_key_destroy()
797 __ieee80211_key_destroy(key, delay_tailroom); in ieee80211_key_destroy()
800 void ieee80211_key_free_unused(struct ieee80211_key *key) in ieee80211_key_free_unused() argument
802 if (!key) in ieee80211_key_free_unused()
805 WARN_ON(key->sdata || key->local); in ieee80211_key_free_unused()
806 ieee80211_key_free_common(key); in ieee80211_key_free_unused()
816 if (!old || new->conf.keylen != old->conf.keylen) in ieee80211_key_identical()
819 tk_old = old->conf.key; in ieee80211_key_identical()
820 tk_new = new->conf.key; in ieee80211_key_identical()
823 * In station mode, don't compare the TX MIC key, as it's never used in ieee80211_key_identical()
827 if (sdata->vif.type == NL80211_IFTYPE_STATION && in ieee80211_key_identical()
828 new->conf.cipher == WLAN_CIPHER_SUITE_TKIP && in ieee80211_key_identical()
829 new->conf.keylen == WLAN_KEY_LEN_TKIP && in ieee80211_key_identical()
830 !(new->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE)) { in ieee80211_key_identical()
839 return !crypto_memneq(tk_old, tk_new, new->conf.keylen); in ieee80211_key_identical()
842 int ieee80211_key_link(struct ieee80211_key *key, in ieee80211_key_link() argument
846 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_key_link()
849 int idx = key->conf.keyidx; in ieee80211_key_link()
850 bool pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE; in ieee80211_key_link()
852 * We want to delay tailroom updates only for station - in that in ieee80211_key_link()
856 bool delay_tailroom = sdata->vif.type == NL80211_IFTYPE_STATION; in ieee80211_key_link()
859 lockdep_assert_wiphy(sdata->local->hw.wiphy); in ieee80211_key_link()
864 old_key = wiphy_dereference(sdata->local->hw.wiphy, in ieee80211_key_link()
865 sta->ptk[idx]); in ieee80211_key_link()
866 alt_key = wiphy_dereference(sdata->local->hw.wiphy, in ieee80211_key_link()
867 sta->ptk[idx ^ 1]); in ieee80211_key_link()
869 /* The rekey code assumes that the old and new key are using in ieee80211_key_link()
872 if ((alt_key && alt_key->conf.cipher != key->conf.cipher) || in ieee80211_key_link()
873 (old_key && old_key->conf.cipher != key->conf.cipher)) { in ieee80211_key_link()
874 ret = -EOPNOTSUPP; in ieee80211_key_link()
878 struct link_sta_info *link_sta = &sta->deflink; in ieee80211_key_link()
879 int link_id = key->conf.link_id; in ieee80211_key_link()
882 link_sta = rcu_dereference_protected(sta->link[link_id], in ieee80211_key_link()
883 lockdep_is_held(&sta->local->hw.wiphy->mtx)); in ieee80211_key_link()
885 ret = -ENOLINK; in ieee80211_key_link()
890 old_key = wiphy_dereference(sdata->local->hw.wiphy, in ieee80211_key_link()
891 link_sta->gtk[idx]); in ieee80211_key_link()
894 old_key = wiphy_dereference(sdata->local->hw.wiphy, in ieee80211_key_link()
895 sdata->keys[idx]); in ieee80211_key_link()
897 old_key = wiphy_dereference(sdata->local->hw.wiphy, in ieee80211_key_link()
898 link->gtk[idx]); in ieee80211_key_link()
901 /* Non-pairwise keys must also not switch the cipher on rekey */ in ieee80211_key_link()
903 if (old_key && old_key->conf.cipher != key->conf.cipher) { in ieee80211_key_link()
904 ret = -EOPNOTSUPP; in ieee80211_key_link()
910 * Silently accept key re-installation without really installing the in ieee80211_key_link()
911 * new version of the key to avoid nonce reuse or replay issues. in ieee80211_key_link()
913 if (ieee80211_key_identical(sdata, old_key, key)) { in ieee80211_key_link()
914 ret = -EALREADY; in ieee80211_key_link()
918 key->local = sdata->local; in ieee80211_key_link()
919 key->sdata = sdata; in ieee80211_key_link()
920 key->sta = sta; in ieee80211_key_link()
923 * Assign a unique ID to every key so we can easily prevent mixed in ieee80211_key_link()
924 * key and fragment cache attacks. in ieee80211_key_link()
926 key->color = atomic_inc_return(&key_color); in ieee80211_key_link()
929 if (sta && sta->sta.spp_amsdu) in ieee80211_key_link()
930 key->conf.flags |= IEEE80211_KEY_FLAG_SPP_AMSDU; in ieee80211_key_link()
934 ret = ieee80211_key_replace(sdata, link, sta, pairwise, old_key, key); in ieee80211_key_link()
937 ieee80211_debugfs_key_add(key); in ieee80211_key_link()
940 ieee80211_key_free(key, delay_tailroom); in ieee80211_key_link()
943 key = NULL; in ieee80211_key_link()
946 ieee80211_key_free_unused(key); in ieee80211_key_link()
950 void ieee80211_key_free(struct ieee80211_key *key, bool delay_tailroom) in ieee80211_key_free() argument
952 if (!key) in ieee80211_key_free()
956 * Replace key with nothingness if it was ever used. in ieee80211_key_free()
958 if (key->sdata) in ieee80211_key_free()
959 ieee80211_key_replace(key->sdata, NULL, key->sta, in ieee80211_key_free()
960 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, in ieee80211_key_free()
961 key, NULL); in ieee80211_key_free()
962 ieee80211_key_destroy(key, delay_tailroom); in ieee80211_key_free()
967 struct ieee80211_key *key; in ieee80211_reenable_keys() local
970 lockdep_assert_wiphy(sdata->local->hw.wiphy); in ieee80211_reenable_keys()
972 sdata->crypto_tx_tailroom_needed_cnt = 0; in ieee80211_reenable_keys()
973 sdata->crypto_tx_tailroom_pending_dec = 0; in ieee80211_reenable_keys()
975 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_reenable_keys()
976 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) { in ieee80211_reenable_keys()
977 vlan->crypto_tx_tailroom_needed_cnt = 0; in ieee80211_reenable_keys()
978 vlan->crypto_tx_tailroom_pending_dec = 0; in ieee80211_reenable_keys()
983 list_for_each_entry(key, &sdata->key_list, list) { in ieee80211_reenable_keys()
985 ieee80211_key_enable_hw_accel(key); in ieee80211_reenable_keys()
993 struct ieee80211_key *key, in ieee80211_key_iter() argument
997 struct ieee80211_key_conf *key, in ieee80211_key_iter() argument
1002 if (key->sta && key->sta->removed) in ieee80211_key_iter()
1004 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) in ieee80211_key_iter()
1006 iter(hw, vif, key->sta ? &key->sta->sta : NULL, in ieee80211_key_iter()
1007 &key->conf, iter_data); in ieee80211_key_iter()
1015 struct ieee80211_key_conf *key, in ieee80211_iter_keys() argument
1020 struct ieee80211_key *key, *tmp; in ieee80211_iter_keys() local
1023 lockdep_assert_wiphy(hw->wiphy); in ieee80211_iter_keys()
1027 list_for_each_entry_safe(key, tmp, &sdata->key_list, list) in ieee80211_iter_keys()
1028 ieee80211_key_iter(hw, vif, key, iter, iter_data); in ieee80211_iter_keys()
1030 list_for_each_entry(sdata, &local->interfaces, list) in ieee80211_iter_keys()
1031 list_for_each_entry_safe(key, tmp, in ieee80211_iter_keys()
1032 &sdata->key_list, list) in ieee80211_iter_keys()
1033 ieee80211_key_iter(hw, &sdata->vif, key, in ieee80211_iter_keys()
1045 struct ieee80211_key_conf *key, in _ieee80211_iter_keys_rcu() argument
1049 struct ieee80211_key *key; in _ieee80211_iter_keys_rcu() local
1051 list_for_each_entry_rcu(key, &sdata->key_list, list) in _ieee80211_iter_keys_rcu()
1052 ieee80211_key_iter(hw, &sdata->vif, key, iter, iter_data); in _ieee80211_iter_keys_rcu()
1060 struct ieee80211_key_conf *key, in ieee80211_iter_keys_rcu() argument
1071 list_for_each_entry_rcu(sdata, &local->interfaces, list) in ieee80211_iter_keys_rcu()
1080 struct ieee80211_key *key, *tmp; in ieee80211_free_keys_iface() local
1083 sdata->crypto_tx_tailroom_pending_dec); in ieee80211_free_keys_iface()
1084 sdata->crypto_tx_tailroom_pending_dec = 0; in ieee80211_free_keys_iface()
1089 list_for_each_entry_safe(key, tmp, &sdata->key_list, list) { in ieee80211_free_keys_iface()
1090 ieee80211_key_replace(key->sdata, NULL, key->sta, in ieee80211_free_keys_iface()
1091 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, in ieee80211_free_keys_iface()
1092 key, NULL); in ieee80211_free_keys_iface()
1093 list_add_tail(&key->list, keys); in ieee80211_free_keys_iface()
1102 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_remove_link_keys()
1103 struct ieee80211_local *local = sdata->local; in ieee80211_remove_link_keys()
1104 struct ieee80211_key *key, *tmp; in ieee80211_remove_link_keys() local
1106 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_remove_link_keys()
1108 list_for_each_entry_safe(key, tmp, &sdata->key_list, list) { in ieee80211_remove_link_keys()
1109 if (key->conf.link_id != link->link_id) in ieee80211_remove_link_keys()
1111 ieee80211_key_replace(key->sdata, link, key->sta, in ieee80211_remove_link_keys()
1112 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, in ieee80211_remove_link_keys()
1113 key, NULL); in ieee80211_remove_link_keys()
1114 list_add_tail(&key->list, keys); in ieee80211_remove_link_keys()
1121 struct ieee80211_key *key, *tmp; in ieee80211_free_key_list() local
1123 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_free_key_list()
1125 list_for_each_entry_safe(key, tmp, keys, list) in ieee80211_free_key_list()
1126 __ieee80211_key_destroy(key, false); in ieee80211_free_key_list()
1132 struct ieee80211_local *local = sdata->local; in ieee80211_free_keys()
1135 struct ieee80211_key *key, *tmp; in ieee80211_free_keys() local
1138 wiphy_delayed_work_cancel(local->hw.wiphy, in ieee80211_free_keys()
1139 &sdata->dec_tailroom_needed_wk); in ieee80211_free_keys()
1141 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_free_keys()
1145 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_free_keys()
1146 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) in ieee80211_free_keys()
1152 list_for_each_entry_safe(key, tmp, &keys, list) in ieee80211_free_keys()
1153 __ieee80211_key_destroy(key, false); in ieee80211_free_keys()
1155 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_free_keys()
1156 if (sdata->bss) { in ieee80211_free_keys()
1157 master = container_of(sdata->bss, in ieee80211_free_keys()
1161 WARN_ON_ONCE(sdata->crypto_tx_tailroom_needed_cnt != in ieee80211_free_keys()
1162 master->crypto_tx_tailroom_needed_cnt); in ieee80211_free_keys()
1165 WARN_ON_ONCE(sdata->crypto_tx_tailroom_needed_cnt || in ieee80211_free_keys()
1166 sdata->crypto_tx_tailroom_pending_dec); in ieee80211_free_keys()
1169 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_free_keys()
1170 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) in ieee80211_free_keys()
1171 WARN_ON_ONCE(vlan->crypto_tx_tailroom_needed_cnt || in ieee80211_free_keys()
1172 vlan->crypto_tx_tailroom_pending_dec); in ieee80211_free_keys()
1179 struct ieee80211_key *key; in ieee80211_free_sta_keys() local
1182 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_free_sta_keys()
1184 for (i = 0; i < ARRAY_SIZE(sta->deflink.gtk); i++) { in ieee80211_free_sta_keys()
1185 key = wiphy_dereference(local->hw.wiphy, sta->deflink.gtk[i]); in ieee80211_free_sta_keys()
1186 if (!key) in ieee80211_free_sta_keys()
1188 ieee80211_key_replace(key->sdata, NULL, key->sta, in ieee80211_free_sta_keys()
1189 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, in ieee80211_free_sta_keys()
1190 key, NULL); in ieee80211_free_sta_keys()
1191 __ieee80211_key_destroy(key, key->sdata->vif.type == in ieee80211_free_sta_keys()
1196 key = wiphy_dereference(local->hw.wiphy, sta->ptk[i]); in ieee80211_free_sta_keys()
1197 if (!key) in ieee80211_free_sta_keys()
1199 ieee80211_key_replace(key->sdata, NULL, key->sta, in ieee80211_free_sta_keys()
1200 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, in ieee80211_free_sta_keys()
1201 key, NULL); in ieee80211_free_sta_keys()
1202 __ieee80211_key_destroy(key, key->sdata->vif.type == in ieee80211_free_sta_keys()
1218 * and then new keys are installed. The first new key causes the in ieee80211_delayed_tailroom_dec()
1222 * key removal for a while, so if we roam the value is larger than in ieee80211_delayed_tailroom_dec()
1223 * zero and no 0->1 transition happens. in ieee80211_delayed_tailroom_dec()
1232 sdata->crypto_tx_tailroom_pending_dec); in ieee80211_delayed_tailroom_dec()
1233 sdata->crypto_tx_tailroom_pending_dec = 0; in ieee80211_delayed_tailroom_dec()
1243 cfg80211_gtk_rekey_notify(sdata->dev, bssid, replay_ctr, gfp); in ieee80211_gtk_rekey_notify()
1250 struct ieee80211_key *key; in ieee80211_get_key_rx_seq() local
1253 key = container_of(keyconf, struct ieee80211_key, conf); in ieee80211_get_key_rx_seq()
1255 switch (key->conf.cipher) { in ieee80211_get_key_rx_seq()
1259 seq->tkip.iv32 = key->u.tkip.rx[tid].iv32; in ieee80211_get_key_rx_seq()
1260 seq->tkip.iv16 = key->u.tkip.rx[tid].iv16; in ieee80211_get_key_rx_seq()
1264 if (WARN_ON(tid < -1 || tid >= IEEE80211_NUM_TIDS)) in ieee80211_get_key_rx_seq()
1267 pn = key->u.ccmp.rx_pn[IEEE80211_NUM_TIDS]; in ieee80211_get_key_rx_seq()
1269 pn = key->u.ccmp.rx_pn[tid]; in ieee80211_get_key_rx_seq()
1270 memcpy(seq->ccmp.pn, pn, IEEE80211_CCMP_PN_LEN); in ieee80211_get_key_rx_seq()
1276 pn = key->u.aes_cmac.rx_pn; in ieee80211_get_key_rx_seq()
1277 memcpy(seq->aes_cmac.pn, pn, IEEE80211_CMAC_PN_LEN); in ieee80211_get_key_rx_seq()
1283 pn = key->u.aes_gmac.rx_pn; in ieee80211_get_key_rx_seq()
1284 memcpy(seq->aes_gmac.pn, pn, IEEE80211_GMAC_PN_LEN); in ieee80211_get_key_rx_seq()
1288 if (WARN_ON(tid < -1 || tid >= IEEE80211_NUM_TIDS)) in ieee80211_get_key_rx_seq()
1291 pn = key->u.gcmp.rx_pn[IEEE80211_NUM_TIDS]; in ieee80211_get_key_rx_seq()
1293 pn = key->u.gcmp.rx_pn[tid]; in ieee80211_get_key_rx_seq()
1294 memcpy(seq->gcmp.pn, pn, IEEE80211_GCMP_PN_LEN); in ieee80211_get_key_rx_seq()
1303 struct ieee80211_key *key; in ieee80211_set_key_rx_seq() local
1306 key = container_of(keyconf, struct ieee80211_key, conf); in ieee80211_set_key_rx_seq()
1308 switch (key->conf.cipher) { in ieee80211_set_key_rx_seq()
1312 key->u.tkip.rx[tid].iv32 = seq->tkip.iv32; in ieee80211_set_key_rx_seq()
1313 key->u.tkip.rx[tid].iv16 = seq->tkip.iv16; in ieee80211_set_key_rx_seq()
1317 if (WARN_ON(tid < -1 || tid >= IEEE80211_NUM_TIDS)) in ieee80211_set_key_rx_seq()
1320 pn = key->u.ccmp.rx_pn[IEEE80211_NUM_TIDS]; in ieee80211_set_key_rx_seq()
1322 pn = key->u.ccmp.rx_pn[tid]; in ieee80211_set_key_rx_seq()
1323 memcpy(pn, seq->ccmp.pn, IEEE80211_CCMP_PN_LEN); in ieee80211_set_key_rx_seq()
1329 pn = key->u.aes_cmac.rx_pn; in ieee80211_set_key_rx_seq()
1330 memcpy(pn, seq->aes_cmac.pn, IEEE80211_CMAC_PN_LEN); in ieee80211_set_key_rx_seq()
1336 pn = key->u.aes_gmac.rx_pn; in ieee80211_set_key_rx_seq()
1337 memcpy(pn, seq->aes_gmac.pn, IEEE80211_GMAC_PN_LEN); in ieee80211_set_key_rx_seq()
1341 if (WARN_ON(tid < -1 || tid >= IEEE80211_NUM_TIDS)) in ieee80211_set_key_rx_seq()
1344 pn = key->u.gcmp.rx_pn[IEEE80211_NUM_TIDS]; in ieee80211_set_key_rx_seq()
1346 pn = key->u.gcmp.rx_pn[tid]; in ieee80211_set_key_rx_seq()
1347 memcpy(pn, seq->gcmp.pn, IEEE80211_GCMP_PN_LEN); in ieee80211_set_key_rx_seq()
1358 struct ieee80211_key *key; in ieee80211_remove_key() local
1360 key = container_of(keyconf, struct ieee80211_key, conf); in ieee80211_remove_key()
1362 lockdep_assert_wiphy(key->local->hw.wiphy); in ieee80211_remove_key()
1365 * if key was uploaded, we assume the driver will/has remove(d) in ieee80211_remove_key()
1368 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) { in ieee80211_remove_key()
1369 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; in ieee80211_remove_key()
1371 if (!(key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC | in ieee80211_remove_key()
1374 increment_tailroom_need_count(key->sdata); in ieee80211_remove_key()
1377 ieee80211_key_free(key, false); in ieee80211_remove_key()
1387 struct ieee80211_local *local = sdata->local; in ieee80211_gtk_rekey_add()
1388 struct ieee80211_key *key; in ieee80211_gtk_rekey_add() local
1391 link_id < 0 ? &sdata->deflink : in ieee80211_gtk_rekey_add()
1392 sdata_dereference(sdata->link[link_id], sdata); in ieee80211_gtk_rekey_add()
1395 return ERR_PTR(-EINVAL); in ieee80211_gtk_rekey_add()
1397 if (WARN_ON(!local->wowlan)) in ieee80211_gtk_rekey_add()
1398 return ERR_PTR(-EINVAL); in ieee80211_gtk_rekey_add()
1400 if (WARN_ON(vif->type != NL80211_IFTYPE_STATION)) in ieee80211_gtk_rekey_add()
1401 return ERR_PTR(-EINVAL); in ieee80211_gtk_rekey_add()
1403 key = ieee80211_key_alloc(keyconf->cipher, keyconf->keyidx, in ieee80211_gtk_rekey_add()
1404 keyconf->keylen, keyconf->key, in ieee80211_gtk_rekey_add()
1406 if (IS_ERR(key)) in ieee80211_gtk_rekey_add()
1407 return ERR_CAST(key); in ieee80211_gtk_rekey_add()
1409 if (sdata->u.mgd.mfp != IEEE80211_MFP_DISABLED) in ieee80211_gtk_rekey_add()
1410 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT; in ieee80211_gtk_rekey_add()
1412 key->conf.link_id = link_id; in ieee80211_gtk_rekey_add()
1414 err = ieee80211_key_link(key, link_data, NULL); in ieee80211_gtk_rekey_add()
1418 return &key->conf; in ieee80211_gtk_rekey_add()
1424 struct ieee80211_key *key; in ieee80211_key_mic_failure() local
1426 key = container_of(keyconf, struct ieee80211_key, conf); in ieee80211_key_mic_failure()
1428 switch (key->conf.cipher) { in ieee80211_key_mic_failure()
1431 key->u.aes_cmac.icverrors++; in ieee80211_key_mic_failure()
1435 key->u.aes_gmac.icverrors++; in ieee80211_key_mic_failure()
1446 struct ieee80211_key *key; in ieee80211_key_replay() local
1448 key = container_of(keyconf, struct ieee80211_key, conf); in ieee80211_key_replay()
1450 switch (key->conf.cipher) { in ieee80211_key_replay()
1453 key->u.ccmp.replays++; in ieee80211_key_replay()
1457 key->u.aes_cmac.replays++; in ieee80211_key_replay()
1461 key->u.aes_gmac.replays++; in ieee80211_key_replay()
1465 key->u.gcmp.replays++; in ieee80211_key_replay()
1475 struct ieee80211_key *key; in ieee80211_key_switch_links() local
1478 list_for_each_entry(key, &sdata->key_list, list) { in ieee80211_key_switch_links()
1479 if (key->conf.link_id < 0 || in ieee80211_key_switch_links()
1480 !(del_links_mask & BIT(key->conf.link_id))) in ieee80211_key_switch_links()
1483 /* shouldn't happen for per-link keys */ in ieee80211_key_switch_links()
1484 WARN_ON(key->sta); in ieee80211_key_switch_links()
1486 ieee80211_key_disable_hw_accel(key); in ieee80211_key_switch_links()
1489 list_for_each_entry(key, &sdata->key_list, list) { in ieee80211_key_switch_links()
1490 if (key->conf.link_id < 0 || in ieee80211_key_switch_links()
1491 !(add_links_mask & BIT(key->conf.link_id))) in ieee80211_key_switch_links()
1494 /* shouldn't happen for per-link keys */ in ieee80211_key_switch_links()
1495 WARN_ON(key->sta); in ieee80211_key_switch_links()
1497 ret = ieee80211_key_enable_hw_accel(key); in ieee80211_key_switch_links()