linux/drivers/net/wireless/iwlwifi/mvm
Emmanuel Grumbach 1c4abec0ba iwlwifi: mvm: fix setting channel in monitor mode
There was a deadlock in monitor mode when we were setting the
channel if the channel was not 1.

======================================================
[ INFO: possible circular locking dependency detected ]
3.14.3 #4 Not tainted
-------------------------------------------------------
iw/3323 is trying to acquire lock:
 (&local->chanctx_mtx){+.+.+.}, at: [<ffffffffa062e2f2>] ieee80211_vif_release_channel+0x42/0xb0 [mac80211]

but task is already holding lock:
 (&local->iflist_mtx){+.+...}, at: [<ffffffffa0609e0a>] ieee80211_set_monitor_channel+0x5a/0x1b0 [mac80211]

which lock already depends on the new lock.

the existing dependency chain (in reverse order) is:

-> #2 (&local->iflist_mtx){+.+...}:
       [<ffffffff810d95bb>] __lock_acquire+0xb3b/0x13b0
       [<ffffffff810d9ee0>] lock_acquire+0xb0/0x1f0
       [<ffffffff817eb9c8>] mutex_lock_nested+0x78/0x4f0
       [<ffffffffa06225cf>] ieee80211_iterate_active_interfaces+0x2f/0x60 [mac80211]
       [<ffffffffa0518189>] iwl_mvm_recalc_multicast+0x49/0xa0 [iwlmvm]
       [<ffffffffa051822e>] iwl_mvm_configure_filter+0x4e/0x70 [iwlmvm]
       [<ffffffffa05e6d43>] ieee80211_configure_filter+0x153/0x5f0 [mac80211]
       [<ffffffffa05e71f5>] ieee80211_reconfig_filter+0x15/0x20 [mac80211]
       [snip]

-> #1 (&mvm->mutex){+.+.+.}:
       [<ffffffff810d95bb>] __lock_acquire+0xb3b/0x13b0
       [<ffffffff810d9ee0>] lock_acquire+0xb0/0x1f0
       [<ffffffff817eb9c8>] mutex_lock_nested+0x78/0x4f0
       [<ffffffffa0517246>] iwl_mvm_add_chanctx+0x56/0xe0 [iwlmvm]
       [<ffffffffa062ca1e>] ieee80211_new_chanctx+0x13e/0x410 [mac80211]
       [<ffffffffa062d953>] ieee80211_vif_use_channel+0x1c3/0x5a0 [mac80211]
       [<ffffffffa06035ab>] ieee80211_add_virtual_monitor+0x1ab/0x6b0 [mac80211]
       [<ffffffffa06052ea>] ieee80211_do_open+0xe6a/0x15a0 [mac80211]
       [<ffffffffa0605a79>] ieee80211_open+0x59/0x60 [mac80211]
       [snip]

-> #0 (&local->chanctx_mtx){+.+.+.}:
       [<ffffffff810d6cb7>] check_prevs_add+0x977/0x980
       [<ffffffff810d95bb>] __lock_acquire+0xb3b/0x13b0
       [<ffffffff810d9ee0>] lock_acquire+0xb0/0x1f0
       [<ffffffff817eb9c8>] mutex_lock_nested+0x78/0x4f0
       [<ffffffffa062e2f2>] ieee80211_vif_release_channel+0x42/0xb0 [mac80211]
       [<ffffffffa0609ec3>] ieee80211_set_monitor_channel+0x113/0x1b0 [mac80211]
       [<ffffffffa058fb37>] cfg80211_set_monitor_channel+0x77/0x2b0 [cfg80211]
       [<ffffffffa056e0b2>] __nl80211_set_channel+0x122/0x140 [cfg80211]
       [<ffffffffa0581374>] nl80211_set_wiphy+0x284/0xaf0 [cfg80211]
       [snip]

other info that might help us debug this:

Chain exists of:
  &local->chanctx_mtx --> &mvm->mutex --> &local->iflist_mtx

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&local->iflist_mtx);
                               lock(&mvm->mutex);
                               lock(&local->iflist_mtx);
  lock(&local->chanctx_mtx);

 *** DEADLOCK ***

This deadlock actually occurs:
INFO: task iw:3323 blocked for more than 120 seconds.
      Not tainted 3.14.3 #4
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
iw              D ffff8800c8afcd80  4192  3323   3322 0x00000000
 ffff880078fdb7e0 0000000000000046 ffff8800c8afcd80 ffff880078fdbfd8
 00000000001d5540 00000000001d5540 ffff8801141b0000 ffff8800c8afcd80
 ffff880078ff9e38 ffff880078ff9e38 ffff880078ff9e40 0000000000000246
Call Trace:
 [<ffffffff817ea841>] schedule_preempt_disabled+0x31/0x80
 [<ffffffff817ebaed>] mutex_lock_nested+0x19d/0x4f0
 [<ffffffffa06225cf>] ? ieee80211_iterate_active_interfaces+0x2f/0x60 [mac80211]
 [<ffffffffa06225cf>] ? ieee80211_iterate_active_interfaces+0x2f/0x60 [mac80211]
 [<ffffffffa052a680>] ? iwl_mvm_power_mac_update_mode+0xc0/0xc0 [iwlmvm]
 [<ffffffffa06225cf>] ieee80211_iterate_active_interfaces+0x2f/0x60 [mac80211]
 [<ffffffffa0529357>] _iwl_mvm_power_update_binding+0x27/0x80 [iwlmvm]
 [<ffffffffa0516eb1>] iwl_mvm_unassign_vif_chanctx+0x81/0xc0 [iwlmvm]
 [<ffffffffa062d3ff>] __ieee80211_vif_release_channel+0xdf/0x470 [mac80211]
 [<ffffffffa062e2fa>] ieee80211_vif_release_channel+0x4a/0xb0 [mac80211]
 [<ffffffffa0609ec3>] ieee80211_set_monitor_channel+0x113/0x1b0 [mac80211]
 [<ffffffffa058fb37>] cfg80211_set_monitor_channel+0x77/0x2b0 [cfg80211]
 [<ffffffffa056e0b2>] __nl80211_set_channel+0x122/0x140 [cfg80211]
 [<ffffffffa0581374>] nl80211_set_wiphy+0x284/0xaf0 [cfg80211]

This fixes https://bugzilla.kernel.org/show_bug.cgi?id=75541

Cc: <stable@vger.kernel.org> [3.13+]
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
2014-05-11 13:10:08 +03:00
..
binding.c iwlwifi: Update Copyright to 2014 2013-12-31 19:03:53 +02:00
coex.c iwlwifi: mvm: BT Coex - fix validity flags during init 2014-05-06 19:46:24 +03:00
constants.h iwlwifi: mvm: remove using max_duration in firmware API 2014-03-18 21:15:38 +02:00
d3.c iwlwifi: mvm: configure protocol offloading on D0i3 2014-03-16 13:45:33 +02:00
debugfs-vif.c iwlwifi: mvm: fix theoretical NULL ptr dereference 2014-03-18 21:15:40 +02:00
debugfs.c iwlwifi: mvm: add missing include 2014-03-19 08:25:05 +02:00
debugfs.h iwlwifi: Update Copyright to 2014 2013-12-31 19:03:53 +02:00
fw-api-coex.h iwlwifi: mvm: BT Coex - add debugfs hook to set BT Tx priority 2014-03-18 21:15:37 +02:00
fw-api-d3.h iwlwifi: mvm: configure seq_num to D0i3 2014-03-16 13:45:23 +02:00
fw-api-mac.h iwlwifi: Update Copyright to 2014 2013-12-31 19:03:53 +02:00
fw-api-power.h iwlwifi: mvm: add D0i3 power configurations 2014-02-03 22:23:39 +02:00
fw-api-rs.h iwlwifi: mvm: propagate LDPC / STBC status to radiotap 2014-02-13 10:27:24 +02:00
fw-api-scan.h iwlwifi: mvm: several fixes in scan 2014-04-13 21:57:47 +03:00
fw-api-sta.h iwlwifi: mvm: implement AP/GO uAPSD support 2014-02-03 22:23:31 +02:00
fw-api-tx.h iwlwifi: mvm: BT Coex - classify packet priority in BT code 2014-03-11 19:50:06 +02:00
fw-api.h iwlwifi: mvm: make bt-coex.c generic 2014-03-11 19:49:39 +02:00
fw-error-dump.h iwlwifi: mvm: send udev event upon firmware error to dump logs 2014-03-18 21:15:06 +02:00
fw.c iwlwifi: mvm: remove redundant define in fw.c 2014-02-23 19:27:27 +02:00
led.c iwlwifi: mvm: don't fail completely if led mode is not supported 2014-03-16 08:59:05 +02:00
mac80211.c iwlwifi: mvm: fix setting channel in monitor mode 2014-05-11 13:10:08 +03:00
mac-ctxt.c iwlwifi: remove iwl_fw_valid_(tx|rx)_ant inlines 2014-02-13 13:49:44 +02:00
Makefile iwlwifi: mvm: configure seq_num to D0i3 2014-03-16 13:45:23 +02:00
mvm.h iwlwifi: mvm: do no sched scan while associated 2014-05-06 21:56:37 +03:00
nvm.c iwlwifi: remove iwl_fw_valid_(tx|rx)_ant inlines 2014-02-13 13:49:44 +02:00
offloading.c iwlwifi: mvm: configure protocol offloading on D0i3 2014-03-16 13:45:33 +02:00
ops.c iwlwifi: mvm: send udev event upon firmware error to dump logs 2014-03-18 21:15:06 +02:00
phy-ctxt.c iwlwifi: remove iwl_fw_valid_(tx|rx)_ant inlines 2014-02-13 13:49:44 +02:00
power.c iwlwifi: mvm: disable power on P2P client when BSS is added 2014-03-09 16:39:08 +02:00
quota.c iwlwifi: mvm: remove spurious blank line 2014-03-18 21:15:40 +02:00
rs.c iwlwifi: mvm: rs - s/CPTCFG/CONFIG 2014-05-06 20:35:57 +03:00
rs.h iwlwifi: mvm: rs: reinit rs if no tx for a long time 2014-04-13 16:51:04 +03:00
rx.c iwlwifi: mvm: add Rx frames statistics via debugfs 2014-02-20 19:22:12 +02:00
scan.c iwlwifi: mvm: several fixes in scan 2014-04-13 21:57:47 +03:00
sf.c iwlwifi: mvm: delay enabling smart FIFO until after beacon RX 2014-04-13 08:26:51 +03:00
sta.c iwlwifi: mvm: reconfigure qos seq on D0i3 exit 2014-03-16 13:45:32 +02:00
sta.h iwlwifi: mvm: reserve sta_id 0 to station 2014-02-06 21:11:21 +02:00
testmode.h iwlwifi: Update Copyright to 2014 2013-12-31 19:03:53 +02:00
time-event.c iwlwifi: mvm: set immediate apply time bit in time events 2014-02-20 19:19:33 +02:00
time-event.h iwlwifi: Update Copyright to 2014 2013-12-31 19:03:53 +02:00
tt.c iwlwifi: mvm: handle platform PCIe power limitation 2014-02-03 22:23:38 +02:00
tx.c Merge branch 'for-john' of git://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-next 2014-03-18 16:55:28 -04:00
utils.c iwlwifi: mvm: do no sched scan while associated 2014-05-06 21:56:37 +03:00