Skip to content

Commit

Permalink
KVM: x86: fix use of uninitialized memory as segment descriptor in em…
Browse files Browse the repository at this point in the history
…ulator.

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>
  • Loading branch information
Gleb Natapov authored and Marcelo Tosatti committed Jan 24, 2013
1 parent 91b0aa2 commit 378a8b0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion arch/x86/kvm/x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 378a8b0

Please sign in to comment.