Skip to contentSkip to conversation

mac80211: always insert key into list

PATCH In review Johannes Berg 2 participants 3 messages Mar 1, 2008 mac80211

lore
Share & tools
lore

Johannes Berg

author maintainer
#0 lore raw

PATCH 1/1 mac80211: always insert key into list

Today I hit one of my new WARN_ONs in the mac80211 code because a key wasn't being freed correctly. After wondering for a while I finally tracked it to the fact that STA keys aren't added to the per-sdata key list correctly, they are supposed to always be on that list, not just for default keys. This patch fixes that.

---
John, please merge soon, the ultimate consequence of this bug is that when trying to delete everything mac80211 segfaults with an access to already freed memory because the key is freed but still thought to belong to a STA.

 net/mac80211/key.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
net/mac80211/key.c +3 -3
@@ -174,6 +174,9 @@ static void __ieee80211_key_replace(stru
 {
 	int idx, defkey;
 
+	if (new)
+		list_add(&new->list, &sdata->key_list);
+
 	if (sta) {
 		rcu_assign_pointer(sta->key, new);
 	} else {
@@ -190,9 +193,6 @@ static void __ieee80211_key_replace(stru
 			ieee80211_set_default_key(sdata, -1);
 
 		rcu_assign_pointer(sdata->keys[idx], new);
-		if (new)
-			list_add(&new->list, &sdata->key_list);
-
 		if (defkey && new)
 			ieee80211_set_default_key(sdata, new->conf.keyidx);
 	}
#1 lore raw
Quoted 5 lines · Johannes Berg

Today I hit one of my new WARN_ONs in the mac80211 code because
a key wasn't being freed correctly. After wondering for a while I finally tracked it to the fact that STA keys aren't added to the per-sdata key list correctly, they are supposed to always be on that list, not just for default keys. This patch fixes that.

can this be somehow related to the "wep decrypt failed" message that I get when using dynamic wep?
(I didn't have time to create any additional debug info for it yet ...)

author maintainer
#2 lore raw
Quoted 10 lines · On Sat, 2008-03-01 at 19:57 +0100, drago01 wrote:
Quoted 5 lines · Johannes Berg

Today I hit one of my new WARN_ONs in the mac80211 code because
a key wasn't being freed correctly. After wondering for a while I finally tracked it to the fact that STA keys aren't added to the per-sdata key list correctly, they are supposed to always be on that list, not just for default keys. This patch fixes that.

can this be somehow related to the "wep decrypt failed" message that I get when using dynamic wep?
(I didn't have time to create any additional debug info for it yet ...)

No, not at all.

johannes