[PATCH 09/10] wifi: mt76: mt7915: validate WED TX statistics response

From: Jiale Yao

Date: Mon Oct 19 2026 - 06:32:19 EST


The WED statistics query optionally skips a response prefix and then
reads a fixed statistics structure without validating either range. A
truncated firmware response can cause out-of-bounds reads.

Calculate the chip-specific prefix and require the complete response
before pulling the prefix.

Fixes: 161a7528e407 ("wifi: mt76: mt7915: rework tx packets counting when WED is active")
Signed-off-by: Jiale Yao <yaojiale02@xxxxxxx>
---
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index 00a528694255..4a11a4a0dbde 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -4183,7 +4183,7 @@ int mt7915_mcu_wed_wa_tx_stats(struct mt7915_dev *dev, u16 wlan_idx)
} __packed *res;
struct mt76_wcid *wcid;
struct sk_buff *skb;
- int ret, len;
+ int ret, len, offset;
u16 ret_wcid;

if (is_mt7915(&dev->mt76)) {
@@ -4200,8 +4200,13 @@ int mt7915_mcu_wed_wa_tx_stats(struct mt7915_dev *dev, u16 wlan_idx)
if (ret)
return ret;

- if (!is_mt7915(&dev->mt76))
- skb_pull(skb, 4);
+ offset = is_mt7915(&dev->mt76) ? 0 : 4;
+ if (skb->len < offset + sizeof(*res)) {
+ dev_kfree_skb(skb);
+ return -EINVAL;
+ }
+
+ skb_pull(skb, offset);

res = (struct mt7915_mcu_wa_tx_stat *)skb->data;

--
2.34.1