kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: work around leak of uninitialized stack contents
@ 2019-09-12  4:18 Fuqian Huang
  2019-09-12  8:51 ` Vitaly Kuznetsov
  2019-09-12 21:20 ` Jim Mattson
  0 siblings, 2 replies; 10+ messages in thread
From: Fuqian Huang @ 2019-09-12  4:18 UTC (permalink / raw)
  Cc: Paolo Bonzini, Radim Krčmář,
	Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
	Joerg Roedel, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	H . Peter Anvin, x86, kvm, linux-kernel, Fuqian Huang

Emulation of VMPTRST can incorrectly inject a page fault
when passed an operand that points to an MMIO address.
The page fault will use uninitialized kernel stack memory
as the CR2 and error code.

The right behavior would be to abort the VM with a KVM_EXIT_INTERNAL_ERROR
exit to userspace; however, it is not an easy fix, so for now just ensure
that the error code and CR2 are zero.

Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
---
 arch/x86/kvm/x86.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 290c3c3efb87..7f442d710858 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -5312,6 +5312,7 @@ int kvm_write_guest_virt_system(struct kvm_vcpu *vcpu, gva_t addr, void *val,
 	/* kvm_write_guest_virt_system can pull in tons of pages. */
 	vcpu->arch.l1tf_flush_l1d = true;
 
+	memset(exception, 0, sizeof(*exception));
 	return kvm_write_guest_virt_helper(addr, val, bytes, vcpu,
 					   PFERR_WRITE_MASK, exception);
 }
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-09-13  9:07 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-12  4:18 [PATCH] KVM: x86: work around leak of uninitialized stack contents Fuqian Huang
2019-09-12  8:51 ` Vitaly Kuznetsov
2019-09-12  8:56   ` Fuqian Huang
2019-09-12 10:53     ` Vitaly Kuznetsov
2019-09-12 12:02       ` Fuqian Huang
2019-09-12 16:20   ` Jim Mattson
2019-09-12 16:44     ` Vitaly Kuznetsov
2019-09-12 21:20 ` Jim Mattson
2019-09-12 23:52   ` Sean Christopherson
2019-09-13  9:07     ` Paolo Bonzini

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).