This is a TOCTOU (time-of-check-time-of-use) vulnerability in KVM's nested virtualization (nVMX) code where the shadow VMCS page can be freed while hardware might still hold a reference to it, leading to use-after-free with potential cross-VM information leakage.

The bug lives in free_nested(), which releases the shadow VMCS page without coordinating with loaded_vmcs_clear(), the function that issues the VMCLEAR instruction to the hardware. The VMCLEAR instruction is synchronous—it blocks the logical CPU until completion—but a vCPU can migrate between physical CPUs between the moment the software pointer is cleared and the moment VMCLEAR actually executes on the hardware. This creates a window where the page is freed but a VMCLEAR on another physical CPU might still write to it. If that page gets reallocated, a subsequent VMCLEAR could leak contents from one guest's shadow VMCS into another guest's memory.

The fix reorders operations: keep the shadow VMCS attached through the VMCLEAR, then hide it. This is the correct lifecycle, but it patches one caller rather than fixing the infrastructure gap. The loaded_vmcs API provides per-vCPU spinlocks that protect software state transitions, but these do not serialize against hardware acknowledgment latency. There is no reference-counted handle or explicit release primitive that would structurally prevent free_nested() from freeing while any in-flight VMCLEAR could reference the page.

Check your kernels: any code path that frees shadow VMCS structures needs to be audited for this ordering. If you maintain downstream KVM code that calls free_nested() or similar teardown paths, verify they do not free before confirming all vCPUs have migrated away or issued their VMCLEARs. The broader concern is that nVMX testing typically runs inside nested VMs on single-socket cloud instances—the exact environment that won't trigger CPU-migration races. This class of bug may be undercounted in nVMX precisely because the required multi-socket, multi-vCPU migration scenarios are rare in test environments.