Skip to content

Commit

Permalink
wifi: mac80211: do not wake queues on a vif that is being stopped
Browse files Browse the repository at this point in the history
When a vif is being removed and sdata->bss is cleared, __ieee80211_wake_txqs
can still be called on it, which crashes as soon as sdata->bss is being
dereferenced.
To fix this properly, check for SDATA_STATE_RUNNING before waking queues,
and take the fq lock when setting it (to ensure that __ieee80211_wake_txqs
observes the change when running on a different CPU)

Signed-off-by: Felix Fietkau <[email protected]>
Acked-by: Toke Høiland-Jørgensen <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Johannes Berg <[email protected]>
  • Loading branch information
nbd168 authored and jmberg-intel committed Jun 29, 2022
1 parent a4926ab commit f856373
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/mac80211/iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,9 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do
bool cancel_scan;
struct cfg80211_nan_func *func;

spin_lock_bh(&local->fq.lock);
clear_bit(SDATA_STATE_RUNNING, &sdata->state);
spin_unlock_bh(&local->fq.lock);

cancel_scan = rcu_access_pointer(local->scan_sdata) == sdata;
if (cancel_scan)
Expand Down
3 changes: 3 additions & 0 deletions net/mac80211/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ static void __ieee80211_wake_txqs(struct ieee80211_sub_if_data *sdata, int ac)
local_bh_disable();
spin_lock(&fq->lock);

if (!test_bit(SDATA_STATE_RUNNING, &sdata->state))
goto out;

if (sdata->vif.type == NL80211_IFTYPE_AP)
ps = &sdata->bss->ps;

Expand Down

0 comments on commit f856373

Please sign in to comment.