AZL-117115: CVE-2026-139416 affecting package kernel 6.6.161.1-1
In the Linux kernel, the following vulnerability has been resolved:
ALSA: rawmidi: Drain input work before freeing the runtime
The input runtime embeds eventwork, so the work must be drained before closesubstream() frees the runtime. The cancellation in sndrawmidiinputtrigger() runs before close clears substream->opened, leaving a window for sndrawmidireceive() to enqueue more work.
With a sequencer subscription to a USB MIDI input port, an in-flight completion can overlap the last subscription's midisynthunsubscribe():
1. sndusbmidiinputdata() observes inputtriggered and is delayed before calling sndrawmidireceive(). 2. Unsubscribe enters closesubstream(), clears inputtriggered through the provider trigger callback and returns from cancelworksync(). The substream is still opened. 3. The completion resumes. sndrawmidireceive() takes substream->lock, sees opened set and queues runtime->eventwork before dropping the lock. 4. Close clears opened under that lock, closes the provider and frees the runtime. Stopping USB URBs does not drain the raw-MIDI work. 5. The queued work runs and sndrawmidiinputeventwork() reads event or substream from the freed runtime, causing a use-after-free.
Cancel input eventwork again after clearing opened, before closing the provider or releasing the runtime's private data. Receive holds substream->lock through its opened check and work enqueue, so once close has cleared opened under that lock, no further receive can queue work. The final cancellation therefore drains any late work before the runtime is freed. Keep it outside the spinlock so a running callback can finish.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
In the raw-MIDI close path, cancel input event_work again after clearing substream->opened and before closing the provider or freeing the runtime; perform the cancellation outside the spinlock.
Event History
Frequently Asked Questions
Which systems are exposed to this race condition?
Systems using the affected Azure Linux kernel package with ALSA raw MIDI and a sequencer subscription to a USB MIDI input port are exposed to the described race. The issue depends on USB MIDI input activity overlapping removal of the last subscription.
What must happen for the use-after-free to occur?
An in-flight USB MIDI completion must observe that input is triggered, then be delayed while the last sequencer subscription is removed. It can subsequently queue the input runtime's event work after cancellation has completed but before the substream is marked closed and the runtime is freed.
Does stopping USB URBs prevent the queued work from running?
No. The description states that stopping USB URBs does not drain raw-MIDI work, so queued event work can still run after the input runtime has been freed.