Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: nVMX: Set cached_vmcs12 and cached_shadow_vmcs12 NULL after free

Shall help finding use-after-free bugs earlier.

Suggested-by: Liran Alon <liran.alon@oracle.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by

Jan Kiszka and committed by
Paolo Bonzini
c6bf2ae9 d9a710e5

+2
+2
arch/x86/kvm/vmx/nested.c
··· 234 234 vmx->vmcs01.shadow_vmcs = NULL; 235 235 } 236 236 kfree(vmx->nested.cached_vmcs12); 237 + vmx->nested.cached_vmcs12 = NULL; 237 238 kfree(vmx->nested.cached_shadow_vmcs12); 239 + vmx->nested.cached_shadow_vmcs12 = NULL; 238 240 /* Unpin physical memory we referred to in the vmcs02 */ 239 241 if (vmx->nested.apic_access_page) { 240 242 kvm_release_page_dirty(vmx->nested.apic_access_page);