Re: [PATCH] KVM: nVMX: Clear nested.smm.guest_mode when freeing nested state
From: Sean Christopherson
Date: Fri Nov 13 2026 - 09:51:02 EST
On Thu, 22 Oct 2026 12:29:08 -0700, Sean Christopherson wrote:
> If an SMI arrives while L2 is active, vmx_enter_smm() forces a VM-Exit
> to L1, and records in nested.smm.guest_mode that RSM has to re-enter L2
> and in nested.smm.vmxon that the vCPU was post-VMXON. free_nested()
> clears the latter, but not the former.
>
> Userspace can get KVM to free the nested state while the vCPU is in SMM,
> with KVM_SET_NESTED_STATE, e.g. with no VMXON region to say that the
> vCPU isn't in VMX operation, or by flipping the SMM flag back and forth
> with KVM_SET_VCPU_EVENTS. When the guest then executes RSM,
> vmx_leave_smm() tries to re-enter L2 even though there is no vmcs12 any
> more, and nested_vmx_check_restored_vmcs12() dereferences the NULL
> nested.cached_vmcs12.
>
> [...]
Applied to kvm-x86 fixes, thanks!
[1/1] KVM: nVMX: Clear nested.smm.guest_mode when freeing nested state
https://github.com/kvm-x86/linux/commit/809f39842c17
--
https://github.com/kvm-x86/linux/tree/next