KVM: nVMX: Nullify cached vmcs12 pointers if entering VMX operation fails
Sean Christopherson
maintainerPATCH 1/1 KVM: nVMX: Nullify cached vmcs12 pointers if entering VMX operation fails
From: Amirmohammad Eftekhar <[email protected]>
Nullify the cached vmcs12 pointers after freeing them if "entering" VMX ultimately fails (because of an allocation failure), so that if a stale pointer is consumed, KVM hits a NULL pointer dereference instead of a use-after-free. I.e. crash the host instead of providing a potential guest escape vector if KVM is buggy.
--- arch/x86/kvm/vmx/nested.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/kvm/vmx/nested.c +2 -0
@@ -5463,9 +5463,11 @@ static int enter_vmx_operation(struct kvm_vcpu *vcpu) out_shadow_vmcs:kfree (vmx->nested.cached_shadow_vmcs12); + vmx->nested.cached_shadow_vmcs12 =NULL ; out_cached_shadow_vmcs12:kfree (vmx->nested.cached_vmcs12); + vmx->nested.cached_vmcs12 =NULL ; out_cached_vmcs12:free_loaded_vmcs (&vmx->nested.vmcs02);
base-commit: 164405e8e9a0378c7e1aff2254625a6553a291f1
Signature · 1 line
2.56.0.257.gf7497c7d27-goog
Quoted 8 lines · Sean Christopherson
Nullify the cached vmcs12 pointers after freeing them if "entering" VMX ultimately fails (because of an allocation failure), so that if a stale pointer is consumed, KVM hits a NULL pointer dereference instead of a use-after-free. I.e. crash the host instead of providing a potential guest escape vector if KVM is buggy.
[...]
Applied to kvm-x86 vmx, thanks!
[1/1] KVM: nVMX: Nullify cached vmcs12 pointers if entering VMX operation fails
https://github.com/kvm-x86/linux/commit/7597bc333891