{"id":"CVE-2026-139361","summary":"ALSA: pcm: Add refcount for races between drain and unlink","details":"In the Linux kernel, the following vulnerability has been resolved:\n\nALSA: pcm: Add refcount for races between drain and unlink\n\nWe added a workaround for the case where a linked substream gets\nunlinked during the drain operation by another substream of the same\nlinked group in the commit 9b1dbd69ba6f (\"ALSA: pcm: fix\nuse-after-free on linked stream runtime in snd_pcm_drain()\").\nThere, we just cached the parameters of the draining substream for\navoiding UAF.\n\nThen, we check the draining substream (to_check) again in the loop and\nremove it from the queue only when it's still present.  It means,\nhowever, that the wait queue entry won't be removed if the substream\nwent out of the link beforehand, hence a stale wq entry remains.\nLater on, this can be woken up, and this may hit a UAF, too.\nThe problem surfaced more due to the recent change to call\nsnd_pcm_unlink() earlier.\n\nFor properly handling both cases above, in this patch, we introduce a\nrefcount to the snd_pcm_runtime that indicates the substream is being\naccessed / used, then at snd_pcm_release_substream(), it's synced\nbefore the actual resource release via snd_refcount_sync().  This\nguarantees that the accessors are finished, and safe to release\nmemories.  Along with the introduction of a refcount, the comments and\nthe code changes by the former fix were partially reverted as they\ndon't fit with the updated code flow any longer.\n\nLast but not least, the setup of wait queue entry and\nprepare_to_wait() call are moved before the group unref.  With this\nchange, we can avoid the race between the enqueue and the wakeup, too.","modified":"2026-11-30T15:02:28.085136503Z","published":"2026-11-30T13:34:02.926Z","database_specific":{"osv_generated_from":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/139xxx/CVE-2026-139361.json","cna_assigner":"Linux"},"references":[{"type":"PACKAGE","url":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git"},{"type":"WEB","url":"https://git.kernel.org/stable/c/220edbb1806a43a45e9f51a6cc68c54d58c583ee"},{"type":"WEB","url":"https://git.kernel.org/stable/c/68273cb3c8e115b1886ddb4bdf30dd91af1a9e62"},{"type":"WEB","url":"https://git.kernel.org/stable/c/7131b6e1cab439eae7bf4ed37857183e84268b5b"},{"type":"WEB","url":"https://git.kernel.org/stable/c/7d8afac865e73648bae36075b829d5bc4dd32f4e"},{"type":"WEB","url":"https://git.kernel.org/stable/c/91d0048a97e0fdc0a071caa0ba59e659bc6f84df"},{"type":"WEB","url":"https://git.kernel.org/stable/c/bac6a5a3c96237c025086b885d31a3485a3204d9"},{"type":"WEB","url":"https://git.kernel.org/stable/c/bf052a1fb6507ccb6aea53b12db98f0976f8872d"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/139xxx/CVE-2026-139361.json"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-139361"}],"affected":[{"ranges":[{"type":"GIT","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","events":[{"introduced":"f2cb2e0d27fb925c73a78f0ce7d6dbf68d3747c1"},{"fixed":"220edbb1806a43a45e9f51a6cc68c54d58c583ee"}]},{"type":"GIT","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","events":[{"introduced":"fc71f888994569f87d5bee20b1ac6c9c1e3a7a79"},{"fixed":"7131b6e1cab439eae7bf4ed37857183e84268b5b"}]},{"type":"GIT","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","events":[{"introduced":"629cf09464cf98670996ea5c191dc9743e6f3f00"},{"fixed":"bf052a1fb6507ccb6aea53b12db98f0976f8872d"}]},{"type":"GIT","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","events":[{"introduced":"ae8f8d30d334bad5b1b3cdb1eb8a0b771f55e432"},{"fixed":"68273cb3c8e115b1886ddb4bdf30dd91af1a9e62"}]},{"type":"GIT","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","events":[{"introduced":"4a758e9a1f5ed722f83c4dd35f867fe811553bcb"},{"fixed":"7d8afac865e73648bae36075b829d5bc4dd32f4e"}]},{"type":"GIT","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","events":[{"introduced":"9b1dbd69ba6f8f8c69bc7b77c2ce3b9c6ed05ba6"},{"fixed":"bac6a5a3c96237c025086b885d31a3485a3204d9"},{"fixed":"91d0048a97e0fdc0a071caa0ba59e659bc6f84df"}]},{"type":"GIT","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","events":[{"introduced":"9baee36e8c5443411c4629afabafaff8a46a23fd"}]},{"type":"GIT","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","events":[{"introduced":"c2f64e05a0587a83ec42dbd6b7a7ded79b2ff694"}]}],"versions":["v5.15.225","v5.15.224","v5.15.223","v5.15.222","v5.15.221","v5.15.220","v6.1.192","v6.1.191","v6.1.190","v6.1.189","v6.1.188","v6.1.187","v6.1.186","v6.1.185","v6.1.184","v6.1.183","v6.1.182","v6.1.181","v6.1.180","v6.1.179","v6.1.178","v6.1.177","v6.1.176","v6.1.175","v6.1.174","v6.1.173","v6.1.172","v6.1.171","v6.1.170","v6.1.169","v6.1.168","v6.1.167","v6.6.162","v6.6.161","v6.6.160","v6.6.159","v6.6.158","v6.6.157","v6.6.156","v6.6.155","v6.6.154","v6.6.153","v6.6.152","v6.6.151","v6.6.150","v6.6.149","v6.6.148","v6.6.147","v6.6.146","v6.6.145","v6.6.144","v6.6.143","v6.6.142","v6.6.141","v6.6.140","v6.6.139","v6.6.138","v6.6.137","v6.6.136","v6.6.135","v6.6.134","v6.6.133","v6.6.132","v6.6.131","v6.6.130","v6.12.118","v6.12.117","v6.12.116","v6.12.115","v6.12.114","v6.12.113","v6.12.112","v6.12.111","v6.12.110","v6.12.109","v6.12.108","v6.12.107","v6.12.106","v6.12.105","v6.12.104","v6.12.103","v6.12.102","v6.12.101","v6.12.100","v6.12.99","v6.12.98","v6.12.97","v6.12.96","v6.12.95","v6.12.94","v6.12.93","v6.12.92","v6.12.91","v6.12.90","v6.12.89","v6.12.88","v6.12.87","v6.12.86","v6.12.85","v6.12.84","v6.12.83","v6.12.82","v6.12.81","v6.12.80","v6.12.79","v6.12.78","v6.18.64","v6.18.63","v6.18.62","v6.18.61","v6.18.60","v6.18.59","v6.18.58","v6.18.57","v6.18.56","v6.18.55","v6.18.54","v6.18.53","v6.18.52","v6.18.51","v6.18.50","v6.18.49","v6.18.48","v6.18.47","v6.18.46","v6.18.45","v6.18.44","v6.18.43","v6.18.42","v6.18.41","v6.18.40","v6.18.39","v6.18.38","v6.18.37","v6.18.36","v6.18.35","v6.18.34","v6.18.33","v6.18.32","v6.18.31","v6.18.30","v6.18.29","v6.18.28","v6.18.27","v6.18.26","v6.18.25","v6.18.24","v6.18.23","v6.18.22","v6.18.21","v6.18.20","v6.18.19","v5.10.275","v5.10.274","v5.10.273","v5.10.272","v5.10.271","v5.10.270","v5.10.269","v5.10.268","v5.10.267","v5.10.266","v5.10.265","v5.10.264","v5.10.263","v5.10.262","v5.10.261","v5.10.260","v5.10.259","v5.10.258","v5.10.257","v5.10.256","v5.10.255","v5.10.254","v5.10.253","v6.19.14","v6.19.13","v6.19.12","v6.19.11","v6.19.10","v6.19.9"],"database_specific":{"source":"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-139361.json"}},{"package":{"name":"Kernel","ecosystem":"Linux"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"5.10.253"},{"fixed":"5.11"}]},{"type":"ECOSYSTEM","events":[{"introduced":"5.15.220"},{"fixed":"5.15.226"}]},{"type":"ECOSYSTEM","events":[{"introduced":"6.1.167"},{"fixed":"6.1.193"}]},{"type":"ECOSYSTEM","events":[{"introduced":"6.6.130"},{"fixed":"6.6.163"}]},{"type":"ECOSYSTEM","events":[{"introduced":"6.12.78"},{"fixed":"6.12.119"}]},{"type":"ECOSYSTEM","events":[{"introduced":"6.18.19"},{"fixed":"6.18.65"}]},{"type":"ECOSYSTEM","events":[{"introduced":"6.19.9"},{"fixed":"6.20"}]},{"type":"ECOSYSTEM","events":[{"introduced":"7.0.0"},{"fixed":"7.3.6"}]}],"database_specific":{"source":"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-139361.json"}}],"schema_version":"1.9.2"}