* [PATCH 00/10] wifi: mt76: validate legacy MCU responses
@ 2026-10-19 10:14 Jiale Yao
2026-10-19 10:14 ` [PATCH 01/10] wifi: mt76: mt7603: validate MCU response length Jiale Yao
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: Jiale Yao @ 2026-10-19 10:14 UTC (permalink / raw)
To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno, YF Luo,
Chih-Min Chen, Money Wang, MeiChia Chiu, Bo Jiao, Peter Chiu,
linux-wireless, linux-kernel, linux-arm-kernel, linux-mediatek
Cc: Jiale Yao
Several mt7603, mt7615, and mt7915 MCU response paths trust firmware
response sizes before reading receive descriptors, fixed fields, or
arrays. A truncated response can therefore cause an out-of-bounds read.
Validate the common response descriptors and each command-specific
payload before accessing or removing data from the skb.
Jiale Yao (10):
wifi: mt76: mt7603: validate MCU response length
wifi: mt76: mt7615: validate MCU response lengths
wifi: mt76: mt7915: validate MCU response lengths
wifi: mt76: mt7915: validate MURU statistics response
wifi: mt76: mt7915: validate EEPROM response length
wifi: mt76: mt7915: validate free-block response length
wifi: mt76: mt7915: validate channel MIB response length
wifi: mt76: mt7915: validate RX rate response length
wifi: mt76: mt7915: validate WED TX statistics response
wifi: mt76: mt7915: validate RF register response length
.../net/wireless/mediatek/mt76/mt7603/mcu.c | 2 +
.../net/wireless/mediatek/mt76/mt7615/mcu.c | 17 ++++++++
.../net/wireless/mediatek/mt76/mt7915/mcu.c | 43 +++++++++++++++++--
3 files changed, 59 insertions(+), 3 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 01/10] wifi: mt76: mt7603: validate MCU response length
2026-10-19 10:14 [PATCH 00/10] wifi: mt76: validate legacy MCU responses Jiale Yao
@ 2026-10-19 10:14 ` Jiale Yao
2026-10-19 10:14 ` [PATCH 02/10] wifi: mt76: mt7615: validate MCU response lengths Jiale Yao
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jiale Yao @ 2026-10-19 10:14 UTC (permalink / raw)
To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
linux-wireless, linux-kernel, linux-arm-kernel, linux-mediatek
Cc: Jiale Yao
The MCU response parser reads the sequence number from the receive
descriptor without first ensuring that the descriptor is present. A
truncated firmware response can therefore cause an out-of-bounds read.
Reject responses shorter than the receive descriptor before accessing
the sequence number.
Fixes: f320d812b7bb ("mt76: implement .mcu_parse_response in struct mt76_mcu_ops")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
drivers/net/wireless/mediatek/mt76/mt7603/mcu.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7603/mcu.c
index e432cce97640..b231fb2d3752 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7603/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7603/mcu.c
@@ -26,6 +26,8 @@ mt7603_mcu_parse_response(struct mt76_dev *mdev, int cmd,
dev->mcu_hang = MT7603_WATCHDOG_TIMEOUT;
return -ETIMEDOUT;
}
+ if (skb->len < sizeof(*rxd))
+ return -EINVAL;
rxd = (struct mt7603_mcu_rxd *)skb->data;
if (seq != rxd->seq)
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 02/10] wifi: mt76: mt7615: validate MCU response lengths
2026-10-19 10:14 [PATCH 00/10] wifi: mt76: validate legacy MCU responses Jiale Yao
2026-10-19 10:14 ` [PATCH 01/10] wifi: mt76: mt7603: validate MCU response length Jiale Yao
@ 2026-10-19 10:14 ` Jiale Yao
2026-10-19 10:14 ` [PATCH 03/10] wifi: mt76: mt7915: " Jiale Yao
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jiale Yao @ 2026-10-19 10:14 UTC (permalink / raw)
To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
linux-wireless, linux-kernel, linux-arm-kernel, linux-mediatek
Cc: Jiale Yao
The MCU response parser reads descriptor and command payload fields
without checking whether they are present. Truncated firmware responses
can therefore cause out-of-bounds reads.
Validate the descriptor and the command-specific payload before reading
or removing them from the skb.
Fixes: 0e6a29e477f3 ("mt76: mt7615: add support to read temperature from mcu")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
index ff57ede87f71..4e33c6a618f1 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
@@ -143,6 +143,11 @@ int mt7615_mcu_parse_response(struct mt76_dev *mdev, int cmd,
cmd, seq);
return -ETIMEDOUT;
}
+ if (cmd == MCU_CMD(PATCH_SEM_CONTROL) &&
+ skb->len < sizeof(*rxd) - 4 + sizeof(u8))
+ return -EINVAL;
+ if (cmd != MCU_CMD(PATCH_SEM_CONTROL) && skb->len < sizeof(*rxd))
+ return -EINVAL;
rxd = (struct mt7615_mcu_rxd *)skb->data;
if (seq != rxd->seq)
@@ -152,9 +157,15 @@ int mt7615_mcu_parse_response(struct mt76_dev *mdev, int cmd,
skb_pull(skb, sizeof(*rxd) - 4);
ret = *skb->data;
} else if (cmd == MCU_EXT_CMD(THERMAL_CTRL)) {
+ if (skb->len < sizeof(*rxd) + sizeof(__le32))
+ return -EINVAL;
+
skb_pull(skb, sizeof(*rxd));
ret = le32_to_cpu(*(__le32 *)skb->data);
} else if (cmd == MCU_EXT_QUERY(RF_REG_ACCESS)) {
+ if (skb->len < sizeof(*rxd) + 8 + sizeof(__le32))
+ return -EINVAL;
+
skb_pull(skb, sizeof(*rxd));
ret = le32_to_cpu(*(__le32 *)&skb->data[8]);
} else if (cmd == MCU_UNI_CMD(DEV_INFO_UPDATE) ||
@@ -165,12 +176,18 @@ int mt7615_mcu_parse_response(struct mt76_dev *mdev, int cmd,
cmd == MCU_UNI_CMD(SUSPEND)) {
struct mt76_connac_mcu_uni_event *event;
+ if (skb->len < sizeof(*rxd) + sizeof(*event))
+ return -EINVAL;
+
skb_pull(skb, sizeof(*rxd));
event = (struct mt76_connac_mcu_uni_event *)skb->data;
ret = le32_to_cpu(event->status);
} else if (cmd == MCU_CE_QUERY(REG_READ)) {
struct mt76_connac_mcu_reg_event *event;
+ if (skb->len < sizeof(*rxd) + sizeof(*event))
+ return -EINVAL;
+
skb_pull(skb, sizeof(*rxd));
event = (struct mt76_connac_mcu_reg_event *)skb->data;
ret = (int)le32_to_cpu(event->val);
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 03/10] wifi: mt76: mt7915: validate MCU response lengths
2026-10-19 10:14 [PATCH 00/10] wifi: mt76: validate legacy MCU responses Jiale Yao
2026-10-19 10:14 ` [PATCH 01/10] wifi: mt76: mt7603: validate MCU response length Jiale Yao
2026-10-19 10:14 ` [PATCH 02/10] wifi: mt76: mt7615: validate MCU response lengths Jiale Yao
@ 2026-10-19 10:14 ` Jiale Yao
2026-10-19 10:14 ` [PATCH 04/10] wifi: mt76: mt7915: validate MURU statistics response Jiale Yao
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jiale Yao @ 2026-10-19 10:14 UTC (permalink / raw)
To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno, YF Luo,
Yiwei Chung, Chih-Min Chen, linux-wireless, linux-kernel,
linux-arm-kernel, linux-mediatek
Cc: Jiale Yao
The MCU response parser accesses receive descriptor fields and some
command payloads without checking their lengths. A truncated firmware
response can therefore cause an out-of-bounds read.
Validate the descriptor and the patch semaphore and thermal payloads
before accessing them.
Fixes: e57b7901469f ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index 5bfe0366562f..3643906cbdf2 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -174,6 +174,11 @@ mt7915_mcu_parse_response(struct mt76_dev *mdev, int cmd,
return -ETIMEDOUT;
}
+ if (cmd == MCU_CMD(PATCH_SEM_CONTROL) &&
+ skb->len < sizeof(*rxd) - 4 + sizeof(u8))
+ return -EINVAL;
+ if (cmd != MCU_CMD(PATCH_SEM_CONTROL) && skb->len < sizeof(*rxd))
+ return -EINVAL;
rxd = (struct mt76_connac2_mcu_rxd *)skb->data;
if (seq != rxd->seq &&
@@ -185,6 +190,9 @@ mt7915_mcu_parse_response(struct mt76_dev *mdev, int cmd,
skb_pull(skb, sizeof(*rxd) - 4);
ret = *skb->data;
} else if (cmd == MCU_EXT_CMD(THERMAL_CTRL)) {
+ if (skb->len < sizeof(*rxd) + 4 + sizeof(__le32))
+ return -EINVAL;
+
skb_pull(skb, sizeof(*rxd) + 4);
ret = le32_to_cpu(*(__le32 *)skb->data);
} else {
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 04/10] wifi: mt76: mt7915: validate MURU statistics response
2026-10-19 10:14 [PATCH 00/10] wifi: mt76: validate legacy MCU responses Jiale Yao
` (2 preceding siblings ...)
2026-10-19 10:14 ` [PATCH 03/10] wifi: mt76: mt7915: " Jiale Yao
@ 2026-10-19 10:14 ` Jiale Yao
2026-10-19 10:15 ` [PATCH 05/10] wifi: mt76: mt7915: validate EEPROM response length Jiale Yao
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jiale Yao @ 2026-10-19 10:14 UTC (permalink / raw)
To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
Money Wang, MeiChia Chiu, linux-wireless, linux-kernel,
linux-arm-kernel, linux-mediatek
Cc: Jiale Yao
mt7915_mcu_muru_debug_get() treats the firmware response as a complete
statistics structure without checking its length. A truncated response
can cause out-of-bounds reads while accumulating the counters.
Reject responses shorter than the expected statistics structure.
Fixes: 1966a5078f2d ("mt76: mt7915: add mu-mimo and ofdma debugfs knobs")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index 3643906cbdf2..6d777dcfa2c1 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -2256,6 +2256,10 @@ int mt7915_mcu_muru_debug_get(struct mt7915_phy *phy)
&req, sizeof(req), true, &skb);
if (ret)
return ret;
+ if (skb->len < sizeof(*mu_stats)) {
+ dev_kfree_skb(skb);
+ return -EINVAL;
+ }
mu_stats = (struct mt7915_mcu_muru_stats *)(skb->data);
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 05/10] wifi: mt76: mt7915: validate EEPROM response length
2026-10-19 10:14 [PATCH 00/10] wifi: mt76: validate legacy MCU responses Jiale Yao
` (3 preceding siblings ...)
2026-10-19 10:14 ` [PATCH 04/10] wifi: mt76: mt7915: validate MURU statistics response Jiale Yao
@ 2026-10-19 10:15 ` Jiale Yao
2026-10-19 10:15 ` [PATCH 06/10] wifi: mt76: mt7915: validate free-block " Jiale Yao
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jiale Yao @ 2026-10-19 10:15 UTC (permalink / raw)
To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
Chih-Min Chen, YF Luo, linux-wireless, linux-kernel,
linux-arm-kernel, linux-mediatek
Cc: Jiale Yao
The EEPROM query copies a complete firmware response block without
checking that the response contains the address and data fields. A
truncated response can cause an out-of-bounds read.
Require the complete EEPROM response structure before processing it.
Fixes: e57b7901469f ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index 6d777dcfa2c1..7009a3a3edd2 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -2945,6 +2945,10 @@ int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset, u8 *read_buf)
&req, sizeof(req), true, &skb);
if (ret)
return ret;
+ if (skb->len < sizeof(*res)) {
+ dev_kfree_skb(skb);
+ return -EINVAL;
+ }
res = (struct mt7915_mcu_eeprom_info *)skb->data;
if (!buf) {
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 06/10] wifi: mt76: mt7915: validate free-block response length
2026-10-19 10:14 [PATCH 00/10] wifi: mt76: validate legacy MCU responses Jiale Yao
` (4 preceding siblings ...)
2026-10-19 10:15 ` [PATCH 05/10] wifi: mt76: mt7915: validate EEPROM response length Jiale Yao
@ 2026-10-19 10:15 ` Jiale Yao
2026-10-19 10:15 ` [PATCH 07/10] wifi: mt76: mt7915: validate channel MIB " Jiale Yao
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jiale Yao @ 2026-10-19 10:15 UTC (permalink / raw)
To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno, Bo Jiao,
linux-wireless, linux-kernel, linux-arm-kernel, linux-mediatek
Cc: Jiale Yao
The free-block query reads the first response byte without checking that
the firmware returned any payload. A zero-length response can therefore
cause an out-of-bounds read.
Require the block-count byte before accessing it.
Fixes: bbc1d4154ec1 ("mt76: mt7915: add default calibrated data support")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index 7009a3a3edd2..05614b99165b 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -2985,6 +2985,10 @@ int mt7915_mcu_get_eeprom_free_block(struct mt7915_dev *dev, u8 *block_num)
&req, sizeof(req), true, &skb);
if (ret)
return ret;
+ if (skb->len < sizeof(*block_num)) {
+ dev_kfree_skb(skb);
+ return -EINVAL;
+ }
*block_num = *(u8 *)skb->data;
dev_kfree_skb(skb);
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 07/10] wifi: mt76: mt7915: validate channel MIB response length
2026-10-19 10:14 [PATCH 00/10] wifi: mt76: validate legacy MCU responses Jiale Yao
` (5 preceding siblings ...)
2026-10-19 10:15 ` [PATCH 06/10] wifi: mt76: mt7915: validate free-block " Jiale Yao
@ 2026-10-19 10:15 ` Jiale Yao
2026-10-19 10:15 ` [PATCH 08/10] wifi: mt76: mt7915: validate RX rate " Jiale Yao
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jiale Yao @ 2026-10-19 10:15 UTC (permalink / raw)
To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
linux-wireless, linux-kernel, linux-arm-kernel, linux-mediatek
Cc: Jiale Yao
The channel survey query reads several MIB entries at a chip-specific
offset without checking that the firmware response reaches those
entries. A truncated response can cause out-of-bounds reads.
Validate the offset and complete MIB array before processing it.
Fixes: 654300281196 ("mt76: mt7915: use mt7915_mcu_get_mib_info() to get survey data")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index 05614b99165b..955c0e6c7cb6 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -3239,6 +3239,10 @@ int mt7915_mcu_get_chan_mib_info(struct mt7915_phy *phy, bool chan_switch)
req, len * sizeof(req[0]), true, &skb);
if (ret)
return ret;
+ if (skb->len < offs_cc + len * sizeof(*res)) {
+ dev_kfree_skb(skb);
+ return -EINVAL;
+ }
res = (struct mt7915_mcu_mib *)(skb->data + offs_cc);
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 08/10] wifi: mt76: mt7915: validate RX rate response length
2026-10-19 10:14 [PATCH 00/10] wifi: mt76: validate legacy MCU responses Jiale Yao
` (6 preceding siblings ...)
2026-10-19 10:15 ` [PATCH 07/10] wifi: mt76: mt7915: validate channel MIB " Jiale Yao
@ 2026-10-19 10:15 ` Jiale Yao
2026-10-19 10:15 ` [PATCH 09/10] wifi: mt76: mt7915: validate WED TX statistics response Jiale Yao
2026-10-20 2:23 ` [PATCH 10/10] wifi: mt76: mt7915: validate RF register response length Jiale Yao
9 siblings, 0 replies; 11+ messages in thread
From: Jiale Yao @ 2026-10-19 10:15 UTC (permalink / raw)
To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
linux-wireless, linux-kernel, linux-arm-kernel, linux-mediatek
Cc: Jiale Yao
The RX rate query reads a complete PHY information structure without
checking the response length. A truncated firmware response can cause
out-of-bounds reads while decoding the rate.
Require the complete PHY RX information structure before using it.
Fixes: 11553d88d0b9 ("mt76: mt7915: query station rx rate from firmware")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index 955c0e6c7cb6..00a528694255 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -3942,6 +3942,10 @@ int mt7915_mcu_get_rx_rate(struct mt7915_phy *phy, struct ieee80211_vif *vif,
&req, sizeof(req), true, &skb);
if (ret)
return ret;
+ if (skb->len < sizeof(*res)) {
+ dev_kfree_skb(skb);
+ return -EINVAL;
+ }
res = (struct mt7915_mcu_phy_rx_info *)skb->data;
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 09/10] wifi: mt76: mt7915: validate WED TX statistics response
2026-10-19 10:14 [PATCH 00/10] wifi: mt76: validate legacy MCU responses Jiale Yao
` (7 preceding siblings ...)
2026-10-19 10:15 ` [PATCH 08/10] wifi: mt76: mt7915: validate RX rate " Jiale Yao
@ 2026-10-19 10:15 ` Jiale Yao
2026-10-20 2:23 ` [PATCH 10/10] wifi: mt76: mt7915: validate RF register response length Jiale Yao
9 siblings, 0 replies; 11+ messages in thread
From: Jiale Yao @ 2026-10-19 10:15 UTC (permalink / raw)
To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
Peter Chiu, linux-wireless, linux-kernel, linux-arm-kernel,
linux-mediatek
Cc: Jiale Yao
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@163.com>
---
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
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 10/10] wifi: mt76: mt7915: validate RF register response length
2026-10-19 10:14 [PATCH 00/10] wifi: mt76: validate legacy MCU responses Jiale Yao
` (8 preceding siblings ...)
2026-10-19 10:15 ` [PATCH 09/10] wifi: mt76: mt7915: validate WED TX statistics response Jiale Yao
@ 2026-10-20 2:23 ` Jiale Yao
9 siblings, 0 replies; 11+ messages in thread
From: Jiale Yao @ 2026-10-20 2:23 UTC (permalink / raw)
To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
Peter Chiu, linux-wireless, linux-kernel, linux-arm-kernel,
linux-mediatek
Cc: Jiale Yao
The RF register query reads a 32-bit value after an eight-byte response
prefix without checking the skb length. A truncated firmware response
can cause an out-of-bounds read.
Require the prefix and register value before accessing the response.
Fixes: 0a17329ae9c1 ("mt76: mt7915: add debugfs knob for RF registers read/write")
Signed-off-by: Jiale Yao <yaojiale_2026@qq.com>
---
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index 4a11a4a0dbde..650ee9134ddf 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -4256,6 +4256,10 @@ int mt7915_mcu_rf_regval(struct mt7915_dev *dev, u32 regidx, u32 *val, bool set)
&req, sizeof(req), true, &skb);
if (ret)
return ret;
+ if (skb->len < 8 + sizeof(__le32)) {
+ dev_kfree_skb(skb);
+ return -EINVAL;
+ }
*val = le32_to_cpu(*(__le32 *)(skb->data + 8));
dev_kfree_skb(skb);
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-10-20 2:23 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-19 10:14 [PATCH 00/10] wifi: mt76: validate legacy MCU responses Jiale Yao
2026-10-19 10:14 ` [PATCH 01/10] wifi: mt76: mt7603: validate MCU response length Jiale Yao
2026-10-19 10:14 ` [PATCH 02/10] wifi: mt76: mt7615: validate MCU response lengths Jiale Yao
2026-10-19 10:14 ` [PATCH 03/10] wifi: mt76: mt7915: " Jiale Yao
2026-10-19 10:14 ` [PATCH 04/10] wifi: mt76: mt7915: validate MURU statistics response Jiale Yao
2026-10-19 10:15 ` [PATCH 05/10] wifi: mt76: mt7915: validate EEPROM response length Jiale Yao
2026-10-19 10:15 ` [PATCH 06/10] wifi: mt76: mt7915: validate free-block " Jiale Yao
2026-10-19 10:15 ` [PATCH 07/10] wifi: mt76: mt7915: validate channel MIB " Jiale Yao
2026-10-19 10:15 ` [PATCH 08/10] wifi: mt76: mt7915: validate RX rate " Jiale Yao
2026-10-19 10:15 ` [PATCH 09/10] wifi: mt76: mt7915: validate WED TX statistics response Jiale Yao
2026-10-20 2:23 ` [PATCH 10/10] wifi: mt76: mt7915: validate RF register response length Jiale Yao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox