Skip to content

Commit c6bf2ae

Browse files
jan-kiszkabonzini
authored andcommitted
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>
1 parent d9a710e commit c6bf2ae

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎arch/x86/kvm/vmx/nested.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,9 @@ static void free_nested(struct kvm_vcpu *vcpu)
234234
vmx->vmcs01.shadow_vmcs = NULL;
235235
}
236236
kfree(vmx->nested.cached_vmcs12);
237+
vmx->nested.cached_vmcs12 = NULL;
237238
kfree(vmx->nested.cached_shadow_vmcs12);
239+
vmx->nested.cached_shadow_vmcs12 = NULL;
238240
/* Unpin physical memory we referred to in the vmcs02 */
239241
if (vmx->nested.apic_access_page) {
240242
kvm_release_page_dirty(vmx->nested.apic_access_page);

0 commit comments

Comments
 (0)