Skip to content

Commit

Permalink
mac80211: Properly WARN on HW scan before restart
Browse files Browse the repository at this point in the history
The following race was possible:

1. The device driver requests HW restart.
2. A scan is requested from user space and is propagated
   to the driver. During this flow HW_SCANNING flag is set.
3. The thread that handles the HW restart is scheduled,
   and before starting the actual reconfiguration it
   checks that HW_SCANNING is not set. The flow does so
   without acquiring any lock, and thus the WARN fires.

Fix this by checking that HW_SCANNING is on only after RTNL is
acquired, i.e., user space scan request handling is no longer
in transit.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210618133832.8238ab3e19ab.I2693c581c70251472b4f9089e37e06fb2c18268f@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
ilanpeer2 authored and jmberg-intel committed Jun 23, 2021
1 parent dd3e4fc commit 45daaa1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions net/mac80211/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,13 @@ static void ieee80211_restart_work(struct work_struct *work)
/* wait for scan work complete */
flush_workqueue(local->workqueue);
flush_work(&local->sched_scan_stopped_work);
flush_work(&local->radar_detected_work);

rtnl_lock();

WARN(test_bit(SCAN_HW_SCANNING, &local->scanning),
"%s called with hardware scan in progress\n", __func__);

flush_work(&local->radar_detected_work);
/* we might do interface manipulations, so need both */
rtnl_lock();
wiphy_lock(local->hw.wiphy);
list_for_each_entry(sdata, &local->interfaces, list) {
/*
* XXX: there may be more work for other vif types and even
Expand Down

0 comments on commit 45daaa1

Please sign in to comment.