Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1734255
| From | Jim Mattson <jmattson@google.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] KVM: x86: Fix the NULL pointer parameter in check_cr_write() |
| Date | 2017-09-18 18:00 +0200 |
| Message-ID | <ur6CK-8bR-5@gated-at.bofh.it> (permalink) |
| References | <ur265-5yD-21@gated-at.bofh.it> <ur3bQ-6bT-17@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
kvm_cpuid ultimately wants to write all four of the GPRs passed in by
reference. I don't see any advantage to allowing some of these
pointers to be NULL.
Reviewed-by: Jim Mattson <jmattson@google.com>
On Mon, Sep 18, 2017 at 5:19 AM, David Hildenbrand <david@redhat.com> wrote:
> On 18.09.2017 12:45, Yu Zhang wrote:
>> 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>
>> ---
>> arch/x86/kvm/emulate.c | 8 +++++---
>> 1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
>> index 16bf665..15f527b 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)
>> 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;
>>
>
> Not sure if fixing kvm_cpuid() would be better.
>
> Reviewed-by: David Hildenbrand <david@redhat.com>
>
> --
>
> Thanks,
>
> David
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] KVM: x86: Fix the NULL pointer parameter in check_cr_write() Yu Zhang <yu.c.zhang@linux.intel.com> - 2017-09-18 13:10 +0200
Re: [PATCH] KVM: x86: Fix the NULL pointer parameter in check_cr_write() David Hildenbrand <david@redhat.com> - 2017-09-18 14:20 +0200
Re: [PATCH] KVM: x86: Fix the NULL pointer parameter in check_cr_write() Jim Mattson <jmattson@google.com> - 2017-09-18 18:00 +0200
Re: [PATCH] KVM: x86: Fix the NULL pointer parameter in check_cr_write() Yu Zhang <yu.c.zhang@linux.intel.com> - 2017-09-20 09:00 +0200
Re: [PATCH] KVM: x86: Fix the NULL pointer parameter in check_cr_write() Paolo Bonzini <pbonzini@redhat.com> - 2017-09-20 10:20 +0200
Re: [PATCH] KVM: x86: Fix the NULL pointer parameter in check_cr_write() Yu Zhang <yu.c.zhang@linux.intel.com> - 2017-09-20 11:00 +0200
csiph-web