forked from openwrt/openwrt
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mac80211: add a bug fix for a rare crash
Signed-off-by: Felix Fietkau <nbd@nbd.name>
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...el/mac80211/patches/subsys/328-mac80211-do-not-wake-queues-on-a-vif-that-is-being-s.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
From: Felix Fietkau <nbd@nbd.name> | ||
Date: Sat, 26 Mar 2022 23:58:35 +0100 | ||
Subject: [PATCH] mac80211: do not wake queues on a vif that is being stopped | ||
|
||
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 <nbd@nbd.name> | ||
--- | ||
|
||
--- a/net/mac80211/iface.c | ||
+++ b/net/mac80211/iface.c | ||
@@ -377,7 +377,9 @@ static void ieee80211_do_stop(struct iee | ||
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) | ||
--- a/net/mac80211/util.c | ||
+++ b/net/mac80211/util.c | ||
@@ -301,6 +301,9 @@ static void __ieee80211_wake_txqs(struct | ||
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; | ||
|