Просмотр исходного кода

KVM: x86: fix use of uninitialized memory as segment descriptor in emulator.

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>
Gleb Natapov 12 лет назад
Родитель
Сommit
378a8b099f
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      arch/x86/kvm/x86.c

+ 3 - 1
arch/x86/kvm/x86.c

@@ -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;