Lines Matching +full:- +full:key
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-2023 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.
58 lockdep_assert_held(&local->key_mtx); in assert_key_lock()
66 if (sdata->vif.type != NL80211_IFTYPE_AP) in update_vlan_tailroom_need_count()
70 assert_key_lock(sdata->local); in update_vlan_tailroom_need_count()
74 list_for_each_entry_rcu(vlan, &sdata->u.ap.vlans, u.vlan.list) in update_vlan_tailroom_need_count()
75 vlan->crypto_tx_tailroom_needed_cnt += delta; in update_vlan_tailroom_need_count()
87 * 1. SKB resize was skipped because no key was added but just before in increment_tailroom_need_count()
88 * the xmit key is added and SW encryption kicks off. in increment_tailroom_need_count()
91 * just before xmit one of the key is deleted and SW encryption kicks in increment_tailroom_need_count()
101 assert_key_lock(sdata->local); in increment_tailroom_need_count()
105 if (!sdata->crypto_tx_tailroom_needed_cnt++) { in increment_tailroom_need_count()
108 * encryption at all if the count transition is from 0 -> 1. in increment_tailroom_need_count()
117 assert_key_lock(sdata->local); in decrease_tailroom_need_count()
119 WARN_ON_ONCE(sdata->crypto_tx_tailroom_needed_cnt < delta); in decrease_tailroom_need_count()
121 update_vlan_tailroom_need_count(sdata, -delta); in decrease_tailroom_need_count()
122 sdata->crypto_tx_tailroom_needed_cnt -= delta; in decrease_tailroom_need_count()
125 static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key) in ieee80211_key_enable_hw_accel() argument
127 struct ieee80211_sub_if_data *sdata = key->sdata; in ieee80211_key_enable_hw_accel()
129 int ret = -EOPNOTSUPP; in ieee80211_key_enable_hw_accel()
133 if (key->flags & KEY_FLAG_TAINTED) { in ieee80211_key_enable_hw_accel()
134 /* If we get here, it's during resume and the key is in ieee80211_key_enable_hw_accel()
141 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE && in ieee80211_key_enable_hw_accel()
142 !(key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC | in ieee80211_key_enable_hw_accel()
147 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; in ieee80211_key_enable_hw_accel()
148 return -EINVAL; in ieee80211_key_enable_hw_accel()
151 if (!key->local->ops->set_key) in ieee80211_key_enable_hw_accel()
154 assert_key_lock(key->local); in ieee80211_key_enable_hw_accel()
156 sta = key->sta; in ieee80211_key_enable_hw_accel()
159 * If this is a per-STA GTK, check if it in ieee80211_key_enable_hw_accel()
162 if (sta && !(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE) && in ieee80211_key_enable_hw_accel()
163 !ieee80211_hw_check(&key->local->hw, SUPPORTS_PER_STA_GTK)) in ieee80211_key_enable_hw_accel()
166 if (sta && !sta->uploaded) in ieee80211_key_enable_hw_accel()
169 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_key_enable_hw_accel()
174 if (!(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE)) { in ieee80211_key_enable_hw_accel()
180 if (key->conf.link_id >= 0 && sdata->vif.active_links && in ieee80211_key_enable_hw_accel()
181 !(sdata->vif.active_links & BIT(key->conf.link_id))) in ieee80211_key_enable_hw_accel()
184 ret = drv_set_key(key->local, SET_KEY, sdata, in ieee80211_key_enable_hw_accel()
185 sta ? &sta->sta : NULL, &key->conf); in ieee80211_key_enable_hw_accel()
188 key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE; in ieee80211_key_enable_hw_accel()
190 if (!(key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC | in ieee80211_key_enable_hw_accel()
195 WARN_ON((key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE) && in ieee80211_key_enable_hw_accel()
196 (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)); in ieee80211_key_enable_hw_accel()
198 WARN_ON((key->conf.flags & IEEE80211_KEY_FLAG_PUT_MIC_SPACE) && in ieee80211_key_enable_hw_accel()
199 (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC)); in ieee80211_key_enable_hw_accel()
204 if (ret != -ENOSPC && ret != -EOPNOTSUPP && ret != 1) in ieee80211_key_enable_hw_accel()
206 "failed to set key (%d, %pM) to hardware (%d)\n", in ieee80211_key_enable_hw_accel()
207 key->conf.keyidx, in ieee80211_key_enable_hw_accel()
208 sta ? sta->sta.addr : bcast_addr, ret); in ieee80211_key_enable_hw_accel()
211 switch (key->conf.cipher) { in ieee80211_key_enable_hw_accel()
223 /* all of these we can do in software - if driver can */ in ieee80211_key_enable_hw_accel()
226 if (ieee80211_hw_check(&key->local->hw, SW_CRYPTO_CONTROL)) in ieee80211_key_enable_hw_accel()
227 return -EINVAL; in ieee80211_key_enable_hw_accel()
230 return -EINVAL; in ieee80211_key_enable_hw_accel()
234 static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key) in ieee80211_key_disable_hw_accel() argument
242 if (!key || !key->local->ops->set_key) in ieee80211_key_disable_hw_accel()
245 assert_key_lock(key->local); in ieee80211_key_disable_hw_accel()
247 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) in ieee80211_key_disable_hw_accel()
250 sta = key->sta; in ieee80211_key_disable_hw_accel()
251 sdata = key->sdata; in ieee80211_key_disable_hw_accel()
253 if (key->conf.link_id >= 0 && sdata->vif.active_links && in ieee80211_key_disable_hw_accel()
254 !(sdata->vif.active_links & BIT(key->conf.link_id))) in ieee80211_key_disable_hw_accel()
257 if (!(key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC | in ieee80211_key_disable_hw_accel()
262 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; in ieee80211_key_disable_hw_accel()
263 ret = drv_set_key(key->local, DISABLE_KEY, sdata, in ieee80211_key_disable_hw_accel()
264 sta ? &sta->sta : NULL, &key->conf); in ieee80211_key_disable_hw_accel()
268 "failed to remove key (%d, %pM) from hardware (%d)\n", in ieee80211_key_disable_hw_accel()
269 key->conf.keyidx, in ieee80211_key_disable_hw_accel()
270 sta ? sta->sta.addr : bcast_addr, ret); in ieee80211_key_disable_hw_accel()
273 static int _ieee80211_set_tx_key(struct ieee80211_key *key, bool force) in _ieee80211_set_tx_key() argument
275 struct sta_info *sta = key->sta; in _ieee80211_set_tx_key()
276 struct ieee80211_local *local = key->local; in _ieee80211_set_tx_key()
282 sta->ptk_idx = key->conf.keyidx; in _ieee80211_set_tx_key()
284 if (force || !ieee80211_hw_check(&local->hw, AMPDU_KEYBORDER_SUPPORT)) in _ieee80211_set_tx_key()
291 int ieee80211_set_tx_key(struct ieee80211_key *key) in ieee80211_set_tx_key() argument
293 return _ieee80211_set_tx_key(key, false); in ieee80211_set_tx_key()
299 struct ieee80211_local *local = new->local; in ieee80211_pairwise_rekey()
300 struct sta_info *sta = new->sta; in ieee80211_pairwise_rekey()
305 if (new->conf.flags & IEEE80211_KEY_FLAG_NO_AUTO_TX) { in ieee80211_pairwise_rekey()
306 /* Extended Key ID key install, initial one or rekey */ in ieee80211_pairwise_rekey()
308 if (sta->ptk_idx != INVALID_PTK_KEYIDX && in ieee80211_pairwise_rekey()
309 !ieee80211_hw_check(&local->hw, AMPDU_KEYBORDER_SUPPORT)) { in ieee80211_pairwise_rekey()
310 /* Aggregation Sessions with Extended Key ID must not in ieee80211_pairwise_rekey()
311 * mix MPDUs with different keyIDs within one A-MPDU. in ieee80211_pairwise_rekey()
314 * ensure there are no A-MPDUs when the driver is not in ieee80211_pairwise_rekey()
315 * supporting A-MPDU key borders. (Blocking Tx only in ieee80211_pairwise_rekey()
320 mutex_lock(&sta->ampdu_mlme.mtx); in ieee80211_pairwise_rekey()
324 mutex_unlock(&sta->ampdu_mlme.mtx); in ieee80211_pairwise_rekey()
327 /* Rekey without Extended Key ID. in ieee80211_pairwise_rekey()
332 if (!(old->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) in ieee80211_pairwise_rekey()
335 /* Stop Tx till we are on the new key */ in ieee80211_pairwise_rekey()
336 old->flags |= KEY_FLAG_TAINTED; in ieee80211_pairwise_rekey()
338 if (ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION)) { in ieee80211_pairwise_rekey()
343 if (!wiphy_ext_feature_isset(local->hw.wiphy, in ieee80211_pairwise_rekey()
346 sta->sta.addr); in ieee80211_pairwise_rekey()
350 ieee80211_flush_queues(local, old->sdata, false); in ieee80211_pairwise_rekey()
358 struct ieee80211_sub_if_data *sdata = link->sdata; in __ieee80211_set_default_key()
359 struct ieee80211_key *key = NULL; in __ieee80211_set_default_key() local
361 assert_key_lock(sdata->local); in __ieee80211_set_default_key()
364 key = key_mtx_dereference(sdata->local, sdata->keys[idx]); in __ieee80211_set_default_key()
365 if (!key) in __ieee80211_set_default_key()
366 key = key_mtx_dereference(sdata->local, link->gtk[idx]); in __ieee80211_set_default_key()
370 rcu_assign_pointer(sdata->default_unicast_key, key); in __ieee80211_set_default_key()
372 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN) in __ieee80211_set_default_key()
373 drv_set_default_unicast_key(sdata->local, sdata, idx); in __ieee80211_set_default_key()
377 rcu_assign_pointer(link->default_multicast_key, key); in __ieee80211_set_default_key()
385 mutex_lock(&link->sdata->local->key_mtx); in ieee80211_set_default_key()
387 mutex_unlock(&link->sdata->local->key_mtx); in ieee80211_set_default_key()
393 struct ieee80211_sub_if_data *sdata = link->sdata; in __ieee80211_set_default_mgmt_key()
394 struct ieee80211_key *key = NULL; in __ieee80211_set_default_mgmt_key() local
396 assert_key_lock(sdata->local); in __ieee80211_set_default_mgmt_key()
400 key = key_mtx_dereference(sdata->local, link->gtk[idx]); in __ieee80211_set_default_mgmt_key()
402 rcu_assign_pointer(link->default_mgmt_key, key); in __ieee80211_set_default_mgmt_key()
410 mutex_lock(&link->sdata->local->key_mtx); in ieee80211_set_default_mgmt_key()
412 mutex_unlock(&link->sdata->local->key_mtx); in ieee80211_set_default_mgmt_key()
418 struct ieee80211_sub_if_data *sdata = link->sdata; in __ieee80211_set_default_beacon_key()
419 struct ieee80211_key *key = NULL; in __ieee80211_set_default_beacon_key() local
421 assert_key_lock(sdata->local); in __ieee80211_set_default_beacon_key()
426 key = key_mtx_dereference(sdata->local, link->gtk[idx]); in __ieee80211_set_default_beacon_key()
428 rcu_assign_pointer(link->default_beacon_key, key); in __ieee80211_set_default_beacon_key()
436 mutex_lock(&link->sdata->local->key_mtx); in ieee80211_set_default_beacon_key()
438 mutex_unlock(&link->sdata->local->key_mtx); in ieee80211_set_default_beacon_key()
448 struct link_sta_info *link_sta = sta ? &sta->deflink : NULL; in ieee80211_key_replace()
460 idx = new->conf.keyidx; in ieee80211_key_replace()
461 is_wep = new->conf.cipher == WLAN_CIPHER_SUITE_WEP40 || in ieee80211_key_replace()
462 new->conf.cipher == WLAN_CIPHER_SUITE_WEP104; in ieee80211_key_replace()
463 link_id = new->conf.link_id; in ieee80211_key_replace()
465 idx = old->conf.keyidx; in ieee80211_key_replace()
466 is_wep = old->conf.cipher == WLAN_CIPHER_SUITE_WEP40 || in ieee80211_key_replace()
467 old->conf.cipher == WLAN_CIPHER_SUITE_WEP104; in ieee80211_key_replace()
468 link_id = old->conf.link_id; in ieee80211_key_replace()
471 if (WARN(old && old->conf.link_id != link_id, in ieee80211_key_replace()
473 old->conf.link_id, link_id)) in ieee80211_key_replace()
474 return -EINVAL; in ieee80211_key_replace()
478 link = sdata_dereference(sdata->link[link_id], sdata); in ieee80211_key_replace()
480 return -ENOLINK; in ieee80211_key_replace()
484 link_sta = rcu_dereference_protected(sta->link[link_id], in ieee80211_key_replace()
485 lockdep_is_held(&sta->local->sta_mtx)); in ieee80211_key_replace()
487 return -ENOLINK; in ieee80211_key_replace()
490 link = &sdata->deflink; in ieee80211_key_replace()
494 return -EINVAL; in ieee80211_key_replace()
496 WARN_ON(new && old && new->conf.keyidx != old->conf.keyidx); in ieee80211_key_replace()
499 /* Unicast rekey needs special handling. With Extended Key ID in ieee80211_key_replace()
506 if (old->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) { in ieee80211_key_replace()
513 if (!new->local->wowlan) { in ieee80211_key_replace()
516 assert_key_lock(new->local); in ieee80211_key_replace()
517 new->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE; in ieee80211_key_replace()
525 list_add_tail_rcu(&new->list, &sdata->key_list); in ieee80211_key_replace()
529 rcu_assign_pointer(sta->ptk[idx], new); in ieee80211_key_replace()
531 !(new->conf.flags & IEEE80211_KEY_FLAG_NO_AUTO_TX)) in ieee80211_key_replace()
534 rcu_assign_pointer(link_sta->gtk[idx], new); in ieee80211_key_replace()
536 /* Only needed for transition from no key -> key. in ieee80211_key_replace()
537 * Still triggers unnecessary when using Extended Key ID in ieee80211_key_replace()
538 * and installing the second key ID the first time. in ieee80211_key_replace()
544 old == key_mtx_dereference(sdata->local, in ieee80211_key_replace()
545 sdata->default_unicast_key); in ieee80211_key_replace()
547 old == key_mtx_dereference(sdata->local, in ieee80211_key_replace()
548 link->default_multicast_key); in ieee80211_key_replace()
550 old == key_mtx_dereference(sdata->local, in ieee80211_key_replace()
551 link->default_mgmt_key); in ieee80211_key_replace()
553 old == key_mtx_dereference(sdata->local, in ieee80211_key_replace()
554 link->default_beacon_key); in ieee80211_key_replace()
557 __ieee80211_set_default_key(link, -1, true, false); in ieee80211_key_replace()
559 __ieee80211_set_default_key(link, -1, false, true); in ieee80211_key_replace()
561 __ieee80211_set_default_mgmt_key(link, -1); in ieee80211_key_replace()
563 __ieee80211_set_default_beacon_key(link, -1); in ieee80211_key_replace()
566 rcu_assign_pointer(sdata->keys[idx], new); in ieee80211_key_replace()
568 rcu_assign_pointer(link->gtk[idx], new); in ieee80211_key_replace()
571 __ieee80211_set_default_key(link, new->conf.keyidx, in ieee80211_key_replace()
574 __ieee80211_set_default_key(link, new->conf.keyidx, in ieee80211_key_replace()
578 new->conf.keyidx); in ieee80211_key_replace()
581 new->conf.keyidx); in ieee80211_key_replace()
585 list_del_rcu(&old->list); in ieee80211_key_replace()
595 struct ieee80211_key *key; in ieee80211_key_alloc() local
601 return ERR_PTR(-EINVAL); in ieee80211_key_alloc()
603 key = kzalloc(sizeof(struct ieee80211_key) + key_len, GFP_KERNEL); in ieee80211_key_alloc()
604 if (!key) in ieee80211_key_alloc()
605 return ERR_PTR(-ENOMEM); in ieee80211_key_alloc()
609 * key to the hardware if possible. in ieee80211_key_alloc()
611 key->conf.flags = 0; in ieee80211_key_alloc()
612 key->flags = 0; in ieee80211_key_alloc()
614 key->conf.link_id = -1; in ieee80211_key_alloc()
615 key->conf.cipher = cipher; in ieee80211_key_alloc()
616 key->conf.keyidx = idx; in ieee80211_key_alloc()
617 key->conf.keylen = key_len; in ieee80211_key_alloc()
621 key->conf.iv_len = IEEE80211_WEP_IV_LEN; in ieee80211_key_alloc()
622 key->conf.icv_len = IEEE80211_WEP_ICV_LEN; in ieee80211_key_alloc()
625 key->conf.iv_len = IEEE80211_TKIP_IV_LEN; in ieee80211_key_alloc()
626 key->conf.icv_len = IEEE80211_TKIP_ICV_LEN; in ieee80211_key_alloc()
629 key->u.tkip.rx[i].iv32 = in ieee80211_key_alloc()
631 key->u.tkip.rx[i].iv16 = in ieee80211_key_alloc()
635 spin_lock_init(&key->u.tkip.txlock); in ieee80211_key_alloc()
638 key->conf.iv_len = IEEE80211_CCMP_HDR_LEN; in ieee80211_key_alloc()
639 key->conf.icv_len = IEEE80211_CCMP_MIC_LEN; in ieee80211_key_alloc()
643 key->u.ccmp.rx_pn[i][j] = in ieee80211_key_alloc()
644 seq[IEEE80211_CCMP_PN_LEN - j - 1]; in ieee80211_key_alloc()
647 * Initialize AES key state here as an optimization so that in ieee80211_key_alloc()
650 key->u.ccmp.tfm = ieee80211_aes_key_setup_encrypt( in ieee80211_key_alloc()
652 if (IS_ERR(key->u.ccmp.tfm)) { in ieee80211_key_alloc()
653 err = PTR_ERR(key->u.ccmp.tfm); in ieee80211_key_alloc()
654 kfree(key); in ieee80211_key_alloc()
659 key->conf.iv_len = IEEE80211_CCMP_256_HDR_LEN; in ieee80211_key_alloc()
660 key->conf.icv_len = IEEE80211_CCMP_256_MIC_LEN; in ieee80211_key_alloc()
663 key->u.ccmp.rx_pn[i][j] = in ieee80211_key_alloc()
664 seq[IEEE80211_CCMP_256_PN_LEN - j - 1]; in ieee80211_key_alloc()
665 /* Initialize AES key state here as an optimization so that in ieee80211_key_alloc()
668 key->u.ccmp.tfm = ieee80211_aes_key_setup_encrypt( in ieee80211_key_alloc()
670 if (IS_ERR(key->u.ccmp.tfm)) { in ieee80211_key_alloc()
671 err = PTR_ERR(key->u.ccmp.tfm); in ieee80211_key_alloc()
672 kfree(key); in ieee80211_key_alloc()
678 key->conf.iv_len = 0; in ieee80211_key_alloc()
680 key->conf.icv_len = sizeof(struct ieee80211_mmie); in ieee80211_key_alloc()
682 key->conf.icv_len = sizeof(struct ieee80211_mmie_16); in ieee80211_key_alloc()
685 key->u.aes_cmac.rx_pn[j] = in ieee80211_key_alloc()
686 seq[IEEE80211_CMAC_PN_LEN - j - 1]; in ieee80211_key_alloc()
688 * Initialize AES key state here as an optimization so that in ieee80211_key_alloc()
691 key->u.aes_cmac.tfm = in ieee80211_key_alloc()
693 if (IS_ERR(key->u.aes_cmac.tfm)) { in ieee80211_key_alloc()
694 err = PTR_ERR(key->u.aes_cmac.tfm); in ieee80211_key_alloc()
695 kfree(key); in ieee80211_key_alloc()
701 key->conf.iv_len = 0; in ieee80211_key_alloc()
702 key->conf.icv_len = sizeof(struct ieee80211_mmie_16); in ieee80211_key_alloc()
705 key->u.aes_gmac.rx_pn[j] = in ieee80211_key_alloc()
706 seq[IEEE80211_GMAC_PN_LEN - j - 1]; in ieee80211_key_alloc()
707 /* Initialize AES key state here as an optimization so that in ieee80211_key_alloc()
710 key->u.aes_gmac.tfm = in ieee80211_key_alloc()
712 if (IS_ERR(key->u.aes_gmac.tfm)) { in ieee80211_key_alloc()
713 err = PTR_ERR(key->u.aes_gmac.tfm); in ieee80211_key_alloc()
714 kfree(key); in ieee80211_key_alloc()
720 key->conf.iv_len = IEEE80211_GCMP_HDR_LEN; in ieee80211_key_alloc()
721 key->conf.icv_len = IEEE80211_GCMP_MIC_LEN; in ieee80211_key_alloc()
724 key->u.gcmp.rx_pn[i][j] = in ieee80211_key_alloc()
725 seq[IEEE80211_GCMP_PN_LEN - j - 1]; in ieee80211_key_alloc()
726 /* Initialize AES key state here as an optimization so that in ieee80211_key_alloc()
729 key->u.gcmp.tfm = ieee80211_aes_gcm_key_setup_encrypt(key_data, in ieee80211_key_alloc()
731 if (IS_ERR(key->u.gcmp.tfm)) { in ieee80211_key_alloc()
732 err = PTR_ERR(key->u.gcmp.tfm); in ieee80211_key_alloc()
733 kfree(key); in ieee80211_key_alloc()
738 memcpy(key->conf.key, key_data, key_len); in ieee80211_key_alloc()
739 INIT_LIST_HEAD(&key->list); in ieee80211_key_alloc()
741 return key; in ieee80211_key_alloc()
744 static void ieee80211_key_free_common(struct ieee80211_key *key) in ieee80211_key_free_common() argument
746 switch (key->conf.cipher) { in ieee80211_key_free_common()
749 ieee80211_aes_key_free(key->u.ccmp.tfm); in ieee80211_key_free_common()
753 ieee80211_aes_cmac_key_free(key->u.aes_cmac.tfm); in ieee80211_key_free_common()
757 ieee80211_aes_gmac_key_free(key->u.aes_gmac.tfm); in ieee80211_key_free_common()
761 ieee80211_aes_gcm_key_free(key->u.gcmp.tfm); in ieee80211_key_free_common()
764 kfree_sensitive(key); in ieee80211_key_free_common()
767 static void __ieee80211_key_destroy(struct ieee80211_key *key, in __ieee80211_key_destroy() argument
770 if (key->local) { in __ieee80211_key_destroy()
771 struct ieee80211_sub_if_data *sdata = key->sdata; in __ieee80211_key_destroy()
773 ieee80211_debugfs_key_remove(key); in __ieee80211_key_destroy()
777 sdata->crypto_tx_tailroom_pending_dec++; in __ieee80211_key_destroy()
778 schedule_delayed_work(&sdata->dec_tailroom_needed_wk, in __ieee80211_key_destroy()
785 ieee80211_key_free_common(key); in __ieee80211_key_destroy()
788 static void ieee80211_key_destroy(struct ieee80211_key *key, in ieee80211_key_destroy() argument
791 if (!key) in ieee80211_key_destroy()
795 * Synchronize so the TX path and rcu key iterators in ieee80211_key_destroy()
796 * can no longer be using this key before we free/remove it. in ieee80211_key_destroy()
800 __ieee80211_key_destroy(key, delay_tailroom); in ieee80211_key_destroy()
803 void ieee80211_key_free_unused(struct ieee80211_key *key) in ieee80211_key_free_unused() argument
805 if (!key) in ieee80211_key_free_unused()
808 WARN_ON(key->sdata || key->local); in ieee80211_key_free_unused()
809 ieee80211_key_free_common(key); in ieee80211_key_free_unused()
819 if (!old || new->conf.keylen != old->conf.keylen) in ieee80211_key_identical()
822 tk_old = old->conf.key; in ieee80211_key_identical()
823 tk_new = new->conf.key; in ieee80211_key_identical()
826 * In station mode, don't compare the TX MIC key, as it's never used in ieee80211_key_identical()
830 if (sdata->vif.type == NL80211_IFTYPE_STATION && in ieee80211_key_identical()
831 new->conf.cipher == WLAN_CIPHER_SUITE_TKIP && in ieee80211_key_identical()
832 new->conf.keylen == WLAN_KEY_LEN_TKIP && in ieee80211_key_identical()
833 !(new->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE)) { in ieee80211_key_identical()
842 return !crypto_memneq(tk_old, tk_new, new->conf.keylen); in ieee80211_key_identical()
845 int ieee80211_key_link(struct ieee80211_key *key, in ieee80211_key_link() argument
849 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_key_link()
852 int idx = key->conf.keyidx; in ieee80211_key_link()
853 bool pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE; in ieee80211_key_link()
855 * We want to delay tailroom updates only for station - in that in ieee80211_key_link()
859 bool delay_tailroom = sdata->vif.type == NL80211_IFTYPE_STATION; in ieee80211_key_link()
862 mutex_lock(&sdata->local->key_mtx); in ieee80211_key_link()
867 old_key = key_mtx_dereference(sdata->local, sta->ptk[idx]); in ieee80211_key_link()
868 alt_key = key_mtx_dereference(sdata->local, sta->ptk[idx ^ 1]); in ieee80211_key_link()
870 /* The rekey code assumes that the old and new key are using in ieee80211_key_link()
873 if ((alt_key && alt_key->conf.cipher != key->conf.cipher) || in ieee80211_key_link()
874 (old_key && old_key->conf.cipher != key->conf.cipher)) { in ieee80211_key_link()
875 ret = -EOPNOTSUPP; in ieee80211_key_link()
879 struct link_sta_info *link_sta = &sta->deflink; in ieee80211_key_link()
880 int link_id = key->conf.link_id; in ieee80211_key_link()
883 link_sta = rcu_dereference_protected(sta->link[link_id], in ieee80211_key_link()
884 lockdep_is_held(&sta->local->sta_mtx)); in ieee80211_key_link()
886 ret = -ENOLINK; in ieee80211_key_link()
891 old_key = key_mtx_dereference(sdata->local, link_sta->gtk[idx]); in ieee80211_key_link()
894 old_key = key_mtx_dereference(sdata->local, in ieee80211_key_link()
895 sdata->keys[idx]); in ieee80211_key_link()
897 old_key = key_mtx_dereference(sdata->local, 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()
930 ret = ieee80211_key_replace(sdata, link, sta, pairwise, old_key, key); in ieee80211_key_link()
933 ieee80211_debugfs_key_add(key); in ieee80211_key_link()
936 ieee80211_key_free(key, delay_tailroom); in ieee80211_key_link()
939 key = NULL; in ieee80211_key_link()
942 ieee80211_key_free_unused(key); in ieee80211_key_link()
943 mutex_unlock(&sdata->local->key_mtx); in ieee80211_key_link()
948 void ieee80211_key_free(struct ieee80211_key *key, bool delay_tailroom) in ieee80211_key_free() argument
950 if (!key) in ieee80211_key_free()
954 * Replace key with nothingness if it was ever used. in ieee80211_key_free()
956 if (key->sdata) in ieee80211_key_free()
957 ieee80211_key_replace(key->sdata, NULL, key->sta, in ieee80211_key_free()
958 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, in ieee80211_key_free()
959 key, NULL); in ieee80211_key_free()
960 ieee80211_key_destroy(key, delay_tailroom); in ieee80211_key_free()
965 struct ieee80211_key *key; in ieee80211_reenable_keys() local
968 lockdep_assert_wiphy(sdata->local->hw.wiphy); in ieee80211_reenable_keys()
970 mutex_lock(&sdata->local->key_mtx); 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()
989 mutex_unlock(&sdata->local->key_mtx); in ieee80211_reenable_keys()
995 struct ieee80211_key *key, in ieee80211_key_iter() argument
999 struct ieee80211_key_conf *key, in ieee80211_key_iter() argument
1004 if (key->sta && key->sta->removed) in ieee80211_key_iter()
1006 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) in ieee80211_key_iter()
1008 iter(hw, vif, key->sta ? &key->sta->sta : NULL, in ieee80211_key_iter()
1009 &key->conf, iter_data); in ieee80211_key_iter()
1017 struct ieee80211_key_conf *key, in ieee80211_iter_keys() argument
1022 struct ieee80211_key *key, *tmp; in ieee80211_iter_keys() local
1025 lockdep_assert_wiphy(hw->wiphy); in ieee80211_iter_keys()
1027 mutex_lock(&local->key_mtx); in ieee80211_iter_keys()
1030 list_for_each_entry_safe(key, tmp, &sdata->key_list, list) in ieee80211_iter_keys()
1031 ieee80211_key_iter(hw, vif, key, iter, iter_data); in ieee80211_iter_keys()
1033 list_for_each_entry(sdata, &local->interfaces, list) in ieee80211_iter_keys()
1034 list_for_each_entry_safe(key, tmp, in ieee80211_iter_keys()
1035 &sdata->key_list, list) in ieee80211_iter_keys()
1036 ieee80211_key_iter(hw, &sdata->vif, key, in ieee80211_iter_keys()
1039 mutex_unlock(&local->key_mtx); in ieee80211_iter_keys()
1049 struct ieee80211_key_conf *key, in _ieee80211_iter_keys_rcu() argument
1053 struct ieee80211_key *key; in _ieee80211_iter_keys_rcu() local
1055 list_for_each_entry_rcu(key, &sdata->key_list, list) in _ieee80211_iter_keys_rcu()
1056 ieee80211_key_iter(hw, &sdata->vif, key, iter, iter_data); in _ieee80211_iter_keys_rcu()
1064 struct ieee80211_key_conf *key, in ieee80211_iter_keys_rcu() argument
1075 list_for_each_entry_rcu(sdata, &local->interfaces, list) in ieee80211_iter_keys_rcu()
1084 struct ieee80211_key *key, *tmp; in ieee80211_free_keys_iface() local
1087 sdata->crypto_tx_tailroom_pending_dec); in ieee80211_free_keys_iface()
1088 sdata->crypto_tx_tailroom_pending_dec = 0; in ieee80211_free_keys_iface()
1093 list_for_each_entry_safe(key, tmp, &sdata->key_list, list) { in ieee80211_free_keys_iface()
1094 ieee80211_key_replace(key->sdata, NULL, key->sta, in ieee80211_free_keys_iface()
1095 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, in ieee80211_free_keys_iface()
1096 key, NULL); in ieee80211_free_keys_iface()
1097 list_add_tail(&key->list, keys); in ieee80211_free_keys_iface()
1106 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_remove_link_keys()
1107 struct ieee80211_local *local = sdata->local; in ieee80211_remove_link_keys()
1108 struct ieee80211_key *key, *tmp; in ieee80211_remove_link_keys() local
1110 mutex_lock(&local->key_mtx); in ieee80211_remove_link_keys()
1111 list_for_each_entry_safe(key, tmp, &sdata->key_list, list) { in ieee80211_remove_link_keys()
1112 if (key->conf.link_id != link->link_id) in ieee80211_remove_link_keys()
1114 ieee80211_key_replace(key->sdata, link, key->sta, in ieee80211_remove_link_keys()
1115 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, in ieee80211_remove_link_keys()
1116 key, NULL); in ieee80211_remove_link_keys()
1117 list_add_tail(&key->list, keys); in ieee80211_remove_link_keys()
1119 mutex_unlock(&local->key_mtx); in ieee80211_remove_link_keys()
1125 struct ieee80211_key *key, *tmp; in ieee80211_free_key_list() local
1127 mutex_lock(&local->key_mtx); in ieee80211_free_key_list()
1128 list_for_each_entry_safe(key, tmp, keys, list) in ieee80211_free_key_list()
1129 __ieee80211_key_destroy(key, false); in ieee80211_free_key_list()
1130 mutex_unlock(&local->key_mtx); in ieee80211_free_key_list()
1136 struct ieee80211_local *local = sdata->local; in ieee80211_free_keys()
1139 struct ieee80211_key *key, *tmp; in ieee80211_free_keys() local
1142 cancel_delayed_work_sync(&sdata->dec_tailroom_needed_wk); in ieee80211_free_keys()
1144 mutex_lock(&local->key_mtx); in ieee80211_free_keys()
1148 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_free_keys()
1149 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) in ieee80211_free_keys()
1155 list_for_each_entry_safe(key, tmp, &keys, list) in ieee80211_free_keys()
1156 __ieee80211_key_destroy(key, false); in ieee80211_free_keys()
1158 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_free_keys()
1159 if (sdata->bss) { in ieee80211_free_keys()
1160 master = container_of(sdata->bss, in ieee80211_free_keys()
1164 WARN_ON_ONCE(sdata->crypto_tx_tailroom_needed_cnt != in ieee80211_free_keys()
1165 master->crypto_tx_tailroom_needed_cnt); in ieee80211_free_keys()
1168 WARN_ON_ONCE(sdata->crypto_tx_tailroom_needed_cnt || in ieee80211_free_keys()
1169 sdata->crypto_tx_tailroom_pending_dec); in ieee80211_free_keys()
1172 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_free_keys()
1173 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) in ieee80211_free_keys()
1174 WARN_ON_ONCE(vlan->crypto_tx_tailroom_needed_cnt || in ieee80211_free_keys()
1175 vlan->crypto_tx_tailroom_pending_dec); in ieee80211_free_keys()
1178 mutex_unlock(&local->key_mtx); in ieee80211_free_keys()
1184 struct ieee80211_key *key; in ieee80211_free_sta_keys() local
1187 mutex_lock(&local->key_mtx); in ieee80211_free_sta_keys()
1188 for (i = 0; i < ARRAY_SIZE(sta->deflink.gtk); i++) { in ieee80211_free_sta_keys()
1189 key = key_mtx_dereference(local, sta->deflink.gtk[i]); in ieee80211_free_sta_keys()
1190 if (!key) in ieee80211_free_sta_keys()
1192 ieee80211_key_replace(key->sdata, NULL, key->sta, in ieee80211_free_sta_keys()
1193 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, in ieee80211_free_sta_keys()
1194 key, NULL); in ieee80211_free_sta_keys()
1195 __ieee80211_key_destroy(key, key->sdata->vif.type == in ieee80211_free_sta_keys()
1200 key = key_mtx_dereference(local, sta->ptk[i]); in ieee80211_free_sta_keys()
1201 if (!key) in ieee80211_free_sta_keys()
1203 ieee80211_key_replace(key->sdata, NULL, key->sta, in ieee80211_free_sta_keys()
1204 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, in ieee80211_free_sta_keys()
1205 key, NULL); in ieee80211_free_sta_keys()
1206 __ieee80211_key_destroy(key, key->sdata->vif.type == in ieee80211_free_sta_keys()
1210 mutex_unlock(&local->key_mtx); in ieee80211_free_sta_keys()
1223 * and then new keys are installed. The first new key causes the in ieee80211_delayed_tailroom_dec()
1227 * key removal for a while, so if we roam the value is larger than in ieee80211_delayed_tailroom_dec()
1228 * zero and no 0->1 transition happens. in ieee80211_delayed_tailroom_dec()
1236 mutex_lock(&sdata->local->key_mtx); in ieee80211_delayed_tailroom_dec()
1238 sdata->crypto_tx_tailroom_pending_dec); in ieee80211_delayed_tailroom_dec()
1239 sdata->crypto_tx_tailroom_pending_dec = 0; in ieee80211_delayed_tailroom_dec()
1240 mutex_unlock(&sdata->local->key_mtx); in ieee80211_delayed_tailroom_dec()
1250 cfg80211_gtk_rekey_notify(sdata->dev, bssid, replay_ctr, gfp); in ieee80211_gtk_rekey_notify()
1257 struct ieee80211_key *key; in ieee80211_get_key_rx_seq() local
1260 key = container_of(keyconf, struct ieee80211_key, conf); in ieee80211_get_key_rx_seq()
1262 switch (key->conf.cipher) { in ieee80211_get_key_rx_seq()
1266 seq->tkip.iv32 = key->u.tkip.rx[tid].iv32; in ieee80211_get_key_rx_seq()
1267 seq->tkip.iv16 = key->u.tkip.rx[tid].iv16; in ieee80211_get_key_rx_seq()
1271 if (WARN_ON(tid < -1 || tid >= IEEE80211_NUM_TIDS)) in ieee80211_get_key_rx_seq()
1274 pn = key->u.ccmp.rx_pn[IEEE80211_NUM_TIDS]; in ieee80211_get_key_rx_seq()
1276 pn = key->u.ccmp.rx_pn[tid]; in ieee80211_get_key_rx_seq()
1277 memcpy(seq->ccmp.pn, pn, IEEE80211_CCMP_PN_LEN); in ieee80211_get_key_rx_seq()
1283 pn = key->u.aes_cmac.rx_pn; in ieee80211_get_key_rx_seq()
1284 memcpy(seq->aes_cmac.pn, pn, IEEE80211_CMAC_PN_LEN); in ieee80211_get_key_rx_seq()
1290 pn = key->u.aes_gmac.rx_pn; in ieee80211_get_key_rx_seq()
1291 memcpy(seq->aes_gmac.pn, pn, IEEE80211_GMAC_PN_LEN); in ieee80211_get_key_rx_seq()
1295 if (WARN_ON(tid < -1 || tid >= IEEE80211_NUM_TIDS)) in ieee80211_get_key_rx_seq()
1298 pn = key->u.gcmp.rx_pn[IEEE80211_NUM_TIDS]; in ieee80211_get_key_rx_seq()
1300 pn = key->u.gcmp.rx_pn[tid]; in ieee80211_get_key_rx_seq()
1301 memcpy(seq->gcmp.pn, pn, IEEE80211_GCMP_PN_LEN); in ieee80211_get_key_rx_seq()
1310 struct ieee80211_key *key; in ieee80211_set_key_rx_seq() local
1313 key = container_of(keyconf, struct ieee80211_key, conf); in ieee80211_set_key_rx_seq()
1315 switch (key->conf.cipher) { in ieee80211_set_key_rx_seq()
1319 key->u.tkip.rx[tid].iv32 = seq->tkip.iv32; in ieee80211_set_key_rx_seq()
1320 key->u.tkip.rx[tid].iv16 = seq->tkip.iv16; in ieee80211_set_key_rx_seq()
1324 if (WARN_ON(tid < -1 || tid >= IEEE80211_NUM_TIDS)) in ieee80211_set_key_rx_seq()
1327 pn = key->u.ccmp.rx_pn[IEEE80211_NUM_TIDS]; in ieee80211_set_key_rx_seq()
1329 pn = key->u.ccmp.rx_pn[tid]; in ieee80211_set_key_rx_seq()
1330 memcpy(pn, seq->ccmp.pn, IEEE80211_CCMP_PN_LEN); in ieee80211_set_key_rx_seq()
1336 pn = key->u.aes_cmac.rx_pn; in ieee80211_set_key_rx_seq()
1337 memcpy(pn, seq->aes_cmac.pn, IEEE80211_CMAC_PN_LEN); in ieee80211_set_key_rx_seq()
1343 pn = key->u.aes_gmac.rx_pn; in ieee80211_set_key_rx_seq()
1344 memcpy(pn, seq->aes_gmac.pn, IEEE80211_GMAC_PN_LEN); in ieee80211_set_key_rx_seq()
1348 if (WARN_ON(tid < -1 || tid >= IEEE80211_NUM_TIDS)) in ieee80211_set_key_rx_seq()
1351 pn = key->u.gcmp.rx_pn[IEEE80211_NUM_TIDS]; in ieee80211_set_key_rx_seq()
1353 pn = key->u.gcmp.rx_pn[tid]; in ieee80211_set_key_rx_seq()
1354 memcpy(pn, seq->gcmp.pn, IEEE80211_GCMP_PN_LEN); in ieee80211_set_key_rx_seq()
1365 struct ieee80211_key *key; in ieee80211_remove_key() local
1367 key = container_of(keyconf, struct ieee80211_key, conf); in ieee80211_remove_key()
1369 assert_key_lock(key->local); in ieee80211_remove_key()
1372 * if key was uploaded, we assume the driver will/has remove(d) in ieee80211_remove_key()
1375 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) { in ieee80211_remove_key()
1376 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; in ieee80211_remove_key()
1378 if (!(key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC | in ieee80211_remove_key()
1381 increment_tailroom_need_count(key->sdata); in ieee80211_remove_key()
1384 ieee80211_key_free(key, false); in ieee80211_remove_key()
1393 struct ieee80211_local *local = sdata->local; in ieee80211_gtk_rekey_add()
1394 struct ieee80211_key *key; in ieee80211_gtk_rekey_add() local
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()
1413 err = ieee80211_key_link(key, &sdata->deflink, NULL); in ieee80211_gtk_rekey_add()
1417 return &key->conf; in ieee80211_gtk_rekey_add()
1423 struct ieee80211_key *key; in ieee80211_key_mic_failure() local
1425 key = container_of(keyconf, struct ieee80211_key, conf); in ieee80211_key_mic_failure()
1427 switch (key->conf.cipher) { in ieee80211_key_mic_failure()
1430 key->u.aes_cmac.icverrors++; in ieee80211_key_mic_failure()
1434 key->u.aes_gmac.icverrors++; in ieee80211_key_mic_failure()
1445 struct ieee80211_key *key; in ieee80211_key_replay() local
1447 key = container_of(keyconf, struct ieee80211_key, conf); in ieee80211_key_replay()
1449 switch (key->conf.cipher) { in ieee80211_key_replay()
1452 key->u.ccmp.replays++; in ieee80211_key_replay()
1456 key->u.aes_cmac.replays++; in ieee80211_key_replay()
1460 key->u.aes_gmac.replays++; in ieee80211_key_replay()
1464 key->u.gcmp.replays++; in ieee80211_key_replay()
1474 struct ieee80211_key *key; in ieee80211_key_switch_links() local
1477 list_for_each_entry(key, &sdata->key_list, list) { in ieee80211_key_switch_links()
1478 if (key->conf.link_id < 0 || in ieee80211_key_switch_links()
1479 !(del_links_mask & BIT(key->conf.link_id))) in ieee80211_key_switch_links()
1482 /* shouldn't happen for per-link keys */ in ieee80211_key_switch_links()
1483 WARN_ON(key->sta); in ieee80211_key_switch_links()
1485 ieee80211_key_disable_hw_accel(key); in ieee80211_key_switch_links()
1488 list_for_each_entry(key, &sdata->key_list, list) { in ieee80211_key_switch_links()
1489 if (key->conf.link_id < 0 || in ieee80211_key_switch_links()
1490 !(add_links_mask & BIT(key->conf.link_id))) in ieee80211_key_switch_links()
1493 /* shouldn't happen for per-link keys */ in ieee80211_key_switch_links()
1494 WARN_ON(key->sta); in ieee80211_key_switch_links()
1496 ret = ieee80211_key_enable_hw_accel(key); in ieee80211_key_switch_links()