From: Felix Fietkau <nbd@nbd.name>
To: linux-wireless@vger.kernel.org
Subject: [PATCH mt76-next 09/16] wifi: mt76: mt7615: reset the group RX PN counters at WoWLAN resume
Date: Thu, 26 Nov 2026 19:23:18 +0100 [thread overview]
Message-ID: <20261126182325.2516607-9-nbd@nbd.name> (raw)
In-Reply-To: <20261126182325.2516607-1-nbd@nbd.name>
With GTK rekey offload, the firmware can renew the GTK during WoWLAN
suspend without reporting it. If the new key reuses a key id whose
counters hold the PN of an earlier key, its frames read as replays after
resume.
At resume, zero the group counters of an interface that gave rekey data
to the firmware. Where the link held a group key with a PN check, also
check key ids 1 to 3, since the new key can use any of them. Forget the
key ids at the end of an association, so that a reassociation without
such a key arms no check. After resume, a replay with a nonzero PN
passes until the first genuine frame of its key id and TID.
Fixes: b47e21e75c80 ("mt76: mt7615: add gtk rekey offload support")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt76.h | 10 +++++++
.../net/wireless/mediatek/mt76/mt7615/main.c | 28 +++++++++++++++----
.../wireless/mediatek/mt76/mt7615/mt7615.h | 1 +
3 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index e2156d7c1108..d635df2cece2 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -1679,6 +1679,16 @@ mt76_rx_group_wcid(struct mt76_wcid *wcid)
return wcid;
}
+static inline void
+mt76_rx_group_pn_reset(struct mt76_rx_group_pn *group_pn)
+{
+ memset(group_pn->pn, 0, sizeof(group_pn->pn));
+
+ /* the firmware can renew the GTK in suspend under another key id */
+ if (group_pn->key_mask)
+ group_pn->key_mask |= GENMASK(3, 1);
+}
+
void mt76_wcid_key_setup(struct mt76_dev *dev, struct mt76_wcid *wcid,
struct ieee80211_key_conf *key);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/main.c b/drivers/net/wireless/mediatek/mt76/mt7615/main.c
index 7af53894edd1..425640b575d2 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/main.c
@@ -573,6 +573,7 @@ static void mt7615_bss_info_changed(struct ieee80211_hw *hw,
struct ieee80211_bss_conf *info,
u64 changed)
{
+ struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
struct mt7615_dev *dev = mt7615_hw_dev(hw);
struct mt7615_phy *phy = mt7615_hw_phy(hw);
@@ -607,15 +608,17 @@ static void mt7615_bss_info_changed(struct ieee80211_hw *hw,
mt76_connac_mcu_set_vif_ps(&dev->mt76, vif);
if ((changed & BSS_CHANGED_ARP_FILTER) &&
- mt7615_firmware_offload(dev)) {
- struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
-
+ mt7615_firmware_offload(dev))
mt76_connac_mcu_update_arp_filter(&dev->mt76, &mvif->mt76,
info);
- }
- if (changed & BSS_CHANGED_ASSOC)
+ if (changed & BSS_CHANGED_ASSOC) {
mt7615_mac_set_beacon_filter(phy, vif, vif->cfg.assoc);
+ if (!vif->cfg.assoc) {
+ mvif->gtk_rekey_offload = false;
+ mvif->mt76.rx_group_pn.key_mask = 0;
+ }
+ }
if (changed & BSS_CHANGED_MU_GROUPS)
mt7615_update_mu_group(hw, vif, info);
@@ -1264,6 +1267,15 @@ static int mt7615_suspend(struct ieee80211_hw *hw,
return err;
}
+static void
+mt7615_rx_group_pn_reset_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
+{
+ struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
+
+ if (mvif->gtk_rekey_offload)
+ mt76_rx_group_pn_reset(&mvif->mt76.rx_group_pn);
+}
+
static int mt7615_resume(struct ieee80211_hw *hw)
{
struct mt7615_phy *phy = mt7615_hw_phy(hw);
@@ -1287,6 +1299,10 @@ static int mt7615_resume(struct ieee80211_hw *hw)
}
clear_bit(MT76_STATE_SUSPEND, &phy->mt76->state);
+ ieee80211_iterate_active_interfaces(hw,
+ IEEE80211_IFACE_ITER_RESUME_ALL,
+ mt7615_rx_group_pn_reset_iter,
+ NULL);
ieee80211_iterate_active_interfaces(hw,
IEEE80211_IFACE_ITER_RESUME_ALL,
mt76_connac_mcu_set_suspend_iter,
@@ -1312,10 +1328,12 @@ static void mt7615_set_rekey_data(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct cfg80211_gtk_rekey_data *data)
{
+ struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
struct mt7615_dev *dev = mt7615_hw_dev(hw);
mt7615_mutex_acquire(dev);
mt76_connac_mcu_update_gtk_rekey(hw, vif, data);
+ mvif->gtk_rekey_offload = true;
mt7615_mutex_release(dev);
}
#endif /* CONFIG_PM */
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
index 391928405f32..121a4fb690ef 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
@@ -143,6 +143,7 @@ struct mt7615_vif {
struct mt76_vif_link mt76; /* must be first */
struct mt7615_sta sta;
bool sta_added;
+ bool gtk_rekey_offload;
};
struct mib_stats {
--
2.47.3
next prev parent reply other threads:[~2026-11-26 18:23 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 18:23 [PATCH mt76-next 01/16] wifi: mt76: keep the Null frame of an AP on its AC queue Felix Fietkau
2026-11-26 18:23 ` [PATCH mt76-next 02/16] wifi: mt76: mt7996: limit the HE and EHT maps of a peer to its rx_nss Felix Fietkau
2026-11-26 18:23 ` [PATCH mt76-next 03/16] wifi: mt76: mt7915: send the current SM power save mode in STA_REC_HT Felix Fietkau
2026-11-26 18:23 ` [PATCH mt76-next 04/16] wifi: mt76: mt7996: take the HE caps of the band of each link Felix Fietkau
2026-11-26 18:23 ` [PATCH mt76-next 05/16] wifi: mt76: mt7915: count the WA TX statistics from an unsolicited event Felix Fietkau
2026-11-26 18:23 ` [PATCH mt76-next 06/16] wifi: mt76: keep an RX replay counter per group key id and TID Felix Fietkau
2026-11-26 18:23 ` [PATCH mt76-next 07/16] wifi: mt76: mt7996: check the RX PN of group addressed frames Felix Fietkau
2026-11-26 18:23 ` [PATCH mt76-next 08/16] wifi: mt76: mt7615: " Felix Fietkau
2026-11-26 18:23 ` Felix Fietkau [this message]
2026-11-26 18:23 ` [PATCH mt76-next 10/16] wifi: mt76: mt7915: " Felix Fietkau
2026-11-26 18:23 ` [PATCH mt76-next 11/16] wifi: mt76: mt792x: " Felix Fietkau
2026-11-26 18:23 ` [PATCH mt76-next 12/16] wifi: mt76: mt792x: reset the group RX PN counters at WoWLAN resume Felix Fietkau
2026-11-26 18:23 ` [PATCH mt76-next 13/16] wifi: mt76: mt7603: check the RX PN of group addressed frames Felix Fietkau
2026-11-26 18:23 ` [PATCH mt76-next 14/16] wifi: mt76: mt76x02: find no station for the group wcid of a vif Felix Fietkau
2026-11-26 18:23 ` [PATCH mt76-next 15/16] wifi: mt76: mt7915: stop resets before the hw is unregistered Felix Fietkau
2026-11-26 18:23 ` [PATCH mt76-next 16/16] wifi: mt76: mt7996: " Felix Fietkau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261126182325.2516607-9-nbd@nbd.name \
--to=nbd@nbd.name \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox