* [PATCH] KVM: x86: fix wbinvd_dirty_mask use-after-free
@ 2016-10-21 16:39 Ido Yariv
2016-10-24 14:15 ` Paolo Bonzini
2016-10-24 15:23 ` Radim Krčmář
0 siblings, 2 replies; 3+ messages in thread
From: Ido Yariv @ 2016-10-21 16:39 UTC (permalink / raw)
To: Paolo Bonzini, Radim Krčmář
Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, kvm,
linux-kernel, Ido Yariv, stable
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.
Cc: stable@vger.kernel.org
Signed-off-by: Ido Yariv <ido@wizery.com>
---
arch/x86/kvm/x86.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 6c633de..9ec8c1d 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7410,10 +7410,12 @@ void kvm_put_guest_fpu(struct kvm_vcpu *vcpu)
void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu)
{
+ void *wbinvd_dirty_mask = vcpu->arch.wbinvd_dirty_mask;
+
kvmclock_reset(vcpu);
- free_cpumask_var(vcpu->arch.wbinvd_dirty_mask);
kvm_x86_ops->vcpu_free(vcpu);
+ free_cpumask_var(wbinvd_dirty_mask);
}
struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
--
2.5.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: x86: fix wbinvd_dirty_mask use-after-free
2016-10-21 16:39 [PATCH] KVM: x86: fix wbinvd_dirty_mask use-after-free Ido Yariv
@ 2016-10-24 14:15 ` Paolo Bonzini
2016-10-24 15:23 ` Radim Krčmář
1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2016-10-24 14:15 UTC (permalink / raw)
To: Ido Yariv, Radim Krčmář
Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, kvm,
linux-kernel, stable
On 21/10/2016 18:39, Ido Yariv wrote:
> 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.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Ido Yariv <ido@wizery.com>
> ---
> arch/x86/kvm/x86.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 6c633de..9ec8c1d 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -7410,10 +7410,12 @@ void kvm_put_guest_fpu(struct kvm_vcpu *vcpu)
>
> void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu)
> {
> + void *wbinvd_dirty_mask = vcpu->arch.wbinvd_dirty_mask;
> +
> kvmclock_reset(vcpu);
>
> - free_cpumask_var(vcpu->arch.wbinvd_dirty_mask);
> kvm_x86_ops->vcpu_free(vcpu);
> + free_cpumask_var(wbinvd_dirty_mask);
> }
>
> struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: x86: fix wbinvd_dirty_mask use-after-free
2016-10-21 16:39 [PATCH] KVM: x86: fix wbinvd_dirty_mask use-after-free Ido Yariv
2016-10-24 14:15 ` Paolo Bonzini
@ 2016-10-24 15:23 ` Radim Krčmář
1 sibling, 0 replies; 3+ messages in thread
From: Radim Krčmář @ 2016-10-24 15:23 UTC (permalink / raw)
To: Ido Yariv
Cc: Paolo Bonzini, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86,
kvm, linux-kernel, stable
2016-10-21 12:39-0400, Ido Yariv:
> 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.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Ido Yariv <ido@wizery.com>
> ---
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-10-24 15:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-21 16:39 [PATCH] KVM: x86: fix wbinvd_dirty_mask use-after-free Ido Yariv
2016-10-24 14:15 ` Paolo Bonzini
2016-10-24 15:23 ` Radim Krčmář
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).