mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-06 00:39:48 +00:00
mt76: fix tx status related use-after-free race on station removal
[ Upstream commitfcfe1b5e16
] There is a small race window where ongoing tx activity can lead to a skb getting added to the status tracking idr after that idr has already been cleaned up, which will keep the wcid linked in the status poll list. Fix this by only adding status skbs if the wcid pointer is still assigned in dev->wcid, which gets cleared early by mt76_sta_pre_rcu_remove Fixes:bd1e3e7b69
("mt76: introduce packet_id idr") Tested-by: Ben Greear <greearb@candelatech.com> Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
dceccca086
commit
ef7f9f894c
2 changed files with 3 additions and 1 deletions
|
@ -1344,7 +1344,9 @@ void mt76_sta_pre_rcu_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
||||||
struct mt76_wcid *wcid = (struct mt76_wcid *)sta->drv_priv;
|
struct mt76_wcid *wcid = (struct mt76_wcid *)sta->drv_priv;
|
||||||
|
|
||||||
mutex_lock(&dev->mutex);
|
mutex_lock(&dev->mutex);
|
||||||
|
spin_lock_bh(&dev->status_lock);
|
||||||
rcu_assign_pointer(dev->wcid[wcid->idx], NULL);
|
rcu_assign_pointer(dev->wcid[wcid->idx], NULL);
|
||||||
|
spin_unlock_bh(&dev->status_lock);
|
||||||
mutex_unlock(&dev->mutex);
|
mutex_unlock(&dev->mutex);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(mt76_sta_pre_rcu_remove);
|
EXPORT_SYMBOL_GPL(mt76_sta_pre_rcu_remove);
|
||||||
|
|
|
@ -120,7 +120,7 @@ mt76_tx_status_skb_add(struct mt76_dev *dev, struct mt76_wcid *wcid,
|
||||||
|
|
||||||
memset(cb, 0, sizeof(*cb));
|
memset(cb, 0, sizeof(*cb));
|
||||||
|
|
||||||
if (!wcid)
|
if (!wcid || !rcu_access_pointer(dev->wcid[wcid->idx]))
|
||||||
return MT_PACKET_ID_NO_ACK;
|
return MT_PACKET_ID_NO_ACK;
|
||||||
|
|
||||||
if (info->flags & IEEE80211_TX_CTL_NO_ACK)
|
if (info->flags & IEEE80211_TX_CTL_NO_ACK)
|
||||||
|
|
Loading…
Reference in a new issue