CVE-2026-139416

ALSA: rawmidi: Drain input work before freeing the runtime

Published Nov 30, 2026 CVSS n/a EPSS n/a KEV · Not listed
Description
In the Linux kernel, the following vulnerability has been resolved:

ALSA: rawmidi: Drain input work before freeing the runtime

The input runtime embeds event_work, so the work must be drained before
close_substream() frees the runtime. The cancellation in
snd_rawmidi_input_trigger() runs before close clears substream->opened,
leaving a window for snd_rawmidi_receive() to enqueue more work.

With a sequencer subscription to a USB MIDI input port, an in-flight
completion can overlap the last subscription's midisynth_unsubscribe():

1. snd_usbmidi_input_data() observes input_triggered and is delayed
before calling snd_rawmidi_receive().
2. Unsubscribe enters close_substream(), clears input_triggered through
the provider trigger callback and returns from cancel_work_sync().
The substream is still opened.
3. The completion resumes. snd_rawmidi_receive() takes substream->lock,
sees opened set and queues runtime->event_work 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 snd_rawmidi_input_event_work() reads event
or substream from the freed runtime, causing a use-after-free.

Cancel input event_work 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.

Analysis

AI-generated

Technical impact

The vulnerability resides in the ALSA rawmidi driver in the Linux kernel and introduces a use‑after‑free condition. When a USB MIDI device’s subscription is removed, work that has already been queued can still run after the runtime memory is freed, causing the kernel to read from deallocated memory. An attacker feeding crafted data via a USB MIDI device could trigger a crash or, in the worst case, execute arbitrary code with kernel privileges. The secure‑coding inference indicates that this flaw has the potential for privilege escalation, but the exact impact is limited to the size of the exposed memory and the ability to cause a kernel fault. The description is directly supplied by the CVE text.

Affected Systems

All Linux kernel releases that include the ALSA rawmidi implementation before the patch are affected. The vendor is the Linux kernel maintainers, and the product is the generic Linux distribution kernel. No specific version range is listed, so all kernels lacking the runtime drain fix are potentially vulnerable.

Risk and Exploitability

No EPSS score is published and the vulnerability is not listed in the CISA KEV catalog, suggesting limited known exploitation. Based on the description, it is inferred that the exploit requires a local USB MIDI device, making the attack vector local. The likely exploit scenario is that a malicious user plugs a crafted device while the system is running, causing the kernel to process the enqueued work after the runtime has been freed, leading to a use‑after‑free. The severity, as measured by CVSS, remains high due to the kernel distance and privilege escalation potential. The exploitation probability is considered moderate if an attacker can supply a USB MIDI device; otherwise it is unlikely.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Update the Linux kernel to a version containing the rawmidi use‑after‑free patch that drains input work before freeing the runtime.
  • If upgrading is not immediately possible, consider disabling the ALSA rawmidi subsystem or preventing USB MIDI device enumeration until a kernel update is applied.
  • Ensure that only trusted USB MIDI devices are connected to the system to reduce the chance of an attacker submitting malicious input.

Generated by OpenCVE AI on December 1, 2026 at 05:43 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories available
History
Type Values Removed Values Added
Weaknesses CWE-416
Type Values Removed Values Added
Description In the Linux kernel, the following vulnerability has been resolved: ALSA: rawmidi: Drain input work before freeing the runtime The input runtime embeds event_work, so the work must be drained before close_substream() frees the runtime. The cancellation in snd_rawmidi_input_trigger() runs before close clears substream->opened, leaving a window for snd_rawmidi_receive() to enqueue more work. With a sequencer subscription to a USB MIDI input port, an in-flight completion can overlap the last subscription's midisynth_unsubscribe(): 1. snd_usbmidi_input_data() observes input_triggered and is delayed before calling snd_rawmidi_receive(). 2. Unsubscribe enters close_substream(), clears input_triggered through the provider trigger callback and returns from cancel_work_sync(). The substream is still opened. 3. The completion resumes. snd_rawmidi_receive() takes substream->lock, sees opened set and queues runtime->event_work 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 snd_rawmidi_input_event_work() reads event or substream from the freed runtime, causing a use-after-free. Cancel input event_work 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.
Title ALSA: rawmidi: Drain input work before freeing the runtime
First Time appeared Linux
Linux linux Kernel
CPEs cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
Vendors & Products Linux
Linux linux Kernel
References
Weaknesses

Sources

Status
PUBLISHED
Assigner
Linux
Published
Updated
Nov 30, 2026, 1:34 PM
Reserved
Nov 30, 2026, 1:22 PM
Status
Received
Published
Nov 30, 2026, 2:19 PM
Modified
Nov 30, 2026, 2:19 PM