aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/mac80211.h
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2011-07-07 16:28:01 -0400
committerJohn W. Linville <linville@tuxdriver.com>2011-07-08 11:11:19 -0400
commit523b02ea23b175dd3e46e3daf1bc9354376640a3 (patch)
treea11f69f05cdfb457a42b2866e33e73937c35ec1e /include/net/mac80211.h
parent397915c30731340ee3f348d1be597b22467acbdf (diff)
mac80211: fix TKIP races, make API easier to use
Our current TKIP code races against itself on TX since we can process multiple packets at the same time on different ACs, but they all share the TX context for TKIP. This can lead to bad IVs etc. Also, the crypto offload helper code just obtains the P1K/P2K from the cache, and can update it as well, but there's no guarantee that packets are really processed in order. To fix these issues, first introduce a spinlock that will protect the IV16/IV32 values in the TX context. This first step makes sure that we don't assign the same IV multiple times or get confused in other ways. Secondly, change the way the P1K cache works. I add a field "p1k_iv32" that stores the value of the IV32 when the P1K was last recomputed, and if different from the last time, then a new P1K is recomputed. This can cause the P1K computation to flip back and forth if packets are processed out of order. All this also happens under the new spinlock. Finally, because there are argument differences, split up the ieee80211_get_tkip_key() API into ieee80211_get_tkip_p1k() and ieee80211_get_tkip_p2k() and give them the correct arguments. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'include/net/mac80211.h')
-rw-r--r--include/net/mac80211.h48
1 files changed, 22 insertions, 26 deletions
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 2474019f47d3..0aae7bc1eeae 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -962,21 +962,6 @@ enum sta_notify_cmd {
962}; 962};
963 963
964/** 964/**
965 * enum ieee80211_tkip_key_type - get tkip key
966 *
967 * Used by drivers which need to get a tkip key for skb. Some drivers need a
968 * phase 1 key, others need a phase 2 key. A single function allows the driver
969 * to get the key, this enum indicates what type of key is required.
970 *
971 * @IEEE80211_TKIP_P1_KEY: the driver needs a phase 1 key
972 * @IEEE80211_TKIP_P2_KEY: the driver needs a phase 2 key
973 */
974enum ieee80211_tkip_key_type {
975 IEEE80211_TKIP_P1_KEY,
976 IEEE80211_TKIP_P2_KEY,
977};
978
979/**
980 * enum ieee80211_hw_flags - hardware flags 965 * enum ieee80211_hw_flags - hardware flags
981 * 966 *
982 * These flags are used to indicate hardware capabilities to 967 * These flags are used to indicate hardware capabilities to
@@ -2579,21 +2564,32 @@ struct sk_buff *
2579ieee80211_get_buffered_bc(struct ieee80211_hw *hw, struct ieee80211_vif *vif); 2564ieee80211_get_buffered_bc(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
2580 2565
2581/** 2566/**
2582 * ieee80211_get_tkip_key - get a TKIP rc4 for skb 2567 * ieee80211_get_tkip_p1k - get a TKIP phase 1 key
2568 *
2569 * This function returns the TKIP phase 1 key for the IV32 taken
2570 * from the given packet.
2571 *
2572 * @keyconf: the parameter passed with the set key
2573 * @skb: the packet to take the IV32 value from that will be encrypted
2574 * with this P1K
2575 * @p1k: a buffer to which the key will be written, as 5 u16 values
2576 */
2577void ieee80211_get_tkip_p1k(struct ieee80211_key_conf *keyconf,
2578 struct sk_buff *skb, u16 *p1k);
2579
2580/**
2581 * ieee80211_get_tkip_p2k - get a TKIP phase 2 key
2583 * 2582 *
2584 * This function computes a TKIP rc4 key for an skb. It computes 2583 * This function computes the TKIP RC4 key for the IV values
2585 * a phase 1 key if needed (iv16 wraps around). This function is to 2584 * in the packet.
2586 * be used by drivers which can do HW encryption but need to compute
2587 * to phase 1/2 key in SW.
2588 * 2585 *
2589 * @keyconf: the parameter passed with the set key 2586 * @keyconf: the parameter passed with the set key
2590 * @skb: the skb for which the key is needed 2587 * @skb: the packet to take the IV32/IV16 values from that will be
2591 * @type: TBD 2588 * encrypted with this key
2592 * @key: a buffer to which the key will be written 2589 * @p2k: a buffer to which the key will be written, 16 bytes
2593 */ 2590 */
2594void ieee80211_get_tkip_key(struct ieee80211_key_conf *keyconf, 2591void ieee80211_get_tkip_p2k(struct ieee80211_key_conf *keyconf,
2595 struct sk_buff *skb, 2592 struct sk_buff *skb, u8 *p2k);
2596 enum ieee80211_tkip_key_type type, u8 *key);
2597 2593
2598/** 2594/**
2599 * ieee80211_gtk_rekey_notify - notify userspace supplicant of rekeying 2595 * ieee80211_gtk_rekey_notify - notify userspace supplicant of rekeying