wifi: ath11k/ath12k: bound READY MAC address array reads
v2 cover wifi: ath11k/ath12k: bound READY MAC address array reads
ath11k_wmi_tlv_rdy_parse() and ath12k_wmi_rdy_parse() copy one MAC address per radio from the READY event's fixed-struct array after checking only the count advertised in the fixed record, not the array TLV length. A firmware READY event with a short array makes the copy read past the end of the TLV value.
These patches check the array length first and fall back to the driver's default per-radio addresses when it is too short.
Found while bringing up an IPQ8074 v1 device with older firmware; the issue is not specific to that hardware. Verified with a userspace harness around the unmodified parsers under AddressSanitizer. Compile tested on ath-next (W=1). The ath11k change has also run on an IPQ8074 hw1.0 board on every boot since 16 Oct; its firmware sends a well-formed array, so that covers the normal path only. The ath12k change is compile tested only. Neither has been tested on hardware with a malformed event.
Jeff, following your pointers on my earlier ath12k RX-ring RFC, these carry a full-name sign-off, an Assisted-by tag, and state the testing explicitly. This work was developed with AI assistance.
---
Changes in v2:
- Drop RFC.
- ath11k: note the hardware run and add a Tested-on tag; no code change.
- v1 was accidentally sent twice; apologies for the duplicate.
- Link to v1: https://patch.msgid.link/[email protected]
---
John Macias (2):
wifi: ath11k: bound READY MAC address array reads
wifi: ath12k: bound READY MAC address array reads
drivers/net/wireless/ath/ath11k/wmi.c | 6 ++++++ drivers/net/wireless/ath/ath12k/wmi.c | 6 ++++++ 2 files changed, 12 insertions(+)
---
base-commit: cd026e68fdbf88b9cc522b76c7a9d92c9a41f709
change-id: 20261015-rdy-mac-array-bounds-de70c7750217
Best regards,
Signature · 1 line
John Macias <[email protected]>
PATCH v2 1/2 wifi: ath11k: bound READY MAC address array reads
The READY event carries a fixed record whose num_extra_mac_addr field advertises how many per-radio MAC addresses follow, and a separate WMI_TAG_ARRAY_FIXED_STRUCT TLV holding that array. The TLV iterator only ensures that the array TLV fits inside the event; ath11k_wmi_tlv_rdy_parse() then copies one address per radio without checking that the array really holds num_radios entries.
If firmware advertises at least num_radios extra addresses but sends a shorter array, for example two radios with an eight-byte array, the second ether_addr_copy() reads past the end of the TLV value.
Check the array length against num_radios before copying. When it is too short, warn and leave pdevs_macaddr_valid unset, so the driver falls back to deriving the per-radio addresses as it does when no array is provided, instead of failing READY processing.
Found by code review while bringing up a device with older firmware; a userspace harness that includes the unmodified parser reports a 6-byte heap-buffer-overflow read under AddressSanitizer for this input, and the fixed parser passes. Compile tested on ath-next (W=1). The same change has also run on an IPQ8074 hw1.0 board (with out-of-tree enablement patches) on every boot since 16 Oct 2026; that firmware sends a well-formed array, so this exercises only the normal path, which still assigns both per-radio addresses and prints no warning.
Tested-on: IPQ8074 hw1.0 AHB WLAN.HK.2.0-01792-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath11k/wmi.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/wireless/ath/ath11k/wmi.c +6 -0
@@ -7330,6 +7330,12 @@ static int ath11k_wmi_tlv_rdy_parse(struct ath11k_base *ab, u16 tag, u16 len,if (!(ab->num_radios >1 && num_mac_addr >= ab->num_radios))break ; +if (len < ab->num_radios *sizeof (*addr_list)) { +ath11k_warn (ab,"ready event mac address array too short: %u bytes for %d radios\n" , + len, ab->num_radios); +break ; + } +for (i =0 ; i < ab->num_radios; i++) { pdev = &ab->pdevs[i];ether_addr_copy (pdev->mac_addr, addr_list[i].addr);
Signature · 1 line
2.47.3
PATCH v2 2/2 wifi: ath12k: bound READY MAC address array reads
In reply to John Maciasath12k_wmi_rdy_parse() has the same pattern as ath11k: after checking that the READY fixed record advertises at least num_radios extra MAC addresses, it copies one address per radio from the WMI_TAG_ARRAY_FIXED_STRUCT TLV without checking that the TLV actually holds num_radios entries.
With two radios and an array shorter than two 8-byte entries, the second ether_addr_copy() reads past the end of the TLV value.
Check the array length against num_radios before copying. When it is too short, warn and leave pdevs_macaddr_valid unset, so the driver keeps its default per-radio addresses instead of failing READY processing.
A userspace harness that includes the unmodified parser reports a 6-byte heap-buffer-overflow read under AddressSanitizer for 8- and 12-byte arrays with two radios, and the fixed parser passes. Compile tested only (ath-next, W=1).
--- drivers/net/wireless/ath/ath12k/wmi.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/wireless/ath/ath12k/wmi.c +6 -0
@@ -7099,6 +7099,12 @@ static int ath12k_wmi_rdy_parse(struct ath12k_base *ab, u16 tag, u16 len,if (!(ab->num_radios >1 && num_mac_addr >= ab->num_radios))break ; +if (len < ab->num_radios *sizeof (*addr_list)) { +ath12k_warn (ab,"ready event mac address array too short: %u bytes for %d radios\n" , + len, ab->num_radios); +break ; + } +for (i =0 ; i < ab->num_radios; i++) { pdev = &ab->pdevs[i];ether_addr_copy (pdev->mac_addr, addr_list[i].addr);
Signature · 1 line
2.47.3