Skip to contentSkip to conversation

softmac: Fix deadlock of wx_set_essid with assoc work

PATCH In review Michael Buesch 3 participants 4 messages Jul 31, 2007 – Aug 1, 2007 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 softmac: Fix deadlock of wx_set_essid with assoc work

The essid wireless extension does deadlock against the assoc mutex, as we don't unlock the assoc mutex when flushing the workqueue, which also holds the lock.

--

David, please stresstest this.
John, please apply this, if David reports success from his tests. John, please notify me when you applied this, so I can immediately send it to -stable.

net/ieee80211/softmac/ieee80211softmac_wx.c +8 -3
Index: bu3sch-wireless-dev/net/ieee80211/softmac/ieee80211softmac_wx.c
===================================================================
@@ -74,8 +74,8 @@ ieee80211softmac_wx_set_essid(struct net
 	struct ieee80211softmac_auth_queue_item *authptr;
 	int length = 0;
 
+check_assoc_again:
 	mutex_lock(&sm->associnfo.mutex);
-
 	/* Check if we're already associating to this or another network
 	 * If it's another network, cancel and start over with our new network
 	 * If it's our network, ignore the change, we're already doing it!
@@ -98,13 +98,18 @@ ieee80211softmac_wx_set_essid(struct net
 				cancel_delayed_work(&authptr->work);
 			sm->associnfo.bssvalid = 0;
 			sm->associnfo.bssfixed = 0;
-			flush_scheduled_work();
 			sm->associnfo.associating = 0;
 			sm->associnfo.associated = 0;
+			/* We must unlock to avoid deadlocks with the assoc workqueue
+			 * on the associnfo.mutex */
+			mutex_unlock(&sm->associnfo.mutex);
+			flush_scheduled_work();
+			/* Avoid race! Check assoc status again. Maybe someone started an
+			 * association while we flushed. */
+			goto check_assoc_again;
 		}
 	}
 
-
 	sm->associnfo.static_essid = 0;
 	sm->associnfo.assoc_wait = 0;
 
#1 lore raw
Quoted 1 line · Michael Buesch

David, please stresstest this.

It seemed to survive being left with NetworkManager overnight, which the 2.6.22.1 kernel was consistently failing to cope with beforehand.

Signature · 1 line
dwmw2
#2 lore raw
Quoted 5 lines · David Woodhouse
Quoted 1 line · Michael Buesch

David, please stresstest this.

It seemed to survive being left with NetworkManager overnight, which the 2.6.22.1 kernel was consistently failing to cope with beforehand.

So John, please apply this.

#3 lore raw
Quoted 7 lines · Michael Buesch
Quoted 4 lines · David Woodhouse
Quoted 1 line · Michael Buesch

David, please stresstest this.

It seemed to survive being left with NetworkManager overnight, which the 2.6.22.1 kernel was consistently failing to cope with beforehand.

So John, please apply this.

ACK.

Larry