linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mac80211: fix scheduled scan rtnl deadlock
@ 2013-11-06  9:43 Johannes Berg
  2013-11-06 10:58 ` Johannes Berg
  0 siblings, 1 reply; 2+ messages in thread
From: Johannes Berg @ 2013-11-06  9:43 UTC (permalink / raw)
  To: linux-wireless; +Cc: Eliad Peller, Johannes Berg

From: Johannes Berg <johannes.berg@intel.com>

When changing cfg80211 to use RTNL locking, this caused a
deadlock in mac80211 as it calls cfg80211_sched_scan_stopped()
from a work item that's on a workqueue that is flushed with
the RTNL held.

Fix this by simply using schedule_work(), the work only needs
to finish running before the wiphy is unregistered, no other
synchronisation (e.g. with suspend) is really required since
for suspend userspace is already blocked anyway when we flush
the workqueue so will only pick up the event after resume.

Cc: stable@vger.kernel.org
Fixes: 5fe231e87372 ("cfg80211: vastly simplify locking")
Reported-and-tested-by: Eliad Peller <eliadx.peller@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 net/mac80211/main.c | 1 +
 net/mac80211/scan.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 21d5d44..e765f77 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -1047,6 +1047,7 @@ void ieee80211_unregister_hw(struct ieee80211_hw *hw)
 
 	cancel_work_sync(&local->restart_work);
 	cancel_work_sync(&local->reconfig_filter);
+	flush_work(&local->sched_scan_stopped_work);
 
 	ieee80211_clear_tx_pending(local);
 	rate_control_deinitialize(local);
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index a0b78b1..01fdf20 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -1069,6 +1069,6 @@ void ieee80211_sched_scan_stopped(struct ieee80211_hw *hw)
 
 	trace_api_sched_scan_stopped(local);
 
-	ieee80211_queue_work(&local->hw, &local->sched_scan_stopped_work);
+	schedule_work(&local->sched_scan_stopped_work);
 }
 EXPORT_SYMBOL(ieee80211_sched_scan_stopped);
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mac80211: fix scheduled scan rtnl deadlock
  2013-11-06  9:43 [PATCH] mac80211: fix scheduled scan rtnl deadlock Johannes Berg
@ 2013-11-06 10:58 ` Johannes Berg
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Berg @ 2013-11-06 10:58 UTC (permalink / raw)
  To: linux-wireless; +Cc: Eliad Peller

On Wed, 2013-11-06 at 10:43 +0100, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
> 
> When changing cfg80211 to use RTNL locking, this caused a
> deadlock in mac80211 as it calls cfg80211_sched_scan_stopped()
> from a work item that's on a workqueue that is flushed with
> the RTNL held.
> 
> Fix this by simply using schedule_work(), the work only needs
> to finish running before the wiphy is unregistered, no other
> synchronisation (e.g. with suspend) is really required since
> for suspend userspace is already blocked anyway when we flush
> the workqueue so will only pick up the event after resume.

Applied.

johannes


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-11-06 10:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-06  9:43 [PATCH] mac80211: fix scheduled scan rtnl deadlock Johannes Berg
2013-11-06 10:58 ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).