KVM: x86: fix use of uninitialized memory as segment descriptor in emulator.
authorGleb Natapov <gleb@redhat.com>
Mon, 21 Jan 2013 13:36:48 +0000 (15:36 +0200)
committerMarcelo Tosatti <mtosatti@redhat.com>
Thu, 24 Jan 2013 02:40:31 +0000 (00:40 -0200)
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@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/x86/kvm/x86.c

index e00dd0515a84874af7b55fd1a5f828180d721ee3..b9f55299ed7e1ac535f8236626c4d5642f4c093b 100644 (file)
@@ -4489,8 +4489,10 @@ static bool emulator_get_segment(struct x86_emulate_ctxt *ctxt, u16 *selector,
        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;