Skip to content

wifi: mt76: add missing skb length validation

Aviel Zohar linux-mediatek linux-wireless 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2wifi: mt76: mt7925: validate skb length in testmode querydrivers/net/wireless/mediatek/mt76/mt7925/testmode.c+5 -00 replies
2/2wifi: mt76: mt7915: validate skb length in txpower SKU querydrivers/net/wireless/mediatek/mt76/mt7915/mcu.c+8 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] wifi: mt76: add missing skb length validation

This series addresses missing skb length validation in two mt76 drivers before memcpy operations on firmware MCU responses.

In both cases, the driver copies a fixed number of bytes from skb->data without first checking that skb->len is large enough. If the firmware returns a shorter-than-expected response (due to a bug, partial DMA transfer, or in the case of mt7925, a malicious USB device), the memcpy reads beyond the skb data buffer, causing a heap buffer over-read. The over-read data is subsequently returned to userspace.

Patch 1: mt7925 testmode - mt7925_tm_query() copies 512 bytes (MT7925_EVT_RSP_LEN) from skb->data + 8 without verifying skb->len >= 520. The leaked data is returned via nla_put() through nl80211 testmode dump. Fix adds a length check before the memcpy.

Patch 2: mt7915 txpower - mt7915_mcu_get_txpower_sku() copies up to 322 bytes (MT7915_SKU_RATE_NUM * 2) from skb->data + 4 without verifying skb->len. The data surfaces through debugfs (txpower_sku, txpower_path). Fix adds length checks for both the TX_POWER_INFO_RATE and TX_POWER_INFO_PATH code paths.

Both fixes follow the same pattern: validate skb->len before performing the memcpy, returning -EINVAL on insufficient data.

Tested by code inspection; I do not have the hardware to run-test these changes.

Aviel Zohar (2):
wifi: mt76: mt7925: validate skb length in testmode query
wifi: mt76: mt7915: validate skb length in txpower SKU query

 drivers/net/wireless/mediatek/mt76/mt7925/testmode.c | 5 +++++
 drivers/net/wireless/mediatek/mt76/mt7915/mcu.c      | 8 ++++++++
 2 files changed, 13 insertions(+)
Signature · 1 line
2.34.1