]> git.hungrycats.org Git - linux/commit
wifi: mt76: mt7915: validate skb length in txpower SKU query
authorAviel Zohar <avielzohar123@gmail.com>
Mon, 13 Apr 2026 03:31:35 +0000 (06:31 +0300)
committerFelix Fietkau <nbd@nbd.name>
Tue, 9 Jun 2026 10:15:22 +0000 (10:15 +0000)
commit4497665cf4f680f8befbe3c980c93917a195d26b
treed434455d4fac763a80a11beb9a52a3afcb99d2e0
parentc7369a00860a0704461d440e7c3bf9b49bfdbaee
wifi: mt76: mt7915: validate skb length in txpower SKU query

In mt7915_mcu_get_txpower_sku(), the response skb from
mt76_mcu_send_and_get_msg() is used in memcpy without validating
its length:

For TX_POWER_INFO_RATE:
  memcpy(res, skb->data + 4, sizeof(res));

where sizeof(res) is MT7915_SKU_RATE_NUM * 2 = 322 bytes.

For TX_POWER_INFO_PATH:
  memcpy(txpower, skb->data + 4, len);

In both cases, if the firmware returns a response shorter than
the expected size, the memcpy reads beyond the skb data buffer.
The data surfaces to userspace via debugfs (txpower_sku and
txpower_path).

Add length checks for both code paths before the memcpy.

Signed-off-by: Aviel Zohar <avielzohar123@gmail.com>
Link: https://patch.msgid.link/20260413033136.5417-3-avielzohar123@gmail.com
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c