Johannes Berg | 1f5a7e4 | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2002-2005, Instant802 Networks, Inc. |
| 3 | * Copyright 2005-2006, Devicescape Software, Inc. |
| 4 | * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 5 | * Copyright 2007-2008 Johannes Berg <johannes@sipsolutions.net> |
Johannes Berg | 1f5a7e4 | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | */ |
| 11 | |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 12 | #include <linux/if_ether.h> |
| 13 | #include <linux/etherdevice.h> |
| 14 | #include <linux/list.h> |
Johannes Berg | d4e46a3 | 2007-09-14 11:10:24 -0400 | [diff] [blame] | 15 | #include <linux/rcupdate.h> |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 16 | #include <linux/rtnetlink.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 17 | #include <linux/slab.h> |
Johannes Berg | 1f5a7e4 | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 18 | #include <net/mac80211.h> |
| 19 | #include "ieee80211_i.h" |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 20 | #include "driver-ops.h" |
Johannes Berg | 1f5a7e4 | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 21 | #include "debugfs_key.h" |
| 22 | #include "aes_ccm.h" |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 23 | #include "aes_cmac.h" |
Johannes Berg | 1f5a7e4 | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 24 | |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 25 | |
Johannes Berg | dbbea67 | 2008-02-26 14:34:06 +0100 | [diff] [blame] | 26 | /** |
| 27 | * DOC: Key handling basics |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 28 | * |
| 29 | * Key handling in mac80211 is done based on per-interface (sub_if_data) |
| 30 | * keys and per-station keys. Since each station belongs to an interface, |
| 31 | * each station key also belongs to that interface. |
| 32 | * |
Johannes Berg | b5c34f6 | 2011-01-03 19:51:09 +0100 | [diff] [blame] | 33 | * Hardware acceleration is done on a best-effort basis for algorithms |
| 34 | * that are implemented in software, for each key the hardware is asked |
| 35 | * to enable that key for offloading but if it cannot do that the key is |
| 36 | * simply kept for software encryption (unless it is for an algorithm |
| 37 | * that isn't implemented in software). |
| 38 | * There is currently no way of knowing whether a key is handled in SW |
| 39 | * or HW except by looking into debugfs. |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 40 | * |
Johannes Berg | b5c34f6 | 2011-01-03 19:51:09 +0100 | [diff] [blame] | 41 | * All key management is internally protected by a mutex. Within all |
| 42 | * other parts of mac80211, key references are, just as STA structure |
| 43 | * references, protected by RCU. Note, however, that some things are |
| 44 | * unprotected, namely the key->sta dereferences within the hardware |
| 45 | * acceleration functions. This means that sta_info_destroy() must |
| 46 | * remove the key which waits for an RCU grace period. |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 47 | */ |
| 48 | |
| 49 | static const u8 bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 50 | |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 51 | static void assert_key_lock(struct ieee80211_local *local) |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 52 | { |
Johannes Berg | 46a5eba | 2010-09-15 13:28:15 +0200 | [diff] [blame] | 53 | lockdep_assert_held(&local->key_mtx); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 54 | } |
| 55 | |
Johannes Berg | dc822b5 | 2008-12-29 12:55:09 +0100 | [diff] [blame] | 56 | static struct ieee80211_sta *get_sta_for_key(struct ieee80211_key *key) |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 57 | { |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 58 | if (key->sta) |
Johannes Berg | dc822b5 | 2008-12-29 12:55:09 +0100 | [diff] [blame] | 59 | return &key->sta->sta; |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 60 | |
Johannes Berg | dc822b5 | 2008-12-29 12:55:09 +0100 | [diff] [blame] | 61 | return NULL; |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 62 | } |
| 63 | |
Johannes Berg | 3ffc2a9 | 2010-08-27 14:26:52 +0300 | [diff] [blame] | 64 | static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key) |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 65 | { |
Johannes Berg | dc822b5 | 2008-12-29 12:55:09 +0100 | [diff] [blame] | 66 | struct ieee80211_sub_if_data *sdata; |
| 67 | struct ieee80211_sta *sta; |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 68 | int ret; |
| 69 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 70 | might_sleep(); |
| 71 | |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 72 | if (!key->local->ops->set_key) |
Johannes Berg | 3ffc2a9 | 2010-08-27 14:26:52 +0300 | [diff] [blame] | 73 | goto out_unsupported; |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 74 | |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 75 | assert_key_lock(key->local); |
| 76 | |
Johannes Berg | dc822b5 | 2008-12-29 12:55:09 +0100 | [diff] [blame] | 77 | sta = get_sta_for_key(key); |
| 78 | |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 79 | /* |
| 80 | * If this is a per-STA GTK, check if it |
| 81 | * is supported; if not, return. |
| 82 | */ |
| 83 | if (sta && !(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE) && |
| 84 | !(key->local->hw.flags & IEEE80211_HW_SUPPORTS_PER_STA_GTK)) |
| 85 | goto out_unsupported; |
| 86 | |
Johannes Berg | dc822b5 | 2008-12-29 12:55:09 +0100 | [diff] [blame] | 87 | sdata = key->sdata; |
Helmut Schaa | 18890d4 | 2010-11-19 08:11:01 +0100 | [diff] [blame] | 88 | if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { |
| 89 | /* |
| 90 | * The driver doesn't know anything about VLAN interfaces. |
| 91 | * Hence, don't send GTKs for VLAN interfaces to the driver. |
| 92 | */ |
| 93 | if (!(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE)) |
| 94 | goto out_unsupported; |
Johannes Berg | dc822b5 | 2008-12-29 12:55:09 +0100 | [diff] [blame] | 95 | sdata = container_of(sdata->bss, |
| 96 | struct ieee80211_sub_if_data, |
| 97 | u.ap); |
Helmut Schaa | 18890d4 | 2010-11-19 08:11:01 +0100 | [diff] [blame] | 98 | } |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 99 | |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 100 | ret = drv_set_key(key->local, SET_KEY, sdata, sta, &key->conf); |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 101 | |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 102 | if (!ret) { |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 103 | key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE; |
Yogesh Ashok Powar | aac6af5 | 2011-04-27 18:40:29 +0530 | [diff] [blame] | 104 | |
| 105 | if (!(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC)) |
| 106 | key->local->crypto_tx_tailroom_needed_cnt--; |
| 107 | |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 108 | return 0; |
| 109 | } |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 110 | |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 111 | if (ret != -ENOSPC && ret != -EOPNOTSUPP) |
Joe Perches | 0fb9a9e | 2010-08-20 16:25:38 -0700 | [diff] [blame] | 112 | wiphy_err(key->local->hw.wiphy, |
| 113 | "failed to set key (%d, %pM) to hardware (%d)\n", |
| 114 | key->conf.keyidx, sta ? sta->addr : bcast_addr, ret); |
Johannes Berg | 3ffc2a9 | 2010-08-27 14:26:52 +0300 | [diff] [blame] | 115 | |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 116 | out_unsupported: |
| 117 | switch (key->conf.cipher) { |
| 118 | case WLAN_CIPHER_SUITE_WEP40: |
| 119 | case WLAN_CIPHER_SUITE_WEP104: |
| 120 | case WLAN_CIPHER_SUITE_TKIP: |
| 121 | case WLAN_CIPHER_SUITE_CCMP: |
| 122 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 123 | /* all of these we can do in software */ |
| 124 | return 0; |
| 125 | default: |
| 126 | return -EINVAL; |
Johannes Berg | 3ffc2a9 | 2010-08-27 14:26:52 +0300 | [diff] [blame] | 127 | } |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key) |
| 131 | { |
Johannes Berg | dc822b5 | 2008-12-29 12:55:09 +0100 | [diff] [blame] | 132 | struct ieee80211_sub_if_data *sdata; |
| 133 | struct ieee80211_sta *sta; |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 134 | int ret; |
| 135 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 136 | might_sleep(); |
| 137 | |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 138 | if (!key || !key->local->ops->set_key) |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 139 | return; |
| 140 | |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 141 | assert_key_lock(key->local); |
| 142 | |
| 143 | if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 144 | return; |
| 145 | |
Johannes Berg | dc822b5 | 2008-12-29 12:55:09 +0100 | [diff] [blame] | 146 | sta = get_sta_for_key(key); |
| 147 | sdata = key->sdata; |
| 148 | |
| 149 | if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) |
| 150 | sdata = container_of(sdata->bss, |
| 151 | struct ieee80211_sub_if_data, |
| 152 | u.ap); |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 153 | |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 154 | ret = drv_set_key(key->local, DISABLE_KEY, sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 155 | sta, &key->conf); |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 156 | |
| 157 | if (ret) |
Joe Perches | 0fb9a9e | 2010-08-20 16:25:38 -0700 | [diff] [blame] | 158 | wiphy_err(key->local->hw.wiphy, |
| 159 | "failed to remove key (%d, %pM) from hardware (%d)\n", |
| 160 | key->conf.keyidx, sta ? sta->addr : bcast_addr, ret); |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 161 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 162 | key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; |
Yogesh Ashok Powar | aac6af5 | 2011-04-27 18:40:29 +0530 | [diff] [blame] | 163 | |
| 164 | if (!(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC)) |
| 165 | key->local->crypto_tx_tailroom_needed_cnt++; |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 166 | } |
| 167 | |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 168 | void ieee80211_key_removed(struct ieee80211_key_conf *key_conf) |
| 169 | { |
| 170 | struct ieee80211_key *key; |
| 171 | |
| 172 | key = container_of(key_conf, struct ieee80211_key, conf); |
| 173 | |
| 174 | might_sleep(); |
| 175 | assert_key_lock(key->local); |
| 176 | |
| 177 | key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; |
| 178 | |
| 179 | /* |
| 180 | * Flush TX path to avoid attempts to use this key |
| 181 | * after this function returns. Until then, drivers |
| 182 | * must be prepared to handle the key. |
| 183 | */ |
| 184 | synchronize_rcu(); |
| 185 | } |
| 186 | EXPORT_SYMBOL_GPL(ieee80211_key_removed); |
| 187 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 188 | static void __ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata, |
Johannes Berg | f7e0104 | 2010-12-09 19:49:02 +0100 | [diff] [blame] | 189 | int idx, bool uni, bool multi) |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 190 | { |
| 191 | struct ieee80211_key *key = NULL; |
| 192 | |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 193 | assert_key_lock(sdata->local); |
| 194 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 195 | if (idx >= 0 && idx < NUM_DEFAULT_KEYS) |
| 196 | key = sdata->keys[idx]; |
| 197 | |
Johannes Berg | f7e0104 | 2010-12-09 19:49:02 +0100 | [diff] [blame] | 198 | if (uni) |
| 199 | rcu_assign_pointer(sdata->default_unicast_key, key); |
| 200 | if (multi) |
| 201 | rcu_assign_pointer(sdata->default_multicast_key, key); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 202 | |
Johannes Berg | f7e0104 | 2010-12-09 19:49:02 +0100 | [diff] [blame] | 203 | ieee80211_debugfs_key_update_default(sdata); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 204 | } |
| 205 | |
Johannes Berg | f7e0104 | 2010-12-09 19:49:02 +0100 | [diff] [blame] | 206 | void ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata, int idx, |
| 207 | bool uni, bool multi) |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 208 | { |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 209 | mutex_lock(&sdata->local->key_mtx); |
Johannes Berg | f7e0104 | 2010-12-09 19:49:02 +0100 | [diff] [blame] | 210 | __ieee80211_set_default_key(sdata, idx, uni, multi); |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 211 | mutex_unlock(&sdata->local->key_mtx); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 212 | } |
| 213 | |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 214 | static void |
| 215 | __ieee80211_set_default_mgmt_key(struct ieee80211_sub_if_data *sdata, int idx) |
| 216 | { |
| 217 | struct ieee80211_key *key = NULL; |
| 218 | |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 219 | assert_key_lock(sdata->local); |
| 220 | |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 221 | if (idx >= NUM_DEFAULT_KEYS && |
| 222 | idx < NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS) |
| 223 | key = sdata->keys[idx]; |
| 224 | |
| 225 | rcu_assign_pointer(sdata->default_mgmt_key, key); |
| 226 | |
Johannes Berg | f7e0104 | 2010-12-09 19:49:02 +0100 | [diff] [blame] | 227 | ieee80211_debugfs_key_update_default(sdata); |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | void ieee80211_set_default_mgmt_key(struct ieee80211_sub_if_data *sdata, |
| 231 | int idx) |
| 232 | { |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 233 | mutex_lock(&sdata->local->key_mtx); |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 234 | __ieee80211_set_default_mgmt_key(sdata, idx); |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 235 | mutex_unlock(&sdata->local->key_mtx); |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 236 | } |
| 237 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 238 | |
| 239 | static void __ieee80211_key_replace(struct ieee80211_sub_if_data *sdata, |
| 240 | struct sta_info *sta, |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 241 | bool pairwise, |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 242 | struct ieee80211_key *old, |
| 243 | struct ieee80211_key *new) |
| 244 | { |
Johannes Berg | f7e0104 | 2010-12-09 19:49:02 +0100 | [diff] [blame] | 245 | int idx; |
| 246 | bool defunikey, defmultikey, defmgmtkey; |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 247 | |
| 248 | if (new) |
| 249 | list_add(&new->list, &sdata->key_list); |
| 250 | |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 251 | if (sta && pairwise) { |
| 252 | rcu_assign_pointer(sta->ptk, new); |
| 253 | } else if (sta) { |
| 254 | if (old) |
| 255 | idx = old->conf.keyidx; |
| 256 | else |
| 257 | idx = new->conf.keyidx; |
| 258 | rcu_assign_pointer(sta->gtk[idx], new); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 259 | } else { |
| 260 | WARN_ON(new && old && new->conf.keyidx != old->conf.keyidx); |
| 261 | |
| 262 | if (old) |
| 263 | idx = old->conf.keyidx; |
| 264 | else |
| 265 | idx = new->conf.keyidx; |
| 266 | |
Johannes Berg | f7e0104 | 2010-12-09 19:49:02 +0100 | [diff] [blame] | 267 | defunikey = old && sdata->default_unicast_key == old; |
| 268 | defmultikey = old && sdata->default_multicast_key == old; |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 269 | defmgmtkey = old && sdata->default_mgmt_key == old; |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 270 | |
Johannes Berg | f7e0104 | 2010-12-09 19:49:02 +0100 | [diff] [blame] | 271 | if (defunikey && !new) |
| 272 | __ieee80211_set_default_key(sdata, -1, true, false); |
| 273 | if (defmultikey && !new) |
| 274 | __ieee80211_set_default_key(sdata, -1, false, true); |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 275 | if (defmgmtkey && !new) |
| 276 | __ieee80211_set_default_mgmt_key(sdata, -1); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 277 | |
| 278 | rcu_assign_pointer(sdata->keys[idx], new); |
Johannes Berg | f7e0104 | 2010-12-09 19:49:02 +0100 | [diff] [blame] | 279 | if (defunikey && new) |
| 280 | __ieee80211_set_default_key(sdata, new->conf.keyidx, |
| 281 | true, false); |
| 282 | if (defmultikey && new) |
| 283 | __ieee80211_set_default_key(sdata, new->conf.keyidx, |
| 284 | false, true); |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 285 | if (defmgmtkey && new) |
| 286 | __ieee80211_set_default_mgmt_key(sdata, |
| 287 | new->conf.keyidx); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 288 | } |
| 289 | |
Johannes Berg | b5c34f6 | 2011-01-03 19:51:09 +0100 | [diff] [blame] | 290 | if (old) |
| 291 | list_del(&old->list); |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 292 | } |
| 293 | |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 294 | struct ieee80211_key *ieee80211_key_alloc(u32 cipher, int idx, size_t key_len, |
Jouni Malinen | faa8fdc | 2009-05-11 21:57:58 +0300 | [diff] [blame] | 295 | const u8 *key_data, |
| 296 | size_t seq_len, const u8 *seq) |
Johannes Berg | 1f5a7e4 | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 297 | { |
| 298 | struct ieee80211_key *key; |
Ben Hutchings | 1ac62ba | 2010-08-01 17:37:03 +0100 | [diff] [blame] | 299 | int i, j, err; |
Johannes Berg | 1f5a7e4 | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 300 | |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 301 | BUG_ON(idx < 0 || idx >= NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS); |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 302 | |
| 303 | key = kzalloc(sizeof(struct ieee80211_key) + key_len, GFP_KERNEL); |
Johannes Berg | 1f5a7e4 | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 304 | if (!key) |
Ben Hutchings | 1ac62ba | 2010-08-01 17:37:03 +0100 | [diff] [blame] | 305 | return ERR_PTR(-ENOMEM); |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 306 | |
| 307 | /* |
| 308 | * Default to software encryption; we'll later upload the |
| 309 | * key to the hardware if possible. |
| 310 | */ |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 311 | key->conf.flags = 0; |
| 312 | key->flags = 0; |
| 313 | |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 314 | key->conf.cipher = cipher; |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 315 | key->conf.keyidx = idx; |
| 316 | key->conf.keylen = key_len; |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 317 | switch (cipher) { |
| 318 | case WLAN_CIPHER_SUITE_WEP40: |
| 319 | case WLAN_CIPHER_SUITE_WEP104: |
Felix Fietkau | 76708de | 2008-10-05 18:02:48 +0200 | [diff] [blame] | 320 | key->conf.iv_len = WEP_IV_LEN; |
| 321 | key->conf.icv_len = WEP_ICV_LEN; |
| 322 | break; |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 323 | case WLAN_CIPHER_SUITE_TKIP: |
Felix Fietkau | 76708de | 2008-10-05 18:02:48 +0200 | [diff] [blame] | 324 | key->conf.iv_len = TKIP_IV_LEN; |
| 325 | key->conf.icv_len = TKIP_ICV_LEN; |
Jouni Malinen | 9f26a95 | 2009-05-15 12:38:32 +0300 | [diff] [blame] | 326 | if (seq) { |
Jouni Malinen | faa8fdc | 2009-05-11 21:57:58 +0300 | [diff] [blame] | 327 | for (i = 0; i < NUM_RX_DATA_QUEUES; i++) { |
| 328 | key->u.tkip.rx[i].iv32 = |
| 329 | get_unaligned_le32(&seq[2]); |
| 330 | key->u.tkip.rx[i].iv16 = |
| 331 | get_unaligned_le16(seq); |
| 332 | } |
| 333 | } |
Felix Fietkau | 76708de | 2008-10-05 18:02:48 +0200 | [diff] [blame] | 334 | break; |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 335 | case WLAN_CIPHER_SUITE_CCMP: |
Felix Fietkau | 76708de | 2008-10-05 18:02:48 +0200 | [diff] [blame] | 336 | key->conf.iv_len = CCMP_HDR_LEN; |
| 337 | key->conf.icv_len = CCMP_MIC_LEN; |
Jouni Malinen | 9f26a95 | 2009-05-15 12:38:32 +0300 | [diff] [blame] | 338 | if (seq) { |
Jouni Malinen | 9190252 | 2010-06-11 10:27:33 -0700 | [diff] [blame] | 339 | for (i = 0; i < NUM_RX_DATA_QUEUES + 1; i++) |
Jouni Malinen | faa8fdc | 2009-05-11 21:57:58 +0300 | [diff] [blame] | 340 | for (j = 0; j < CCMP_PN_LEN; j++) |
| 341 | key->u.ccmp.rx_pn[i][j] = |
| 342 | seq[CCMP_PN_LEN - j - 1]; |
| 343 | } |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 344 | /* |
| 345 | * Initialize AES key state here as an optimization so that |
| 346 | * it does not need to be initialized for every packet. |
| 347 | */ |
| 348 | key->u.ccmp.tfm = ieee80211_aes_key_setup_encrypt(key_data); |
Ben Hutchings | 1ac62ba | 2010-08-01 17:37:03 +0100 | [diff] [blame] | 349 | if (IS_ERR(key->u.ccmp.tfm)) { |
| 350 | err = PTR_ERR(key->u.ccmp.tfm); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 351 | kfree(key); |
Petr Å tetiar | 1f951a7 | 2011-03-27 13:31:26 +0200 | [diff] [blame] | 352 | return ERR_PTR(err); |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 353 | } |
Johannes Berg | 60ae0f2 | 2010-08-10 09:46:39 +0200 | [diff] [blame] | 354 | break; |
| 355 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 356 | key->conf.iv_len = 0; |
| 357 | key->conf.icv_len = sizeof(struct ieee80211_mmie); |
| 358 | if (seq) |
| 359 | for (j = 0; j < 6; j++) |
| 360 | key->u.aes_cmac.rx_pn[j] = seq[6 - j - 1]; |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 361 | /* |
| 362 | * Initialize AES key state here as an optimization so that |
| 363 | * it does not need to be initialized for every packet. |
| 364 | */ |
| 365 | key->u.aes_cmac.tfm = |
| 366 | ieee80211_aes_cmac_key_setup(key_data); |
Ben Hutchings | 1ac62ba | 2010-08-01 17:37:03 +0100 | [diff] [blame] | 367 | if (IS_ERR(key->u.aes_cmac.tfm)) { |
| 368 | err = PTR_ERR(key->u.aes_cmac.tfm); |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 369 | kfree(key); |
Petr Å tetiar | 1f951a7 | 2011-03-27 13:31:26 +0200 | [diff] [blame] | 370 | return ERR_PTR(err); |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 371 | } |
Johannes Berg | 60ae0f2 | 2010-08-10 09:46:39 +0200 | [diff] [blame] | 372 | break; |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 373 | } |
Johannes Berg | 60ae0f2 | 2010-08-10 09:46:39 +0200 | [diff] [blame] | 374 | memcpy(key->conf.key, key_data, key_len); |
| 375 | INIT_LIST_HEAD(&key->list); |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 376 | |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 377 | return key; |
| 378 | } |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 379 | |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 380 | static void __ieee80211_key_destroy(struct ieee80211_key *key) |
| 381 | { |
| 382 | if (!key) |
| 383 | return; |
| 384 | |
Johannes Berg | d2460f4 | 2011-01-03 19:42:24 +0100 | [diff] [blame] | 385 | /* |
| 386 | * Synchronize so the TX path can no longer be using |
| 387 | * this key before we free/remove it. |
| 388 | */ |
| 389 | synchronize_rcu(); |
| 390 | |
Jouni Malinen | 32162a4 | 2010-07-26 15:52:03 -0700 | [diff] [blame] | 391 | if (key->local) |
| 392 | ieee80211_key_disable_hw_accel(key); |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 393 | |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 394 | if (key->conf.cipher == WLAN_CIPHER_SUITE_CCMP) |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 395 | ieee80211_aes_key_free(key->u.ccmp.tfm); |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 396 | if (key->conf.cipher == WLAN_CIPHER_SUITE_AES_CMAC) |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 397 | ieee80211_aes_cmac_key_free(key->u.aes_cmac.tfm); |
Yogesh Ashok Powar | aac6af5 | 2011-04-27 18:40:29 +0530 | [diff] [blame] | 398 | if (key->local) { |
Jouni Malinen | 32162a4 | 2010-07-26 15:52:03 -0700 | [diff] [blame] | 399 | ieee80211_debugfs_key_remove(key); |
Yogesh Ashok Powar | aac6af5 | 2011-04-27 18:40:29 +0530 | [diff] [blame] | 400 | key->local->crypto_tx_tailroom_needed_cnt--; |
| 401 | } |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 402 | |
| 403 | kfree(key); |
| 404 | } |
| 405 | |
Johannes Berg | 3ffc2a9 | 2010-08-27 14:26:52 +0300 | [diff] [blame] | 406 | int ieee80211_key_link(struct ieee80211_key *key, |
| 407 | struct ieee80211_sub_if_data *sdata, |
| 408 | struct sta_info *sta) |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 409 | { |
| 410 | struct ieee80211_key *old_key; |
Johannes Berg | 3ffc2a9 | 2010-08-27 14:26:52 +0300 | [diff] [blame] | 411 | int idx, ret; |
Mariusz Kozlowski | 67aa030 | 2011-03-26 18:58:51 +0100 | [diff] [blame] | 412 | bool pairwise; |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 413 | |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 414 | BUG_ON(!sdata); |
| 415 | BUG_ON(!key); |
| 416 | |
Mariusz Kozlowski | 67aa030 | 2011-03-26 18:58:51 +0100 | [diff] [blame] | 417 | pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE; |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 418 | idx = key->conf.keyidx; |
| 419 | key->local = sdata->local; |
| 420 | key->sdata = sdata; |
| 421 | key->sta = sta; |
| 422 | |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 423 | if (sta) { |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 424 | /* |
| 425 | * some hardware cannot handle TKIP with QoS, so |
| 426 | * we indicate whether QoS could be in use. |
| 427 | */ |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 428 | if (test_sta_flags(sta, WLAN_STA_WME)) |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 429 | key->conf.flags |= IEEE80211_KEY_FLAG_WMM_STA; |
| 430 | } else { |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 431 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 432 | struct sta_info *ap; |
| 433 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 434 | /* |
Johannes Berg | b5c34f6 | 2011-01-03 19:51:09 +0100 | [diff] [blame] | 435 | * We're getting a sta pointer in, so must be under |
| 436 | * appropriate locking for sta_info_get(). |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 437 | */ |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 438 | |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 439 | /* same here, the AP could be using QoS */ |
Johannes Berg | abe6063 | 2009-11-25 17:46:18 +0100 | [diff] [blame] | 440 | ap = sta_info_get(key->sdata, key->sdata->u.mgd.bssid); |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 441 | if (ap) { |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 442 | if (test_sta_flags(ap, WLAN_STA_WME)) |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 443 | key->conf.flags |= |
| 444 | IEEE80211_KEY_FLAG_WMM_STA; |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 445 | } |
| 446 | } |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 447 | } |
| 448 | |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 449 | mutex_lock(&sdata->local->key_mtx); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 450 | |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 451 | if (sta && pairwise) |
| 452 | old_key = sta->ptk; |
| 453 | else if (sta) |
| 454 | old_key = sta->gtk[idx]; |
Johannes Berg | d4e46a3 | 2007-09-14 11:10:24 -0400 | [diff] [blame] | 455 | else |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 456 | old_key = sdata->keys[idx]; |
| 457 | |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 458 | __ieee80211_key_replace(sdata, sta, pairwise, old_key, key); |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 459 | __ieee80211_key_destroy(old_key); |
Johannes Berg | d4e46a3 | 2007-09-14 11:10:24 -0400 | [diff] [blame] | 460 | |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 461 | ieee80211_debugfs_key_add(key); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 462 | |
Yogesh Ashok Powar | aac6af5 | 2011-04-27 18:40:29 +0530 | [diff] [blame] | 463 | key->local->crypto_tx_tailroom_needed_cnt++; |
| 464 | |
Johannes Berg | 3ffc2a9 | 2010-08-27 14:26:52 +0300 | [diff] [blame] | 465 | ret = ieee80211_key_enable_hw_accel(key); |
Johannes Berg | 523d2f6 | 2009-07-01 21:26:43 +0200 | [diff] [blame] | 466 | |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 467 | mutex_unlock(&sdata->local->key_mtx); |
Johannes Berg | 3ffc2a9 | 2010-08-27 14:26:52 +0300 | [diff] [blame] | 468 | |
| 469 | return ret; |
Johannes Berg | 3a24576 | 2008-04-09 16:45:37 +0200 | [diff] [blame] | 470 | } |
| 471 | |
| 472 | static void __ieee80211_key_free(struct ieee80211_key *key) |
| 473 | { |
| 474 | /* |
| 475 | * Replace key with nothingness if it was ever used. |
| 476 | */ |
| 477 | if (key->sdata) |
| 478 | __ieee80211_key_replace(key->sdata, key->sta, |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 479 | key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, |
| 480 | key, NULL); |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 481 | __ieee80211_key_destroy(key); |
Johannes Berg | 1f5a7e4 | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 482 | } |
| 483 | |
Jouni Malinen | 32162a4 | 2010-07-26 15:52:03 -0700 | [diff] [blame] | 484 | void ieee80211_key_free(struct ieee80211_local *local, |
| 485 | struct ieee80211_key *key) |
Johannes Berg | 1f5a7e4 | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 486 | { |
Johannes Berg | 8f37171 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 487 | if (!key) |
| 488 | return; |
| 489 | |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 490 | mutex_lock(&local->key_mtx); |
Johannes Berg | 3a24576 | 2008-04-09 16:45:37 +0200 | [diff] [blame] | 491 | __ieee80211_key_free(key); |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 492 | mutex_unlock(&local->key_mtx); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 493 | } |
| 494 | |
| 495 | void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata) |
| 496 | { |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 497 | struct ieee80211_key *key; |
| 498 | |
Johannes Berg | 3a24576 | 2008-04-09 16:45:37 +0200 | [diff] [blame] | 499 | ASSERT_RTNL(); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 500 | |
Johannes Berg | 9607e6b | 2009-12-23 13:15:31 +0100 | [diff] [blame] | 501 | if (WARN_ON(!ieee80211_sdata_running(sdata))) |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 502 | return; |
| 503 | |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 504 | mutex_lock(&sdata->local->key_mtx); |
| 505 | |
Yogesh Ashok Powar | aac6af5 | 2011-04-27 18:40:29 +0530 | [diff] [blame] | 506 | sdata->local->crypto_tx_tailroom_needed_cnt = 0; |
| 507 | |
| 508 | list_for_each_entry(key, &sdata->key_list, list) { |
| 509 | sdata->local->crypto_tx_tailroom_needed_cnt++; |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 510 | ieee80211_key_enable_hw_accel(key); |
Yogesh Ashok Powar | aac6af5 | 2011-04-27 18:40:29 +0530 | [diff] [blame] | 511 | } |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 512 | |
| 513 | mutex_unlock(&sdata->local->key_mtx); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 514 | } |
| 515 | |
| 516 | void ieee80211_disable_keys(struct ieee80211_sub_if_data *sdata) |
| 517 | { |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 518 | struct ieee80211_key *key; |
| 519 | |
Johannes Berg | 3a24576 | 2008-04-09 16:45:37 +0200 | [diff] [blame] | 520 | ASSERT_RTNL(); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 521 | |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 522 | mutex_lock(&sdata->local->key_mtx); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 523 | |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 524 | list_for_each_entry(key, &sdata->key_list, list) |
| 525 | ieee80211_key_disable_hw_accel(key); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 526 | |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 527 | mutex_unlock(&sdata->local->key_mtx); |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 528 | } |
| 529 | |
| 530 | void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata) |
| 531 | { |
| 532 | struct ieee80211_key *key, *tmp; |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 533 | |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 534 | mutex_lock(&sdata->local->key_mtx); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 535 | |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 536 | ieee80211_debugfs_key_remove_mgmt_default(sdata); |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 537 | |
| 538 | list_for_each_entry_safe(key, tmp, &sdata->key_list, list) |
Johannes Berg | 3a24576 | 2008-04-09 16:45:37 +0200 | [diff] [blame] | 539 | __ieee80211_key_free(key); |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 540 | |
Johannes Berg | f7e0104 | 2010-12-09 19:49:02 +0100 | [diff] [blame] | 541 | ieee80211_debugfs_key_update_default(sdata); |
| 542 | |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 543 | mutex_unlock(&sdata->local->key_mtx); |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 544 | } |