aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Spinadel <david.spinadel@intel.com>2017-12-01 06:50:52 -0500
committerJohannes Berg <johannes.berg@intel.com>2017-12-11 06:20:17 -0500
commit9de18d8186cb070d22ed67a3f75a2ef5fbf3ef6f (patch)
tree936a15e2817360d322ebe90373099da0d3f478a9
parentc7c477b52c4caa2cfb44bf3841f806d1bf20e0bf (diff)
mac80211: Add MIC space only for TX key option
Add a key flag to indicates that the device only needs MIC space and not a real MIC. In such cases, keep the MIC zeroed for ease of debug. Signed-off-by: David Spinadel <david.spinadel@intel.com> Signed-off-by: Luca Coelho <luciano.coelho@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r--include/net/mac80211.h6
-rw-r--r--net/mac80211/key.c12
-rw-r--r--net/mac80211/tx.c4
-rw-r--r--net/mac80211/wpa.c16
4 files changed, 29 insertions, 9 deletions
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 2ee4af25256d..906e90223066 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -1552,6 +1552,9 @@ struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif);
1552 * @IEEE80211_KEY_FLAG_RESERVE_TAILROOM: This flag should be set by the 1552 * @IEEE80211_KEY_FLAG_RESERVE_TAILROOM: This flag should be set by the
1553 * driver for a key to indicate that sufficient tailroom must always 1553 * driver for a key to indicate that sufficient tailroom must always
1554 * be reserved for ICV or MIC, even when HW encryption is enabled. 1554 * be reserved for ICV or MIC, even when HW encryption is enabled.
1555 * @IEEE80211_KEY_FLAG_PUT_MIC_SPACE: This flag should be set by the driver for
1556 * a TKIP key if it only requires MIC space. Do not set together with
1557 * @IEEE80211_KEY_FLAG_GENERATE_MMIC on the same key.
1555 */ 1558 */
1556enum ieee80211_key_flags { 1559enum ieee80211_key_flags {
1557 IEEE80211_KEY_FLAG_GENERATE_IV_MGMT = BIT(0), 1560 IEEE80211_KEY_FLAG_GENERATE_IV_MGMT = BIT(0),
@@ -1562,6 +1565,7 @@ enum ieee80211_key_flags {
1562 IEEE80211_KEY_FLAG_PUT_IV_SPACE = BIT(5), 1565 IEEE80211_KEY_FLAG_PUT_IV_SPACE = BIT(5),
1563 IEEE80211_KEY_FLAG_RX_MGMT = BIT(6), 1566 IEEE80211_KEY_FLAG_RX_MGMT = BIT(6),
1564 IEEE80211_KEY_FLAG_RESERVE_TAILROOM = BIT(7), 1567 IEEE80211_KEY_FLAG_RESERVE_TAILROOM = BIT(7),
1568 IEEE80211_KEY_FLAG_PUT_MIC_SPACE = BIT(8),
1565}; 1569};
1566 1570
1567/** 1571/**
@@ -1593,8 +1597,8 @@ struct ieee80211_key_conf {
1593 u8 icv_len; 1597 u8 icv_len;
1594 u8 iv_len; 1598 u8 iv_len;
1595 u8 hw_key_idx; 1599 u8 hw_key_idx;
1596 u8 flags;
1597 s8 keyidx; 1600 s8 keyidx;
1601 u16 flags;
1598 u8 keylen; 1602 u8 keylen;
1599 u8 key[0]; 1603 u8 key[0];
1600}; 1604};
diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index 938049395f90..aee05ec3f7ea 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -178,13 +178,17 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
178 if (!ret) { 178 if (!ret) {
179 key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE; 179 key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE;
180 180
181 if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) || 181 if (!((key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC |
182 IEEE80211_KEY_FLAG_PUT_MIC_SPACE)) ||
182 (key->conf.flags & IEEE80211_KEY_FLAG_RESERVE_TAILROOM))) 183 (key->conf.flags & IEEE80211_KEY_FLAG_RESERVE_TAILROOM)))
183 decrease_tailroom_need_count(sdata, 1); 184 decrease_tailroom_need_count(sdata, 1);
184 185
185 WARN_ON((key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE) && 186 WARN_ON((key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE) &&
186 (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)); 187 (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV));
187 188
189 WARN_ON((key->conf.flags & IEEE80211_KEY_FLAG_PUT_MIC_SPACE) &&
190 (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC));
191
188 return 0; 192 return 0;
189 } 193 }
190 194
@@ -237,7 +241,8 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
237 sta = key->sta; 241 sta = key->sta;
238 sdata = key->sdata; 242 sdata = key->sdata;
239 243
240 if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) || 244 if (!((key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC |
245 IEEE80211_KEY_FLAG_PUT_MIC_SPACE)) ||
241 (key->conf.flags & IEEE80211_KEY_FLAG_RESERVE_TAILROOM))) 246 (key->conf.flags & IEEE80211_KEY_FLAG_RESERVE_TAILROOM)))
242 increment_tailroom_need_count(sdata); 247 increment_tailroom_need_count(sdata);
243 248
@@ -1104,7 +1109,8 @@ void ieee80211_remove_key(struct ieee80211_key_conf *keyconf)
1104 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) { 1109 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) {
1105 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; 1110 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;
1106 1111
1107 if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) || 1112 if (!((key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC |
1113 IEEE80211_KEY_FLAG_PUT_MIC_SPACE)) ||
1108 (key->conf.flags & IEEE80211_KEY_FLAG_RESERVE_TAILROOM))) 1114 (key->conf.flags & IEEE80211_KEY_FLAG_RESERVE_TAILROOM)))
1109 increment_tailroom_need_count(key->sdata); 1115 increment_tailroom_need_count(key->sdata);
1110 } 1116 }
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 3160954fc406..25904af38839 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -2922,7 +2922,9 @@ void ieee80211_check_fast_xmit(struct sta_info *sta)
2922 2922
2923 gen_iv = build.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV; 2923 gen_iv = build.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV;
2924 iv_spc = build.key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE; 2924 iv_spc = build.key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE;
2925 mmic = build.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC; 2925 mmic = build.key->conf.flags &
2926 (IEEE80211_KEY_FLAG_GENERATE_MMIC |
2927 IEEE80211_KEY_FLAG_PUT_MIC_SPACE);
2926 2928
2927 /* don't handle software crypto */ 2929 /* don't handle software crypto */
2928 if (!(build.key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) 2930 if (!(build.key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
index b58722d9de37..785056cb76f6 100644
--- a/net/mac80211/wpa.c
+++ b/net/mac80211/wpa.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright 2002-2004, Instant802 Networks, Inc. 2 * Copyright 2002-2004, Instant802 Networks, Inc.
3 * Copyright 2008, Jouni Malinen <j@w1.fi> 3 * Copyright 2008, Jouni Malinen <j@w1.fi>
4 * Copyright (C) 2016 Intel Deutschland GmbH 4 * Copyright (C) 2016-2017 Intel Deutschland GmbH
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
@@ -59,8 +59,9 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_tx_data *tx)
59 if (info->control.hw_key && 59 if (info->control.hw_key &&
60 (info->flags & IEEE80211_TX_CTL_DONTFRAG || 60 (info->flags & IEEE80211_TX_CTL_DONTFRAG ||
61 ieee80211_hw_check(&tx->local->hw, SUPPORTS_TX_FRAG)) && 61 ieee80211_hw_check(&tx->local->hw, SUPPORTS_TX_FRAG)) &&
62 !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC)) { 62 !(tx->key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC |
63 /* hwaccel - with no need for SW-generated MMIC */ 63 IEEE80211_KEY_FLAG_PUT_MIC_SPACE))) {
64 /* hwaccel - with no need for SW-generated MMIC or MIC space */
64 return TX_CONTINUE; 65 return TX_CONTINUE;
65 } 66 }
66 67
@@ -75,8 +76,15 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_tx_data *tx)
75 skb_tailroom(skb), tail)) 76 skb_tailroom(skb), tail))
76 return TX_DROP; 77 return TX_DROP;
77 78
78 key = &tx->key->conf.key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY];
79 mic = skb_put(skb, MICHAEL_MIC_LEN); 79 mic = skb_put(skb, MICHAEL_MIC_LEN);
80
81 if (tx->key->conf.flags & IEEE80211_KEY_FLAG_PUT_MIC_SPACE) {
82 /* Zeroed MIC can help with debug */
83 memset(mic, 0, MICHAEL_MIC_LEN);
84 return TX_CONTINUE;
85 }
86
87 key = &tx->key->conf.key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY];
80 michael_mic(key, hdr, data, data_len, mic); 88 michael_mic(key, hdr, data, data_len, mic);
81 if (unlikely(info->flags & IEEE80211_TX_INTFL_TKIP_MIC_FAILURE)) 89 if (unlikely(info->flags & IEEE80211_TX_INTFL_TKIP_MIC_FAILURE))
82 mic[0]++; 90 mic[0]++;