CVE-2024-40953

Source
https://cve.org/CVERecord?id=CVE-2024-40953
Import Source
https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2024-40953.json
JSON Data
https://api.osv.dev/v1/vulns/CVE-2024-40953
Downstream
Related
Published
2024-07-12T12:31:56.832Z
Modified
2026-03-14T12:35:03.480176Z
Summary
KVM: Fix a data race on last_boosted_vcpu in kvm_vcpu_on_spin()
Details

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

KVM: Fix a data race on lastboostedvcpu in kvmvcpuon_spin()

Use {READ,WRITE}ONCE() to access kvm->lastboosted_vcpu to ensure the loads and stores are atomic. In the extremely unlikely scenario the compiler tears the stores, it's theoretically possible for KVM to attempt to get a vCPU using an out-of-bounds index, e.g. if the write is split into multiple 8-bit stores, and is paired with a 32-bit load on a VM with 257 vCPUs:

CPU0 CPU1 lastboostedvcpu = 0xff;

                                (last_boosted_vcpu = 0x100)
                                last_boosted_vcpu[15:8] = 0x01;

i = (lastboostedvcpu = 0x1ff) lastboostedvcpu[7:0] = 0x00;

vcpu = kvm->vcpu_array[0x1ff];

As detected by KCSAN:

BUG: KCSAN: data-race in kvmvcpuonspin [kvm] / kvmvcpuonspin [kvm]

write to 0xffffc90025a92344 of 4 bytes by task 4340 on cpu 16: kvmvcpuonspin (arch/x86/kvm/../../../virt/kvm/kvmmain.c:4112) kvm handlepause (arch/x86/kvm/vmx/vmx.c:5929) kvmintel vmxhandleexit (arch/x86/kvm/vmx/vmx.c:? arch/x86/kvm/vmx/vmx.c:6606) kvmintel vcpurun (arch/x86/kvm/x86.c:11107 arch/x86/kvm/x86.c:11211) kvm kvmarchvcpuioctlrun (arch/x86/kvm/x86.c:?) kvm kvmvcpuioctl (arch/x86/kvm/../../../virt/kvm/kvm_main.c:?) kvm __sesysioctl (fs/ioctl.c:52 fs/ioctl.c:904 fs/ioctl.c:890) __x64sysioctl (fs/ioctl.c:890) x64syscall (arch/x86/entry/syscall64.c:33) dosyscall64 (arch/x86/entry/common.c:?) entrySYSCALL64afterhwframe (arch/x86/entry/entry64.S:130)

read to 0xffffc90025a92344 of 4 bytes by task 4342 on cpu 4: kvmvcpuonspin (arch/x86/kvm/../../../virt/kvm/kvmmain.c:4069) kvm handlepause (arch/x86/kvm/vmx/vmx.c:5929) kvmintel vmxhandleexit (arch/x86/kvm/vmx/vmx.c:? arch/x86/kvm/vmx/vmx.c:6606) kvmintel vcpurun (arch/x86/kvm/x86.c:11107 arch/x86/kvm/x86.c:11211) kvm kvmarchvcpuioctlrun (arch/x86/kvm/x86.c:?) kvm kvmvcpuioctl (arch/x86/kvm/../../../virt/kvm/kvm_main.c:?) kvm __sesysioctl (fs/ioctl.c:52 fs/ioctl.c:904 fs/ioctl.c:890) __x64sysioctl (fs/ioctl.c:890) x64syscall (arch/x86/entry/syscall64.c:33) dosyscall64 (arch/x86/entry/common.c:?) entrySYSCALL64afterhwframe (arch/x86/entry/entry64.S:130)

value changed: 0x00000012 -> 0x00000000

Database specific
{
    "cna_assigner": "Linux",
    "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/40xxx/CVE-2024-40953.json"
}
References

Affected packages

Git / git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git

Affected ranges

Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
217ece6129f2d3b4fdd18d9e79be9e43d8d14a42
Fixed
11a772d5376aa6d3e2e69b5b5c585f79b60c0e17
Fixed
4c141136a28421b78f34969b25a4fa32e06e2180
Fixed
71fbc3af3dacb26c3aa2f30bb3ab05c44d082c84
Fixed
82bd728a06e55f5b5f93d10ce67f4fe7e689853a
Fixed
92c77807d938145c7c3350c944ef9f39d7f6017c
Fixed
a937ef951bba72f48d2402451419d725d70dba20
Fixed
95c8dd79f3a14df96b3820b35b8399bd91b2be60
Fixed
49f683b41f28918df3e51ddc0d928cb2e934ccdb

Database specific

source
"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2024-40953.json"