* [PATCH v2] wifi: mt76: mt7925: fix mt7925_reverse_frag0_hdr_trans() for MLO
@ 2026-11-16 8:14 Ziheng Wei
2026-11-16 8:45 ` Zhao Li
0 siblings, 1 reply; 2+ messages in thread
From: Ziheng Wei @ 2026-11-16 8:14 UTC (permalink / raw)
To: Felix Fietkau, Lorenzo Bianconi
Cc: Ryder Lee, Shayne Chen, Sean Wang, Zhao Li, linux-wireless,
linux-mediatek, linux-kernel, stable
For unicast frames mt792x_rx_get_wcid() returns the wcid of the
receiving link. Since commit 43aa4033eb18 ("wifi: mt76: mt7925: add
mt7925_change_sta_links") the wcid of a non-default station link is
embedded in a separately allocated struct mt792x_link_sta, not in
struct mt792x_sta. mt7925_reverse_frag0_hdr_trans() still casts
status->wcid to struct mt792x_sta and derives the ieee80211_sta from
it with container_of(), so for a frame received on such a link it
reads msta->vif past the end of the link allocation, dereferences the
result as a vif, and copies sta->addr from memory in front of it into
the rebuilt 802.11 header.
This path is taken for the first fragment of a header-translated
unicast frame, so it is reached when the AP sends fragmented data on
a secondary link while RX header translation is active there.
Do what commit a3ea1c309bf3 ("wifi: mt76: mt7996: Fix
mt7996_reverse_frag0_hdr_trans for MLO") did for mt7996: get the
station through the sta back pointer of the link and wcid_to_sta(),
and take the BSSID from the bss_conf of the receiving link.
The unicast path of mt792x_rx_get_wcid() returns the WTBL entry
unchecked, and not every entry is a station link: index 0 holds the
bare global wcid. Check wcid->sta before converting the wcid to
struct mt792x_link_sta, as the non-unicast path already does.
Found by LLM-assisted source review. Not tested on hardware.
Fixes: 43aa4033eb18 ("wifi: mt76: mt7925: add mt7925_change_sta_links")
Cc: stable@vger.kernel.org
Signed-off-by: Ziheng Wei <zihengw03@163.com>
---
Notes:
Changes in v2:
- Check status->wcid->sta before container_of(), so that a non-station
WTBL entry such as the global wcid at index 0 is never treated as
struct mt792x_link_sta; drop the now redundant !sta check
(suggested by Zhao Li)
- v1: https://lore.kernel.org/all/20261115080239.910402-1-zihengw03@163.com/
The changelog was drafted with an AI assistant from my analysis;
I have reviewed the code, the fix and the text.
drivers/net/wireless/mediatek/mt76/mt7925/mac.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
index 7af996abe..9a79b989b 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
@@ -184,9 +184,11 @@ static int mt7925_reverse_frag0_hdr_trans(struct sk_buff *skb, u16 hdr_gap)
{
struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;
struct ethhdr *eth_hdr = (struct ethhdr *)(skb->data + hdr_gap);
- struct mt792x_sta *msta = (struct mt792x_sta *)status->wcid;
+ struct ieee80211_bss_conf *link_conf;
+ struct mt792x_link_sta *mlink;
__le32 *rxd = (__le32 *)skb->data;
struct ieee80211_sta *sta;
+ struct mt792x_sta *msta;
struct ieee80211_vif *vif;
struct ieee80211_hdr hdr;
u16 frame_control;
@@ -198,11 +200,20 @@ static int mt7925_reverse_frag0_hdr_trans(struct sk_buff *skb, u16 hdr_gap)
if (!(le32_to_cpu(rxd[1]) & MT_RXD1_NORMAL_GROUP_4))
return -EINVAL;
+ /* not every WTBL entry is a station link, e.g. the global wcid */
+ if (!status->wcid || !status->wcid->sta)
+ return -EINVAL;
+
+ mlink = container_of(status->wcid, struct mt792x_link_sta, wcid);
+ msta = mlink->sta;
if (!msta || !msta->vif)
return -EINVAL;
- sta = container_of((void *)msta, struct ieee80211_sta, drv_priv);
+ sta = wcid_to_sta(status->wcid);
vif = container_of((void *)msta->vif, struct ieee80211_vif, drv_priv);
+ link_conf = rcu_dereference(vif->link_conf[mlink->wcid.link_id]);
+ if (!link_conf)
+ return -EINVAL;
/* store the info from RXD and ethhdr to avoid being overridden */
frame_control = le32_get_bits(rxd[8], MT_RXD8_FRAME_CONTROL);
@@ -215,7 +226,7 @@ static int mt7925_reverse_frag0_hdr_trans(struct sk_buff *skb, u16 hdr_gap)
switch (frame_control & (IEEE80211_FCTL_TODS |
IEEE80211_FCTL_FROMDS)) {
case 0:
- ether_addr_copy(hdr.addr3, vif->bss_conf.bssid);
+ ether_addr_copy(hdr.addr3, link_conf->bssid);
break;
case IEEE80211_FCTL_FROMDS:
ether_addr_copy(hdr.addr3, eth_hdr->h_source);
base-commit: 97d73c8251226cf27cc6656b4c542869bb8c69fa
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] wifi: mt76: mt7925: fix mt7925_reverse_frag0_hdr_trans() for MLO
2026-11-16 8:14 [PATCH v2] wifi: mt76: mt7925: fix mt7925_reverse_frag0_hdr_trans() for MLO Ziheng Wei
@ 2026-11-16 8:45 ` Zhao Li
0 siblings, 0 replies; 2+ messages in thread
From: Zhao Li @ 2026-11-16 8:45 UTC (permalink / raw)
To: Ziheng Wei
Cc: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
Sean Wang, linux-wireless, linux-mediatek, linux-kernel
Hi Ziheng,
On Mon, Nov 16, 2026 at 04:14:40PM +0800, Ziheng Wei wrote:
> + /* not every WTBL entry is a station link, e.g. the global wcid */
> + if (!status->wcid || !status->wcid->sta)
> + return -EINVAL;
> +
> + mlink = container_of(status->wcid, struct mt792x_link_sta, wcid);
> + msta = mlink->sta;
With the check ahead of the container_of(), the global wcid is rejected,
and wcid_to_sta() resolves a secondary link to its station through the
def_wcid that mt7925_mac_sta_add_links() sets.
Reviewed-by: Zhao Li <enderaoelyther@gmail.com>
Thanks,
Zhao
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-16 8:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16 8:14 [PATCH v2] wifi: mt76: mt7925: fix mt7925_reverse_frag0_hdr_trans() for MLO Ziheng Wei
2026-11-16 8:45 ` Zhao Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®