CVE-2026-142986: usb: gadget: f_midi: fix UAF race during IN request handling

Published Dec 3, 2026
·
Updated

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

1 affected component
Linux Linux kernel

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Compensating control

    In f_midi_disable(), acquire midi->transmit_lock while draining and freeing pre-allocated IN requests from in_req_fifo.

  2. Compensating control

    In f_midi_do_transmit(), propagate the error from usb_ep_queue() instead of returning active when queuing fails, so f_midi_transmit() aborts rather than continuing its loop.

Event History

Dec 3, 2026
CVE Published
via MITRE·09:17 AM
Data Sourced
via MITRE·09:17 AM
Description

Frequently Asked Questions

1

What runtime conditions are required to trigger the use-after-free?

f_midi_disable() must run concurrently with f_midi_transmit() executing on the workqueue. The transmit path can obtain an IN request from in_req_fifo and write to its buffer while the disable path drains and frees that request.

2

What happens if an IN request cannot be queued while the endpoint is being disabled?

A usb_ep_queue() failure, such as -ESHUTDOWN during concurrent endpoint disablement, previously caused the transmit loop to continue spinning while holding midi->transmit_lock until the substream drained. The fix returns the queueing error so transmission aborts immediately and active substreams are dropped.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203