[PATCH 3.2 036/106] KVM: x86: fix use of uninitialized memory as segment descriptor in emulator.

From: Ben Hutchings
Date: Sat Sep 09 2017 - 18:40:12 EST


3.2.93-rc1 review patch. If anyone has any objections, please let me know.

------------------

From: Gleb Natapov <gleb@xxxxxxxxxx>

commit 378a8b099fc207ddcb91b19a8c1457667e0af398 upstream.

If VMX reports segment as unusable, zero descriptor passed by the emulator
before returning. Such descriptor will be considered not present by the
emulator.

Signed-off-by: Gleb Natapov <gleb@xxxxxxxxxx>
Signed-off-by: Marcelo Tosatti <mtosatti@xxxxxxxxxx>
Signed-off-by: Ben Hutchings <ben@xxxxxxxxxxxxxxx>
---
arch/x86/kvm/x86.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4611,8 +4611,10 @@ static bool emulator_get_segment(struct
kvm_get_segment(emul_to_vcpu(ctxt), &var, seg);
*selector = var.selector;

- if (var.unusable)
+ if (var.unusable) {
+ memset(desc, 0, sizeof(*desc));
return false;
+ }

if (var.g)
var.limit >>= 12;