]> www.infradead.org Git - users/jedix/linux-maple.git/commit
KVM: nVMX: Assert that vcpu->mutex is held when accessing secondary VMCSes
authorSean Christopherson <seanjc@google.com>
Fri, 6 Sep 2024 04:34:13 +0000 (21:34 -0700)
committerSean Christopherson <seanjc@google.com>
Tue, 10 Sep 2024 03:15:03 +0000 (20:15 -0700)
commit3dde46a21aa72a3640bf3f6ff5ce7838af06a1f9
tree52c60212980d73a6b16b3f3e96b6109e5b17c735
parent1ed0f119c5ff66bec663ba5507539ec4a4f33775
KVM: nVMX: Assert that vcpu->mutex is held when accessing secondary VMCSes

Add lockdep assertions in get_vmcs12() and get_shadow_vmcs12() to verify
the vCPU's mutex is held, as the returned VMCS objects are dynamically
allocated/freed when nested VMX is turned on/off, i.e. accessing vmcs12
structures without holding vcpu->mutex is susceptible to use-after-free.

Waive the assertion if the VM is being destroyed, as KVM currently forces
a nested VM-Exit when freeing the vCPU.  If/when that wart is fixed, the
assertion can/should be converted to an unqualified lockdep assertion.
See also https://lore.kernel.org/all/Zsd0TqCeY3B5Sb5b@google.com.

Link: https://lore.kernel.org/r/20240906043413.1049633-8-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/vmx/nested.h