diff mbox series

KVM: nVMX: Set cached_vmcs12 and cached_shadow_vmcs12 NULL after free

Message ID e48af3c7-c7ac-87b4-3ce1-9b7b775cd6f2@web.de (mailing list archive)
State New, archived
Headers show
Series KVM: nVMX: Set cached_vmcs12 and cached_shadow_vmcs12 NULL after free | expand

Commit Message

Jan Kiszka July 21, 2019, 2:01 p.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

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>
---
 arch/x86/kvm/vmx/nested.c | 2 ++
 1 file changed, 2 insertions(+)

--
2.16.4

Comments

Paolo Bonzini July 22, 2019, 11:50 a.m. UTC | #1
On 21/07/19 16:01, Jan Kiszka wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> 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>
> ---
>  arch/x86/kvm/vmx/nested.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
> index 4cdab4b4eff1..ced9fba32598 100644
> --- a/arch/x86/kvm/vmx/nested.c
> +++ b/arch/x86/kvm/vmx/nested.c
> @@ -234,7 +234,9 @@ static void free_nested(struct kvm_vcpu *vcpu)
>  		vmx->vmcs01.shadow_vmcs = NULL;
>  	}
>  	kfree(vmx->nested.cached_vmcs12);
> +	vmx->nested.cached_vmcs12 = NULL;
>  	kfree(vmx->nested.cached_shadow_vmcs12);
> +	vmx->nested.cached_shadow_vmcs12 = NULL;
>  	/* Unpin physical memory we referred to in the vmcs02 */
>  	if (vmx->nested.apic_access_page) {
>  		kvm_release_page_dirty(vmx->nested.apic_access_page);
> --
> 2.16.4
> 

Queued, thanks.

Paolo
diff mbox series

Patch

diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 4cdab4b4eff1..ced9fba32598 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -234,7 +234,9 @@  static void free_nested(struct kvm_vcpu *vcpu)
 		vmx->vmcs01.shadow_vmcs = NULL;
 	}
 	kfree(vmx->nested.cached_vmcs12);
+	vmx->nested.cached_vmcs12 = NULL;
 	kfree(vmx->nested.cached_shadow_vmcs12);
+	vmx->nested.cached_shadow_vmcs12 = NULL;
 	/* Unpin physical memory we referred to in the vmcs02 */
 	if (vmx->nested.apic_access_page) {
 		kvm_release_page_dirty(vmx->nested.apic_access_page);