Skip to content

Commit 3c49985

Browse files
Jiajia Liugregkh
authored andcommitted
wifi: mt76: add wcid publish check in mt76_sta_add
commit 20b1269 upstream. Since mt7925_mac_sta_add publishes wcid, add publish check in mt76_sta_add to avoid reinitializing the wcid->poll_list. Found dev->sta_poll_list corruption when using mt7925 and 7.1-rc4. According to the corruption information, prev->next was changed to itself. wlan0: disconnect from AP 90:fb:5d:94:8b:e3 for new auth to 90:fb:5d:94:8b:e2 wlan0: authenticate with 90:fb:5d:94:8b:e2 (local address=84:9e:56:9c:7e:6b) wlan0: send auth to 90:fb:5d:94:8b:e2 (try 1/3) slab kmalloc-8k start ffff8c80958a6000 pointer offset 4160 size 8192 list_add corruption. prev->next should be next (ffff8c808a7488f8), but was ffff8c80958a7040. (prev=ffff8c80958a7040). mt76_wcid_add_poll+0x95/0xd0 [mt76] mt7925_mac_add_txs.part.0+0xa5/0xe0 [mt7925_common] mt7925_rx_check+0xa7/0xc0 [mt7925_common] mt76_dma_rx_poll+0x50d/0x790 [mt76] mt792x_poll_rx+0x52/0xe0 [mt792x_lib] Signed-off-by: Jiajia Liu <liujiajia@kylinos.cn> Link: https://patch.msgid.link/20260528033814.46418-1-liujiajia@kylinos.cn Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 5e658b9 commit 3c49985

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

drivers/net/wireless/mediatek/mt76/mac80211.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,6 +1568,7 @@ mt76_sta_add(struct mt76_phy *phy, struct ieee80211_vif *vif,
15681568
{
15691569
struct mt76_wcid *wcid = (struct mt76_wcid *)sta->drv_priv;
15701570
struct mt76_dev *dev = phy->dev;
1571+
struct mt76_wcid *published;
15711572
int ret;
15721573
int i;
15731574

@@ -1587,11 +1588,19 @@ mt76_sta_add(struct mt76_phy *phy, struct ieee80211_vif *vif,
15871588
mtxq->wcid = wcid->idx;
15881589
}
15891590

1590-
ewma_signal_init(&wcid->rssi);
1591-
rcu_assign_pointer(dev->wcid[wcid->idx], wcid);
1591+
published = rcu_dereference_protected(dev->wcid[wcid->idx],
1592+
lockdep_is_held(&dev->mutex));
1593+
if (published != wcid) {
1594+
WARN_ON_ONCE(published);
1595+
ewma_signal_init(&wcid->rssi);
1596+
rcu_assign_pointer(dev->wcid[wcid->idx], wcid);
1597+
mt76_wcid_init(wcid, phy->band_idx);
1598+
} else {
1599+
wcid->phy_idx = phy->band_idx;
1600+
}
1601+
15921602
phy->num_sta++;
15931603

1594-
mt76_wcid_init(wcid, phy->band_idx);
15951604
out:
15961605
mutex_unlock(&dev->mutex);
15971606

0 commit comments

Comments
 (0)