CVE-2024-26976

Severity CVSS v4.0:
Pending analysis
Type:
CWE-400 Uncontrolled Resource Consumption ('Resource Exhaustion')
Publication date:
01/05/2024
Last modified:
08/04/2025

Description

In the Linux kernel, the following vulnerability has been resolved:<br /> <br /> KVM: Always flush async #PF workqueue when vCPU is being destroyed<br /> <br /> Always flush the per-vCPU async #PF workqueue when a vCPU is clearing its<br /> completion queue, e.g. when a VM and all its vCPUs is being destroyed.<br /> KVM must ensure that none of its workqueue callbacks is running when the<br /> last reference to the KVM _module_ is put. Gifting a reference to the<br /> associated VM prevents the workqueue callback from dereferencing freed<br /> vCPU/VM memory, but does not prevent the KVM module from being unloaded<br /> before the callback completes.<br /> <br /> Drop the misguided VM refcount gifting, as calling kvm_put_kvm() from<br /> async_pf_execute() if kvm_put_kvm() flushes the async #PF workqueue will<br /> result in deadlock. async_pf_execute() can&amp;#39;t return until kvm_put_kvm()<br /> finishes, and kvm_put_kvm() can&amp;#39;t return until async_pf_execute() finishes:<br /> <br /> WARNING: CPU: 8 PID: 251 at virt/kvm/kvm_main.c:1435 kvm_put_kvm+0x2d/0x320 [kvm]<br /> Modules linked in: vhost_net vhost vhost_iotlb tap kvm_intel kvm irqbypass<br /> CPU: 8 PID: 251 Comm: kworker/8:1 Tainted: G W 6.6.0-rc1-e7af8d17224a-x86/gmem-vm #119<br /> Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015<br /> Workqueue: events async_pf_execute [kvm]<br /> RIP: 0010:kvm_put_kvm+0x2d/0x320 [kvm]<br /> Call Trace:<br /> <br /> async_pf_execute+0x198/0x260 [kvm]<br /> process_one_work+0x145/0x2d0<br /> worker_thread+0x27e/0x3a0<br /> kthread+0xba/0xe0<br /> ret_from_fork+0x2d/0x50<br /> ret_from_fork_asm+0x11/0x20<br /> <br /> ---[ end trace 0000000000000000 ]---<br /> INFO: task kworker/8:1:251 blocked for more than 120 seconds.<br /> Tainted: G W 6.6.0-rc1-e7af8d17224a-x86/gmem-vm #119<br /> "echo 0 &gt; /proc/sys/kernel/hung_task_timeout_secs" disables this message.<br /> task:kworker/8:1 state:D stack:0 pid:251 ppid:2 flags:0x00004000<br /> Workqueue: events async_pf_execute [kvm]<br /> Call Trace:<br /> <br /> __schedule+0x33f/0xa40<br /> schedule+0x53/0xc0<br /> schedule_timeout+0x12a/0x140<br /> __wait_for_common+0x8d/0x1d0<br /> __flush_work.isra.0+0x19f/0x2c0<br /> kvm_clear_async_pf_completion_queue+0x129/0x190 [kvm]<br /> kvm_arch_destroy_vm+0x78/0x1b0 [kvm]<br /> kvm_put_kvm+0x1c1/0x320 [kvm]<br /> async_pf_execute+0x198/0x260 [kvm]<br /> process_one_work+0x145/0x2d0<br /> worker_thread+0x27e/0x3a0<br /> kthread+0xba/0xe0<br /> ret_from_fork+0x2d/0x50<br /> ret_from_fork_asm+0x11/0x20<br /> <br /> <br /> If kvm_clear_async_pf_completion_queue() actually flushes the workqueue,<br /> then there&amp;#39;s no need to gift async_pf_execute() a reference because all<br /> invocations of async_pf_execute() will be forced to complete before the<br /> vCPU and its VM are destroyed/freed. And that in turn fixes the module<br /> unloading bug as __fput() won&amp;#39;t do module_put() on the last vCPU reference<br /> until the vCPU has been freed, e.g. if closing the vCPU file also puts the<br /> last reference to the KVM module.<br /> <br /> Note that kvm_check_async_pf_completion() may also take the work item off<br /> the completion queue and so also needs to flush the work queue, as the<br /> work will not be seen by kvm_clear_async_pf_completion_queue(). Waiting<br /> on the workqueue could theoretically delay a vCPU due to waiting for the<br /> work to complete, but that&amp;#39;s a very, very small chance, and likely a very<br /> small delay. kvm_arch_async_page_present_queued() unconditionally makes a<br /> new request, i.e. will effectively delay entering the guest, so the<br /> remaining work is really just:<br /> <br /> trace_kvm_async_pf_completed(addr, cr2_or_gpa);<br /> <br /> __kvm_vcpu_wake_up(vcpu);<br /> <br /> mmput(mm);<br /> <br /> and mmput() can&amp;#39;t drop the last reference to the page tables if the vCPU is<br /> still alive, i.e. the vCPU won&amp;#39;t get stuck tearing down page tables.<br /> <br /> Add a helper to do the flushing, specifically to deal with "wakeup all"<br /> work items, as they aren&amp;#39;t actually work items, i.e. are never placed in a<br /> workqueue. Trying to flush a bogus workqueue entry rightly makes<br /> __flush_work() complain (kudos to whoever added that sanity check).<br /> <br /> Note, commit 5f6de5cbebee ("KVM: Prevent module exit until al<br /> ---truncated---

Vulnerable products and versions

CPE From Up to
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 2.6.38 (including) 4.19.312 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 4.20 (including) 5.4.274 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.5 (including) 5.10.215 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.11 (including) 5.15.154 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.16 (including) 6.1.84 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 6.2 (including) 6.6.24 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 6.7 (including) 6.7.12 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 6.8 (including) 6.8.3 (excluding)
cpe:2.3:o:debian:debian_linux:10.0:*:*:*:*:*:*:*