KVM: Fix a data race on last_boosted_vcpu in kvm_vcpu_on_spin()
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ 217ece6129f2d3b4fdd18d9e79be9e43d8d14a42 · < a937ef951bba72f48d2402451419d725d70dba20| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
KVM: Fix a data race on last_boosted_vcpu in kvm_vcpu_on_spin()
Use {READ,WRITE}_ONCE() to access kvm->last_boosted_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 last_boosted_vcpu = 0xff;
(last_boosted_vcpu = 0x100) last_boosted_vcpu[15:8] = 0x01; i = (last_boosted_vcpu = 0x1ff) last_boosted_vcpu[7:0] = 0x00;
vcpu = kvm->vcpu_array[0x1ff];
As detected by KCSAN:
BUG: KCSAN: data-race in kvm_vcpu_on_spin [kvm] / kvm_vcpu_on_spin [kvm]
From the CVE record · Linux
The Linux kernel’s KVM code has a data race in kvm_vcpu_on_spin(). If concurrent accesses coincide with a compiler-torn store, KVM could attempt an out-of-bounds vCPU lookup; the input does not establish an attacker access path or authentication requirements.
Engineers running Linux systems with KVM should check their kernels; affected versions are not specified.