[PATCH 0/3] wifi: ar5523: fix three command path bugs
From: Alexandre Becholey
Date: Mon Nov 16 2026 - 02:53:31 EST
Hi,
Three bugs in the ar5523 command path, all reachable from a USB device
that presents itself as an AR5523, and all reproduced with an emulated
device (raw-gadget/dummy_hcd and QEMU's xHCI) under KASAN on
torvalds/master (v7.4-rc2-141-g9d66f26fefac) and on v7.3.1:
1/3 ar5523_read_reply() hits WARN_ON(1) on a short reply: a header
length below the header size (or with bit 31 set) makes the
payload length negative. The device triggers it during probe by
answering the first read command (WDCMSG_HOST_AVAILABLE) with such
a reply, or later with an unsolicited one. The command also
completes with the result of the previous command.
2/3 ar5523_cmd() returns while the command TX URB is still in flight
when the device sends the reply without taking the command on its
bulk OUT endpoint. If that reply fails the command, probe unwinds
and frees the command buffer and struct ar5523 under the queued
URB; when the URB completes later (the device takes the command,
or is unplugged), the host controller and ar5523_cmd_tx_cb() use
the freed memory (use-after-free). The device does this on its own
at plug-in.
3/3 ar5523_cmd() leaves the caller's reply buffer in tx_cmd.odata
when a command fails. If WDCMSG_TARGET_START fails while the
interface is being brought up (the device halts its command
endpoint), the pointer keeps referring to a variable on the stack
of the task that brought the interface up, and a later
WDCMSG_TARGET_START message from the device writes 4 bytes of its
choice into that dead stack frame. Bringing the interface up is
the only local action needed.
3/3 is written on top of 2/3 (it changes the branch that 2/3 adds after
the wait), so please apply the series in order. The series is based on
v7.4-rc2-141-g9d66f26fefac (base-commit below); ar5523.c is identical
in v7.3.1 and the patches apply there unchanged. Each patch has its
trigger, a decoded trace from that commit and its testing notes below
its '---' line; the testing of the whole series is in the notes of 2/3.
The notes of 1/3 explain how the series interacts with Weiming Shi's
pending "wifi: ar5523: reject negative reply lengths" patch.
How we found it: the bugs were found, and the reproducers and these
patches were written, by AI agents (Claude Mythos and Claude Opus
models), in QEMU with an emulated USB device.
A human reviewed the analysis and the patches. The reproducers are
available to maintainers on request.
Thanks,
Alexandre Becholey
Alexandre Becholey (3):
wifi: ar5523: don't WARN on a short command reply
wifi: ar5523: don't leave the command TX URB in flight
wifi: ar5523: don't leave a stale reply buffer behind in ar5523_cmd()
drivers/net/wireless/ath/ar5523/ar5523.c | 43 +++++++++++++++++++++++++++++---
drivers/net/wireless/ath/ar5523/ar5523.h | 1 +
2 files changed, 40 insertions(+), 4 deletions(-)
base-commit: 9d66f26fefacebfeed15de31c1123451a17ff119