CVE-2025-39997
Description
In the Linux kernel, the following vulnerability has been resolved:
ALSA: usb-audio: fix race condition to UAF in snd_usbmidi_free
The previous commit 0718a78f6a9f ("ALSA: usb-audio: Kill timer properly at removal") patched a UAF issue caused by the error timer.
However, because the error timer kill added in this patch occurs after the endpoint delete, a race condition to UAF still occurs, albeit rarely.
Additionally, since kill-cleanup for urb is also missing, freed memory can be accessed in interrupt context related to urb, which can cause UAF.
Therefore, to prevent this, error timer and urb must be killed before freeing the heap memory.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
A race condition in the Linux kernel's ALSA USB-audio MIDI driver can lead to use-after-free (UAF) when freeing memory before killing timers and URBs.
Vulnerability
Overview
CVE-2025-39997 is a use-after-free (UAF) vulnerability in the Linux kernel's ALSA USB-audio MIDI subsystem, specifically in the snd_usbmidi_free function. The root cause is a race condition where the error timer and associated URBs are not properly cleaned up before heap memory is freed. A previous fix (commit 0718a78f6a9f) attempted to address a similar UAF by killing the timer at removal, but it placed the timer kill after the endpoint delete, leaving a window for a race condition to still occur. Additionally, the cleanup of URBs was missing entirely, allowing freed memory to be accessed in interrupt context [1][2][3].
Exploitation
An attacker with local access to the system can trigger the race condition by manipulating USB device hotplug or MIDI device operations. The vulnerability requires the ability to cause the USB audio device to be removed while MIDI operations are in progress. No special privileges beyond the ability to interact with USB devices are needed, but the attack is dependent on precise timing to hit the race window.
Impact
Successful exploitation leads to a use-after-free condition, which can result in memory corruption, system crash (denial of service), or potentially arbitrary code execution in kernel context. The UAF occurs when the freed memory is accessed by the error timer callback or URB completion handler, giving an attacker control over kernel memory.
Mitigation
The fix is included in the Linux kernel stable tree as commits af600e7f5526, dc4874366cf6, and 353d8c715cc9. These patches ensure that the error timer and all URBs are killed before freeing the heap memory, closing the race window. Users should apply the updated kernel version containing these commits.
AI Insight generated on May 19, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected products
2Patches
5dc4874366cf6647d6b8d22beaf600e7f5526353d8c715cc99f2c0ac1423dVulnerability mechanics
Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
5- git.kernel.org/stable/c/353d8c715cc951a980728133c9dd64ca5a0a186cnvd
- git.kernel.org/stable/c/647d6b8d22be12842fde6ed0c56859ebc615f21envd
- git.kernel.org/stable/c/9f2c0ac1423d5f267e7f1d1940780fc764b0fee3nvd
- git.kernel.org/stable/c/af600e7f5526d16146b3ae99f6ad57bfea79ca33nvd
- git.kernel.org/stable/c/dc4874366cf6cf4a31d8fa4b7f0e2a5b2d7647banvd
News mentions
0No linked articles in our index yet.