The RX descriptor of a decrypted group addressed frame names the vif link wcid, which has no station, so mt7996_rx_get_wcid() gives the frame no wcid. With the IV stripped, the frame gets no replay check. Give such a frame the vif link wcid and check it against the counters of its key id. Seed the counters only when mac80211 sets the group key, not when the driver installs the key again at a link add, since mac80211 does not advance the RSC of a frame with a stripped IV. Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices") Signed-off-by: Felix Fietkau --- drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 5 +++++ drivers/net/wireless/mediatek/mt76/mt7996/main.c | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c index 62e16e3c989b..ec4c8118d679 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c @@ -478,6 +478,8 @@ mt7996_mac_fill_rx(struct mt7996_dev *dev, enum mt76_rxq_id q, status->flag |= RX_FLAG_ONLY_MONITOR; unicast = FIELD_GET(MT_RXD3_NORMAL_ADDR_TYPE, rxd3) == MT_RXD3_NORMAL_U2M; + status->group = !unicast; + status->key_id = FIELD_GET(MT_RXD1_NORMAL_KEY_ID, rxd1); idx = FIELD_GET(MT_RXD1_NORMAL_WLAN_IDX, rxd1); status->wcid = mt7996_rx_get_wcid(dev, idx, band_idx); @@ -519,6 +521,9 @@ mt7996_mac_fill_rx(struct mt7996_dev *dev, enum mt76_rxq_id q, status->flag |= RX_FLAG_MMIC_STRIPPED | RX_FLAG_MIC_STRIPPED; } + if (!unicast && !status->wcid && (status->flag & RX_FLAG_DECRYPTED)) + status->wcid = mt76_rx_group_wcid(mt76_wcid_ptr(dev, idx)); + remove_pad = FIELD_GET(MT_RXD2_NORMAL_HDR_OFFSET, rxd2); if (rxd2 & MT_RXD2_NORMAL_MAX_LEN_ERROR) diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/main.c b/drivers/net/wireless/mediatek/mt76/mt7996/main.c index bcecd6558fda..7e5bf40c257d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c @@ -469,6 +469,7 @@ int mt7996_vif_link_add(struct mt76_phy *mphy, struct ieee80211_vif *vif, msta_link->wcid.link_valid = ieee80211_vif_is_mld(vif); msta_link->wcid.tx_info |= MT_WCID_TX_INFO_SET; mt76_wcid_init(&msta_link->wcid, band_idx); + mt76_wcid_rx_group_pn_set(&msta_link->wcid, vif, &mlink->rx_group_pn); if (vif->type != NL80211_IFTYPE_AP && (!mlink->omac_idx || mlink->omac_idx > 3)) @@ -900,6 +901,12 @@ static int mt7996_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, } for_each_set_bit(link_id, &links, IEEE80211_MLD_MAX_NUM_LINKS) { + struct mt7996_vif_link *link = mt7996_vif_link(dev, vif, link_id); + + /* a replay of the key at a link add must keep the counters */ + if (!sta && link && cmd == SET_KEY) + mt76_wcid_key_setup(&dev->mt76, &link->msta_link.wcid, key); + err = mt7996_set_hw_key(hw, cmd, vif, sta, link_id, key); if (err) break; -- 2.47.3