KVM: x86: fix wbinvd_dirty_mask use-after-free
authorIdo Yariv <ido@wizery.com>
Fri, 21 Oct 2016 16:39:57 +0000 (12:39 -0400)
committerWilly Tarreau <w@1wt.eu>
Mon, 6 Feb 2017 08:04:07 +0000 (09:04 +0100)
commita3e49e607d8b858519a83ec65e4aac66ba847f62
tree8f7dfad7d9965951389393f0861ad2ae0a56ec63
parent010a6cc4a6431093afec6e1611310f9a0f4433fe
KVM: x86: fix wbinvd_dirty_mask use-after-free

commit bd768e146624cbec7122ed15dead8daa137d909d upstream.

vcpu->arch.wbinvd_dirty_mask may still be used after freeing it,
corrupting memory. For example, the following call trace may set a bit
in an already freed cpu mask:
    kvm_arch_vcpu_load
    vcpu_load
    vmx_free_vcpu_nested
    vmx_free_vcpu
    kvm_arch_vcpu_free

Fix this by deferring freeing of wbinvd_dirty_mask.

Signed-off-by: Ido Yariv <ido@wizery.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Radim KrÄ\8dmáÅ\99 <rkrcmar@redhat.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
arch/x86/kvm/x86.c