Skip to contentSkip to conversation

mac80211: fix deauth race

PATCH Superseded Johannes Berg 1 participant 2 messages Feb 6, 2010 mac80211

lore
Share & tools
lore

Johannes Berg

author maintainer
#0 lore raw

PATCH 1/1 mac80211: fix deauth race

When userspace requests a deauth while the authentication work is pending in the auth (not probe) state, we do not properly abort the work and then things get confused.

Fix that and also improve the checks here to include the correct virtual interface, just in case two virtual interfaces would ever try to connect to the same BSS.

---
 net/mac80211/mlme.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
net/mac80211/mlme.c +8 -2
@@ -2007,11 +2007,17 @@ int ieee80211_mgd_deauth(struct ieee8021
 
 		mutex_lock(&local->work_mtx);
 		list_for_each_entry(wk, &local->work_list, list) {
-			if (wk->type != IEEE80211_WORK_DIRECT_PROBE)
+			if (wk->sdata != sdata)
 				continue;
+
+			if (wk->type != IEEE80211_WORK_DIRECT_PROBE &&
+			    wk->type != IEEE80211_WORK_AUTH)
+				continue;
+
 			if (memcmp(req->bss->bssid, wk->filter_ta, ETH_ALEN))
 				continue;
-			not_auth_yet = true;
+
+			not_auth_yet = wk->type == IEEE80211_WORK_DIRECT_PROBE;
 			list_del(&wk->list);
 			free_work(wk);
 			break;
author maintainer
#1 lore raw

PATCH v2 1/1 mac80211: fix deauth race

When userspace requests a deauth while the authentication work is pending in the auth (not probe) state, we do not properly abort the work and then things get confused.

Fix that and also improve the checks here to include the correct virtual interface, just in case two virtual interfaces would ever try to connect to the same BSS.

Also fix a bug -- need to use list_del_rcu instead of just list_del to free a work item.

---
 net/mac80211/mlme.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
net/mac80211/mlme.c +9 -3
@@ -2007,12 +2007,18 @@ int ieee80211_mgd_deauth(struct ieee8021
 
 		mutex_lock(&local->work_mtx);
 		list_for_each_entry(wk, &local->work_list, list) {
-			if (wk->type != IEEE80211_WORK_DIRECT_PROBE)
+			if (wk->sdata != sdata)
 				continue;
+
+			if (wk->type != IEEE80211_WORK_DIRECT_PROBE &&
+			    wk->type != IEEE80211_WORK_AUTH)
+				continue;
+
 			if (memcmp(req->bss->bssid, wk->filter_ta, ETH_ALEN))
 				continue;
-			not_auth_yet = true;
-			list_del(&wk->list);
+
+			not_auth_yet = wk->type == IEEE80211_WORK_DIRECT_PROBE;
+			list_del_rcu(&wk->list);
 			free_work(wk);
 			break;
 		}