f0150ddef0ba6082f35c80e4653d6dbf3a1a7c54
[openwrt/staging/stintel.git] /
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Sat, 26 Mar 2022 23:58:35 +0100
3 Subject: [PATCH] mac80211: do not wake queues on a vif that is being stopped
4
5 When a vif is being removed and sdata->bss is cleared, __ieee80211_wake_txqs
6 can still be called on it, which crashes as soon as sdata->bss is being
7 dereferenced.
8 To fix this properly, check for SDATA_STATE_RUNNING before waking queues,
9 and take the fq lock when setting it (to ensure that __ieee80211_wake_txqs
10 observes the change when running on a different CPU
11
12 Signed-off-by: Felix Fietkau <nbd@nbd.name>
13 ---
14
15 --- a/net/mac80211/iface.c
16 +++ b/net/mac80211/iface.c
17 @@ -377,7 +377,9 @@ static void ieee80211_do_stop(struct iee
18 bool cancel_scan;
19 struct cfg80211_nan_func *func;
20
21 + spin_lock_bh(&local->fq.lock);
22 clear_bit(SDATA_STATE_RUNNING, &sdata->state);
23 + spin_unlock_bh(&local->fq.lock);
24
25 cancel_scan = rcu_access_pointer(local->scan_sdata) == sdata;
26 if (cancel_scan)
27 --- a/net/mac80211/util.c
28 +++ b/net/mac80211/util.c
29 @@ -301,6 +301,9 @@ static void __ieee80211_wake_txqs(struct
30 local_bh_disable();
31 spin_lock(&fq->lock);
32
33 + if (!test_bit(SDATA_STATE_RUNNING, &sdata->state))
34 + goto out;
35 +
36 if (sdata->vif.type == NL80211_IFTYPE_AP)
37 ps = &sdata->bss->ps;
38