Skip to content

Commit

Permalink
KVM: x86: Fix the NULL pointer parameter in check_cr_write()
Browse files Browse the repository at this point in the history
Routine check_cr_write() will trigger emulator_get_cpuid()->
kvm_cpuid() to get maxphyaddr, and NULL is passed as values
for ebx/ecx/edx. This is problematic because kvm_cpuid() will
dereference these pointers.

Fixes: d1cd3ce ("KVM: MMU: check guest CR3 reserved bits based on its physical address width.")
Reported-by: Jim Mattson <jmattson@google.com>
Signed-off-by: Yu Zhang <yu.c.zhang@linux.intel.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Jim Mattson <jmattson@google.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
  • Loading branch information
Yu Zhang authored and rkrcmar committed Sep 19, 2017
1 parent 95e2a3b commit d650014
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions arch/x86/kvm/emulate.c
Expand Up @@ -4102,10 +4102,12 @@ static int check_cr_write(struct x86_emulate_ctxt *ctxt)
ctxt->ops->get_msr(ctxt, MSR_EFER, &efer);
if (efer & EFER_LMA) {
u64 maxphyaddr;
u32 eax = 0x80000008;
u32 eax, ebx, ecx, edx;

if (ctxt->ops->get_cpuid(ctxt, &eax, NULL, NULL,
NULL, false))
eax = 0x80000008;
ecx = 0;
if (ctxt->ops->get_cpuid(ctxt, &eax, &ebx, &ecx,
&edx, false))
maxphyaddr = eax & 0xff;
else
maxphyaddr = 36;
Expand Down

0 comments on commit d650014

Please sign in to comment.