aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/ieee80211_key.h
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-04-08 11:56:52 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-04-08 16:44:45 -0400
commit3b96766f0e643f52ae19e134664df6730c737e87 (patch)
treeb1707d94a14c9777f09b1aab33970e7741190d4c /net/mac80211/ieee80211_key.h
parent7d1559f1737d5ca27b267b0392015f42b3bbe2fa (diff)
mac80211: fix key vs. sta locking problems
Up to now, key manipulation is supposed to run under RTNL to avoid concurrent manipulations and also allow the set_key() hardware callback to sleep. This is not feasible because STA structs are rcu-protected and thus a lot of operations there cannot take the RTNL. Also, key references are rcu-protected so we cannot do things atomically. This patch changes key locking completely: * key operations are now atomic * hardware crypto offload is enabled and disabled from a workqueue, due to that key freeing is also delayed * debugfs code is also run from a workqueue * keys reference STAs (and vice versa!) so during STA unlink the STAs key reference is removed but not the keys STA reference, to avoid races key todo work is run before STA destruction. * fewer STA operations now need the RTNL which was required due to key operations This fixes the locking problems lockdep pointed out and also makes things more light-weight because the rtnl isn't required as much. Note that the key todo lock/key mutex are global locks, this is not required, of course, they could be per-hardware instead. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/ieee80211_key.h')
-rw-r--r--net/mac80211/ieee80211_key.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/net/mac80211/ieee80211_key.h b/net/mac80211/ieee80211_key.h
index d670e6dbfa39..467890c6fe81 100644
--- a/net/mac80211/ieee80211_key.h
+++ b/net/mac80211/ieee80211_key.h
@@ -51,13 +51,19 @@ struct sta_info;
51 * 51 *
52 * @KEY_FLAG_UPLOADED_TO_HARDWARE: Indicates that this key is present 52 * @KEY_FLAG_UPLOADED_TO_HARDWARE: Indicates that this key is present
53 * in the hardware for TX crypto hardware acceleration. 53 * in the hardware for TX crypto hardware acceleration.
54 * @KEY_FLAG_REMOVE_FROM_HARDWARE: Indicates to the key code that this 54 * @KEY_FLAG_TODO_DELETE: Key is marked for deletion and will, after an
55 * key is present in the hardware (but it cannot be used for 55 * RCU grace period, no longer be reachable other than from the
56 * hardware acceleration any more!) 56 * todo list.
57 * @KEY_FLAG_TODO_HWACCEL: Key needs to be added to hardware acceleration.
58 * @KEY_FLAG_TODO_DEFKEY: Key is default key and debugfs needs to be updated.
59 * @KEY_FLAG_TODO_ADD_DEBUGFS: Key needs to be added to debugfs.
57 */ 60 */
58enum ieee80211_internal_key_flags { 61enum ieee80211_internal_key_flags {
59 KEY_FLAG_UPLOADED_TO_HARDWARE = BIT(0), 62 KEY_FLAG_UPLOADED_TO_HARDWARE = BIT(0),
60 KEY_FLAG_REMOVE_FROM_HARDWARE = BIT(1), 63 KEY_FLAG_TODO_DELETE = BIT(1),
64 KEY_FLAG_TODO_HWACCEL = BIT(2),
65 KEY_FLAG_TODO_DEFKEY = BIT(3),
66 KEY_FLAG_TODO_ADD_DEBUGFS = BIT(4),
61}; 67};
62 68
63struct ieee80211_key { 69struct ieee80211_key {
@@ -65,8 +71,12 @@ struct ieee80211_key {
65 struct ieee80211_sub_if_data *sdata; 71 struct ieee80211_sub_if_data *sdata;
66 struct sta_info *sta; 72 struct sta_info *sta;
67 73
74 /* for sdata list */
68 struct list_head list; 75 struct list_head list;
76 /* for todo list */
77 struct list_head todo;
69 78
79 /* protected by todo lock! */
70 unsigned int flags; 80 unsigned int flags;
71 81
72 union { 82 union {
@@ -142,4 +152,6 @@ void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata);
142void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata); 152void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata);
143void ieee80211_disable_keys(struct ieee80211_sub_if_data *sdata); 153void ieee80211_disable_keys(struct ieee80211_sub_if_data *sdata);
144 154
155void ieee80211_key_todo(void);
156
145#endif /* IEEE80211_KEY_H */ 157#endif /* IEEE80211_KEY_H */