{"id":"CVE-2026-139416","state":"PUBLISHED","title":"ALSA: rawmidi: Drain input work before freeing the runtime","description":"In the Linux kernel, the following vulnerability has been resolved:\n\nALSA: rawmidi: Drain input work before freeing the runtime\n\nThe input runtime embeds event_work, so the work must be drained before\nclose_substream() frees the runtime. The cancellation in\nsnd_rawmidi_input_trigger() runs before close clears substream->opened,\nleaving a window for snd_rawmidi_receive() to enqueue more work.\n\nWith a sequencer subscription to a USB MIDI input port, an in-flight\ncompletion can overlap the last subscription's midisynth_unsubscribe():\n\n1. snd_usbmidi_input_data() observes input_triggered and is delayed\n   before calling snd_rawmidi_receive().\n2. Unsubscribe enters close_substream(), clears input_triggered through\n   the provider trigger callback and returns from cancel_work_sync().\n   The substream is still opened.\n3. The completion resumes. snd_rawmidi_receive() takes substream->lock,\n   sees opened set and queues runtime->event_work before dropping the\n   lock.\n4. Close clears opened under that lock, closes the provider and frees\n   the runtime. Stopping USB URBs does not drain the raw-MIDI work.\n5. The queued work runs and snd_rawmidi_input_event_work() reads event\n   or substream from the freed runtime, causing a use-after-free.\n\nCancel input event_work again after clearing opened, before closing the\nprovider or releasing the runtime's private data. Receive holds\nsubstream->lock through its opened check and work enqueue, so once close\nhas cleared opened under that lock, no further receive can queue work.\nThe final cancellation therefore drains any late work before the\nruntime is freed. Keep it outside the spinlock so a running callback can\nfinish.","publishedAt":"2026-11-30T13:34:33.192Z","updatedAt":"2026-11-30T13:34:33.192Z","severity":null,"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"b3c705aa9e9147a30009bdf6ba853aa7fe138e58","status":"affected","lessThan":"d2ee58c9cc55dc5f8a4b6e076d0dd29e55528ef9","versionType":"git"},{"version":"b3c705aa9e9147a30009bdf6ba853aa7fe138e58","status":"affected","lessThan":"31fe24f97c1046ac0219b625eb5008ef31923e7b","versionType":"git"},{"version":"b3c705aa9e9147a30009bdf6ba853aa7fe138e58","status":"affected","lessThan":"b4449d6b58b8a84ae1706775863f472765463bce","versionType":"git"},{"version":"b3c705aa9e9147a30009bdf6ba853aa7fe138e58","status":"affected","lessThan":"16ef7ce9f01ea9950b2186c48b14538dcb87da61","versionType":"git"},{"version":"b3c705aa9e9147a30009bdf6ba853aa7fe138e58","status":"affected","lessThan":"48f7120813e8509dce98b4dd27c39ca80149d150","versionType":"git"},{"version":"b3c705aa9e9147a30009bdf6ba853aa7fe138e58","status":"affected","lessThan":"b8824d0fb9e515d9b0d5be78b4acc99f02981151","versionType":"git"},{"version":"b3c705aa9e9147a30009bdf6ba853aa7fe138e58","status":"affected","lessThan":"8c3529f0a8faaac7d73333486f69da1617ecc579","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["sound/core/rawmidi.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"3.1","status":"affected"},{"version":"0","status":"unaffected","lessThan":"3.1","versionType":"semver"},{"version":"5.10.275","status":"unaffected","lessThanOrEqual":"5.10.*","versionType":"semver"},{"version":"5.15.226","status":"unaffected","lessThanOrEqual":"5.15.*","versionType":"semver"},{"version":"6.6.163","status":"unaffected","lessThanOrEqual":"6.6.*","versionType":"semver"},{"version":"6.12.119","status":"unaffected","lessThanOrEqual":"6.12.*","versionType":"semver"},{"version":"6.18.65","status":"unaffected","lessThanOrEqual":"6.18.*","versionType":"semver"},{"version":"7.3.6","status":"unaffected","lessThanOrEqual":"7.3.*","versionType":"semver"},{"version":"7.4-rc1","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["sound/core/rawmidi.c"]}],"references":["https://git.kernel.org/stable/c/d2ee58c9cc55dc5f8a4b6e076d0dd29e55528ef9","https://git.kernel.org/stable/c/31fe24f97c1046ac0219b625eb5008ef31923e7b","https://git.kernel.org/stable/c/b4449d6b58b8a84ae1706775863f472765463bce","https://git.kernel.org/stable/c/16ef7ce9f01ea9950b2186c48b14538dcb87da61","https://git.kernel.org/stable/c/48f7120813e8509dce98b4dd27c39ca80149d150","https://git.kernel.org/stable/c/b8824d0fb9e515d9b0d5be78b4acc99f02981151","https://git.kernel.org/stable/c/8c3529f0a8faaac7d73333486f69da1617ecc579"],"weaknesses":[],"ingestedAt":"2026-11-30T13:48:04.491Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2026/139xxx/CVE-2026-139416.json","commit":"8c2c22940a0de21d18737df980299c0488d5dc73","baselineCommit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2026-139416","state":"PUBLISHED","datePublished":"2026-11-30T13:34:33.192Z","dateUpdated":"2026-11-30T13:34:33.192Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2026-11-30T13:22:15.932Z"},"containers":{"cna":{"title":"ALSA: rawmidi: Drain input work before freeing the runtime","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nALSA: rawmidi: Drain input work before freeing the runtime\n\nThe input runtime embeds event_work, so the work must be drained before\nclose_substream() frees the runtime. The cancellation in\nsnd_rawmidi_input_trigger() runs before close clears substream->opened,\nleaving a window for snd_rawmidi_receive() to enqueue more work.\n\nWith a sequencer subscription to a USB MIDI input port, an in-flight\ncompletion can overlap the last subscription's midisynth_unsubscribe():\n\n1. snd_usbmidi_input_data() observes input_triggered and is delayed\n   before calling snd_rawmidi_receive().\n2. Unsubscribe enters close_substream(), clears input_triggered through\n   the provider trigger callback and returns from cancel_work_sync().\n   The substream is still opened.\n3. The completion resumes. snd_rawmidi_receive() takes substream->lock,\n   sees opened set and queues runtime->event_work before dropping the\n   lock.\n4. Close clears opened under that lock, closes the provider and frees\n   the runtime. Stopping USB URBs does not drain the raw-MIDI work.\n5. The queued work runs and snd_rawmidi_input_event_work() reads event\n   or substream from the freed runtime, causing a use-after-free.\n\nCancel input event_work again after clearing opened, before closing the\nprovider or releasing the runtime's private data. Receive holds\nsubstream->lock through its opened check and work enqueue, so once close\nhas cleared opened under that lock, no further receive can queue work.\nThe final cancellation therefore drains any late work before the\nruntime is freed. Keep it outside the spinlock so a running callback can\nfinish."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"b3c705aa9e9147a30009bdf6ba853aa7fe138e58","status":"affected","lessThan":"d2ee58c9cc55dc5f8a4b6e076d0dd29e55528ef9","versionType":"git"},{"version":"b3c705aa9e9147a30009bdf6ba853aa7fe138e58","status":"affected","lessThan":"31fe24f97c1046ac0219b625eb5008ef31923e7b","versionType":"git"},{"version":"b3c705aa9e9147a30009bdf6ba853aa7fe138e58","status":"affected","lessThan":"b4449d6b58b8a84ae1706775863f472765463bce","versionType":"git"},{"version":"b3c705aa9e9147a30009bdf6ba853aa7fe138e58","status":"affected","lessThan":"16ef7ce9f01ea9950b2186c48b14538dcb87da61","versionType":"git"},{"version":"b3c705aa9e9147a30009bdf6ba853aa7fe138e58","status":"affected","lessThan":"48f7120813e8509dce98b4dd27c39ca80149d150","versionType":"git"},{"version":"b3c705aa9e9147a30009bdf6ba853aa7fe138e58","status":"affected","lessThan":"b8824d0fb9e515d9b0d5be78b4acc99f02981151","versionType":"git"},{"version":"b3c705aa9e9147a30009bdf6ba853aa7fe138e58","status":"affected","lessThan":"8c3529f0a8faaac7d73333486f69da1617ecc579","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["sound/core/rawmidi.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"3.1","status":"affected"},{"version":"0","status":"unaffected","lessThan":"3.1","versionType":"semver"},{"version":"5.10.275","status":"unaffected","lessThanOrEqual":"5.10.*","versionType":"semver"},{"version":"5.15.226","status":"unaffected","lessThanOrEqual":"5.15.*","versionType":"semver"},{"version":"6.6.163","status":"unaffected","lessThanOrEqual":"6.6.*","versionType":"semver"},{"version":"6.12.119","status":"unaffected","lessThanOrEqual":"6.12.*","versionType":"semver"},{"version":"6.18.65","status":"unaffected","lessThanOrEqual":"6.18.*","versionType":"semver"},{"version":"7.3.6","status":"unaffected","lessThanOrEqual":"7.3.*","versionType":"semver"},{"version":"7.4-rc1","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["sound/core/rawmidi.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/d2ee58c9cc55dc5f8a4b6e076d0dd29e55528ef9"},{"url":"https://git.kernel.org/stable/c/31fe24f97c1046ac0219b625eb5008ef31923e7b"},{"url":"https://git.kernel.org/stable/c/b4449d6b58b8a84ae1706775863f472765463bce"},{"url":"https://git.kernel.org/stable/c/16ef7ce9f01ea9950b2186c48b14538dcb87da61"},{"url":"https://git.kernel.org/stable/c/48f7120813e8509dce98b4dd27c39ca80149d150"},{"url":"https://git.kernel.org/stable/c/b8824d0fb9e515d9b0d5be78b4acc99f02981151"},{"url":"https://git.kernel.org/stable/c/8c3529f0a8faaac7d73333486f69da1617ecc579"}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-11-30T13:34:33.192Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"3.1","versionEndExcluding":"5.10.275"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"3.1","versionEndExcluding":"5.15.226"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"3.1","versionEndExcluding":"6.6.163"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"3.1","versionEndExcluding":"6.12.119"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"3.1","versionEndExcluding":"6.18.65"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"3.1","versionEndExcluding":"7.3.6"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"3.1","versionEndExcluding":"7.4-rc1"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}}}}}