mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Yu Zhang <yu.c.zhang@linux.intel.com>, kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, pbonzini@redhat.com,
	jmattson@google.com, rkrcmar@redhat.com, tglx@linutronix.de,
	mingo@redhat.com, hpa@zytor.com
Subject: Re: [PATCH] KVM: x86: Fix the NULL pointer parameter in check_cr_write()
Date: Mon, 18 Sep 2017 14:19:26 +0200	[thread overview]
Message-ID: <62dd03f0-4049-1d9c-d07b-61cac4c49c93@redhat.com> (raw)
In-Reply-To: <1505731501-6821-1-git-send-email-yu.c.zhang@linux.intel.com>

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

  reply	other threads:[~2017-09-18 12:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-18 10:45 Yu Zhang
2017-09-18 12:19 ` David Hildenbrand [this message]
2017-09-18 15:56   ` Jim Mattson
2017-09-20  6:35     ` Yu Zhang
2017-09-20  8:13       ` Paolo Bonzini
2017-09-20  8:27         ` Yu Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=62dd03f0-4049-1d9c-d07b-61cac4c49c93@redhat.com \
    --to=david@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=yu.c.zhang@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®