diff options
author | Yu Zhang <yu.c.zhang@linux.intel.com> | 2017-09-18 06:45:01 -0400 |
---|---|---|
committer | Radim Krčmář <rkrcmar@redhat.com> | 2017-09-19 08:28:58 -0400 |
commit | d6500149bc4fddc5a91cd1a0c31b38fa36bff3ee (patch) | |
tree | 63bebe3b669b051526b608e50db1fbdc4c753d94 | |
parent | 95e2a3b3ef177730019e3799917193595133b275 (diff) |
KVM: x86: Fix the NULL pointer parameter in check_cr_write()
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: d1cd3ce90044 ("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>
-rw-r--r-- | arch/x86/kvm/emulate.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 16bf6655aa85..15f527b44aa7 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c | |||
@@ -4102,10 +4102,12 @@ static int check_cr_write(struct x86_emulate_ctxt *ctxt) | |||
4102 | ctxt->ops->get_msr(ctxt, MSR_EFER, &efer); | 4102 | ctxt->ops->get_msr(ctxt, MSR_EFER, &efer); |
4103 | if (efer & EFER_LMA) { | 4103 | if (efer & EFER_LMA) { |
4104 | u64 maxphyaddr; | 4104 | u64 maxphyaddr; |
4105 | u32 eax = 0x80000008; | 4105 | u32 eax, ebx, ecx, edx; |
4106 | 4106 | ||
4107 | if (ctxt->ops->get_cpuid(ctxt, &eax, NULL, NULL, | 4107 | eax = 0x80000008; |
4108 | NULL, false)) | 4108 | ecx = 0; |
4109 | if (ctxt->ops->get_cpuid(ctxt, &eax, &ebx, &ecx, | ||
4110 | &edx, false)) | ||
4109 | maxphyaddr = eax & 0xff; | 4111 | maxphyaddr = eax & 0xff; |
4110 | else | 4112 | else |
4111 | maxphyaddr = 36; | 4113 | maxphyaddr = 36; |