aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/iface.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2013-12-18 03:43:33 -0500
committerJohannes Berg <johannes.berg@intel.com>2013-12-19 07:33:33 -0500
commit34a3740d6b392896b71e36cd5cd68837a8f94a5c (patch)
tree128f9a3e35af1e7fc768b55fc7173cac9e1a3b08 /net/mac80211/iface.c
parent6924d0138acdf5026ee4463134d98e139fe025a2 (diff)
mac80211: fix iflist_mtx/mtx locking in radar detection
The scan code creates an iflist_mtx -> mtx locking dependency, and a few other places, notably radar detection, were creating the opposite dependency, causing lockdep to complain. As scan and radar detection are mutually exclusive, the deadlock can't really happen in practice, but it's still bad form. A similar issue exists in the monitor mode code, but this is only used by channel-context drivers right now and those have to have hardware scan, so that also can't happen. Still, fix these issues by making some of the channel context code require the mtx to be held rather than acquiring it, thus allowing the monitor/radar callers to keep the iflist_mtx->mtx lock ordering. While at it, also fix access to the local->scanning variable in the radar code, and document that radar_detect_enabled is now properly protected by the mtx. All this would now introduce an ABBA deadlock between the DFS work cancelling and local->mtx, so change the locking there a bit to not need to use cancel_delayed_work_sync() but be able to just use cancel_delayed_work(). The work is also safely stopped/removed when the interface is stopped, so no extra changes are needed. Reported-by: Kalle Valo <kvalo@qca.qualcomm.com> Tested-by: Simon Wunderlich <sw@simonwunderlich.de> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/iface.c')
-rw-r--r--net/mac80211/iface.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 0c0be9097664..0aa9675319ef 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -418,8 +418,10 @@ int ieee80211_add_virtual_monitor(struct ieee80211_local *local)
418 return ret; 418 return ret;
419 } 419 }
420 420
421 mutex_lock(&local->mtx);
421 ret = ieee80211_vif_use_channel(sdata, &local->monitor_chandef, 422 ret = ieee80211_vif_use_channel(sdata, &local->monitor_chandef,
422 IEEE80211_CHANCTX_EXCLUSIVE); 423 IEEE80211_CHANCTX_EXCLUSIVE);
424 mutex_unlock(&local->mtx);
423 if (ret) { 425 if (ret) {
424 drv_remove_interface(local, sdata); 426 drv_remove_interface(local, sdata);
425 kfree(sdata); 427 kfree(sdata);
@@ -456,7 +458,9 @@ void ieee80211_del_virtual_monitor(struct ieee80211_local *local)
456 458
457 synchronize_net(); 459 synchronize_net();
458 460
461 mutex_lock(&local->mtx);
459 ieee80211_vif_release_channel(sdata); 462 ieee80211_vif_release_channel(sdata);
463 mutex_unlock(&local->mtx);
460 464
461 drv_remove_interface(local, sdata); 465 drv_remove_interface(local, sdata);
462 466
@@ -826,7 +830,9 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
826 if (sdata->wdev.cac_started) { 830 if (sdata->wdev.cac_started) {
827 chandef = sdata->vif.bss_conf.chandef; 831 chandef = sdata->vif.bss_conf.chandef;
828 WARN_ON(local->suspended); 832 WARN_ON(local->suspended);
833 mutex_lock(&local->mtx);
829 ieee80211_vif_release_channel(sdata); 834 ieee80211_vif_release_channel(sdata);
835 mutex_unlock(&local->mtx);
830 cfg80211_cac_event(sdata->dev, &chandef, 836 cfg80211_cac_event(sdata->dev, &chandef,
831 NL80211_RADAR_CAC_ABORTED, 837 NL80211_RADAR_CAC_ABORTED,
832 GFP_KERNEL); 838 GFP_KERNEL);