KVM: x86: zero base3 of unusable segments
authorRadim Krčmář <rkrcmar@redhat.com>
Thu, 18 May 2017 17:37:30 +0000 (19:37 +0200)
committerRadim Krčmář <rkrcmar@redhat.com>
Fri, 19 May 2017 17:59:27 +0000 (19:59 +0200)
Static checker noticed that base3 could be used uninitialized if the
segment was not present (useable).  Random stack values probably would
not pass VMCS entry checks.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 1aa366163b8b ("KVM: x86 emulator: consolidate segment accessors")
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
arch/x86/kvm/x86.c

index 519f3572e48e231a7959acfd614169e47e3be219..02363e37d4a61e8271d7fed0a8c534e9dd90f264 100644 (file)
@@ -5067,6 +5067,8 @@ static bool emulator_get_segment(struct x86_emulate_ctxt *ctxt, u16 *selector,
 
        if (var.unusable) {
                memset(desc, 0, sizeof(*desc));
+               if (base3)
+                       *base3 = 0;
                return false;
        }