diff options
author | Felix Fietkau <nbd@nbd.name> | 2018-11-13 11:25:47 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2018-11-30 12:29:34 +0100 |
commit | c2a1a5e13684cafb866f15af2394119f62c423a9 (patch) | |
tree | 0a03c3479caa80fb709c9eb2448d8eef2da493ec | |
parent | 13c6d5f8370a55f556443e32c314f8b3abf842ad (diff) |
mt76: fix race condition in station removal
If there are still pending packets in the tx queue when removing a station,
it could possibly lead to a call to further attempts to pull packets from
the mac80211 tx queue after it has already been removed from the scheduling
list.
Prevent this from happening by calling synchronize_rcu after deleting the
wcid pointer before further cleaning up the tx queues.
To be extra careful, ensure that mtxq->list is always initialized properly.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/mt76x02_util.c | 4 | ||||
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/tx.c | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c index d2ac1a84668c..1a51193d5d59 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c @@ -216,9 +216,11 @@ int mt76x02_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, int idx = msta->wcid.idx; int i; + rcu_assign_pointer(dev->mt76.wcid[idx], NULL); + synchronize_rcu(); + mutex_lock(&dev->mt76.mutex); mt76_tx_status_check(&dev->mt76, &msta->wcid, true); - rcu_assign_pointer(dev->mt76.wcid[idx], NULL); for (i = 0; i < ARRAY_SIZE(sta->txq); i++) mt76_txq_remove(&dev->mt76, sta->txq[i]); mt76x02_mac_wcid_set_drop(dev, idx, true); diff --git a/drivers/net/wireless/mediatek/mt76/tx.c b/drivers/net/wireless/mediatek/mt76/tx.c index e42a24628e4f..f4093dc0e174 100644 --- a/drivers/net/wireless/mediatek/mt76/tx.c +++ b/drivers/net/wireless/mediatek/mt76/tx.c @@ -590,7 +590,7 @@ void mt76_txq_remove(struct mt76_dev *dev, struct ieee80211_txq *txq) spin_lock_bh(&hwq->lock); if (!list_empty(&mtxq->list)) - list_del(&mtxq->list); + list_del_init(&mtxq->list); spin_unlock_bh(&hwq->lock); while ((skb = skb_dequeue(&mtxq->retry_q)) != NULL) |