CVE-2024-47744: KVM: Use dedicated mutex to protect kvm_usage_count to avoid deadlock

Published Oct 21, 2024
·
Updated

In the Linux kernel, the following vulnerability has been resolved:

KVM: Use dedicated mutex to protect kvmusagecount to avoid deadlock

Use a dedicated mutex to guard kvmusagecount to fix a potential deadlock on x86 due to a chain of locks and SRCU synchronizations. Translating the below lockdep splat, CPU1 #6 will wait on CPU0 #1, CPU0 #8 will wait on CPU2 #3, and CPU2 #7 will wait on CPU1 #4 (if there's a writer, due to the fairness of r/w semaphores).

CPU0 CPU1 CPU2 1 lock(&kvm->slotslock); 2 lock(&vcpu->mutex); 3 lock(&kvm->srcu); 4 lock(cpuhotpluglock); 5 lock(kvmlock); 6 lock(&kvm->slotslock); 7 lock(cpuhotpluglock); 8 sync(&kvm->srcu);

Note, there are likely more potential deadlocks in KVM x86, e.g. the same pattern of taking cpuhotpluglock outside of kvmlock likely exists with kvmclockcpufreqnotifier():

cpuhpcpufreqonline() | -> cpufreqonline() | -> cpufreqgovperformancelimits() | -> cpufreqdrivertarget() | -> targetindex() | -> cpufreqfreqtransitionbegin() | -> cpufreqnotifytransition() | -> ... kvmclockcpufreqnotifier()

But, actually triggering such deadlocks is beyond rare due to the combination of dependencies and timings involved. E.g. the cpufreq notifier is only used on older CPUs without a constant TSC, mucking with the NX hugepage mitigation while VMs are running is very uncommon, and doing so while also onlining/offlining a CPU (necessary to generate contention on cpuhotpluglock) would be even more unusual.

The most robust solution to the general cpuhotpluglock issue is likely to switch vmlist to be an RCU-protected list, e.g. so that x86's cpufreq notifier doesn't to take kvmlock. For now, settle for fixing the most blatant deadlock, as switching to an RCU-protected list is a much more involved change, but add a comment in locking.rst to call out that care needs to be taken when walking holding kvmlock and walking vmlist.

====================================================== WARNING: possible circular locking dependency detected 6.10.0-smp--c257535a0c9d-pip #330 Tainted: G S O ------------------------------------------------------ tee/35048 is trying to acquire lock: ff6a80eced71e0a8 (&kvm->slotslock){+.+.}-{3:3}, at: setnxhugepages+0x179/0x1e0 [kvm]

but task is already holding lock: ffffffffc07abb08 (kvmlock){+.+.}-{3:3}, at: setnxhugepages+0x14a/0x1e0 [kvm]

which lock already depends on the new lock.

the existing dependency chain (in reverse order) is:

-> #3 (kvmlock){+.+.}-{3:3}: mutexlock+0x6a/0xb40 mutexlocknested+0x1f/0x30 kvmdevioctl+0x4fb/0xe50 [kvm] sesysioctl+0x7b/0xd0 x64sysioctl+0x21/0x30 x64syscall+0x15d0/0x2e60 dosyscall64+0x83/0x160 entrySYSCALL64afterhwframe+0x76/0x7e

-> #2 (cpuhotpluglock){++++}-{0:0}: cpusreadlock+0x2e/0xb0 statickeyslowinc+0x16/0x30 kvmlapicsetbase+0x6a/0x1c0 [kvm] kvmsetapicbase+0x8f/0xe0 [kvm] kvmsetmsrcommon+0x9ae/0xf80 [kvm] vmxsetmsr+0xa54/0xbe0 [kvmintel] kvmsetmsr+0xb6/0x1a0 [kvm] kvmarchvcpuioctl+0xeca/0x10c0 [kvm] kvmvcpuioctl+0x485/0x5b0 [kvm] sesysioctl+0x7b/0xd0 x64sysioctl+0x21/0x30 x64syscall+0x15d0/0x2e60 dosyscall64+0x83/0x160 entrySYSCALL64afterhwframe+0x76/0x7e

-> #1 (&kvm->srcu){.+.+}-{0:0}: synchronizesrcu+0x44/0x1a0 ---truncated---

Other sources

This CVE was automatically created from a reference found in an email or other text. If you are reading this, then this CVE entry is probably erroneous, since this text should be replaced by the official CVE description automatically.

Launchpad

Affected Software

4 affected componentsFixes available
Linux Linux kernel>=6.3<6.6.54
Linux Linux kernel>=6.7<6.10.13
Linux Linux kernel>=6.11<6.11.2
debian/linux
5.10.223-15.10.234-16.1.129-16.1.135-16.12.25-16.12.27-1

Event History

Oct 21, 2024
CVE Published
via MITRE·12:14 PM
Data Sourced
via MITRE·12:14 PM
Description
Feb 20, 2025
Data Sourced
via Launchpad·12:49 AM
Description
Apr 5, 2025
Data Sourced
via Ubuntu·12:58 AM
RemedyDescriptionSeverityAffected Software
Apr 13, 2025
Data Sourced
via Debian·01:02 AM
DescriptionAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2024-47744?

CVE-2024-47744 is categorized as a medium severity vulnerability due to its potential to cause deadlocks in the Linux kernel.

2

How do I fix CVE-2024-47744?

To fix CVE-2024-47744, update the Linux kernel to versions 5.10.223-1, 5.10.226-1, 6.1.123-1, 6.1.128-1, 6.12.12-1, or 6.12.15-1.

3

Which systems are affected by CVE-2024-47744?

CVE-2024-47744 affects various versions of the Linux kernel, specifically those prior to version 6.3 and those between versions 6.7 and 6.10.13.

4

What does CVE-2024-47744 impact?

CVE-2024-47744 impacts the KVM subsystem of the Linux kernel, specifically how mutexes are handled in relation to kvm_usage_count.

5

Is CVE-2024-47744 a remote attack vulnerability?

CVE-2024-47744 is not explicitly a remote attack vulnerability; it primarily concerns local deadlock scenarios within the Linux kernel.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203