AZL-117878: CVE-2026-142986 affecting package kernel 6.6.161.1-1
In the Linux kernel, the following vulnerability has been resolved:
usb: gadget: fmidi: fix UAF race during IN request handling
fmididisable() drains and frees pre-allocated IN requests from inreqfifo without holding midi->transmitlock. If fmiditransmit() runs concurrently on the workqueue, fmididotransmit() can peek a request from inreqfifo and write into its buffer while fmididisable() frees it, leading to a use-after-free.
Additionally, when usbepqueue() fails in fmididotransmit() (such as with -ESHUTDOWN when the endpoint is disabled concurrently), it resets req->length = 0 and returns active instead of the error code, causing the do-while loop in fmiditransmit() to keep spinning under midi->transmitlock until the substream is drained.
Fix this by acquiring midi->transmitlock in fmididisable() while releasing IN requests from inreqfifo, and returning the error code from fmididotransmit() when usbepqueue() fails so fmiditransmit() aborts immediately and drops active substreams.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
In f_midi_disable(), acquire midi->transmit_lock while draining and freeing pre-allocated IN requests from in_req_fifo, and hold it until the substream is drained.
Event History
Frequently Asked Questions
What conditions are required to trigger the use-after-free?
The race requires the USB MIDI gadget function to be handling IN requests while f_midi_disable() runs concurrently with transmit work on the workqueue. The vulnerable path involves a request being read from the IN request FIFO for transmission while disable processing frees that request.
Is there an availability impact in addition to the memory-safety issue?
Yes. If usb_ep_queue() fails while transmission is active, such as when an endpoint is disabled concurrently, the transmit loop can continue spinning while holding midi->transmit_lock until the substream is drained. The fix makes transmission abort immediately and drops active substreams on that error.
How can I tell whether this kernel package includes the fix?
The provided affected package is azure-linux/kernel version 6.6.161.1-1. The fix is present when f_midi_disable() holds midi->transmit_lock while releasing IN requests and f_midi_do_transmit() returns usb_ep_queue() errors instead of treating them as active transmission.