All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Gleb Natapov <gleb@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] Fix NULL dereference in gfn_to_hva_prot()
Date: Tue, 01 Oct 2013 19:03:03 +0200	[thread overview]
Message-ID: <524B0047.3080700@redhat.com> (raw)
In-Reply-To: <20131001165836.GX11993@redhat.com>

Il 01/10/2013 18:58, Gleb Natapov ha scritto:
> gfn_to_memslot() can return NULL or invalid slot. We need to check slot
> validity before accessing it.
> 
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 979bff4..a9dd682 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -1064,10 +1064,12 @@ EXPORT_SYMBOL_GPL(gfn_to_hva);
>  unsigned long gfn_to_hva_prot(struct kvm *kvm, gfn_t gfn, bool *writable)
>  {
>  	struct kvm_memory_slot *slot = gfn_to_memslot(kvm, gfn);
> -	if (writable)
> +	unsigned long hva = __gfn_to_hva_many(slot, gfn, NULL, false);
> +
> +	if (!kvm_is_error_hva(hva) && writable)
>  		*writable = !memslot_is_readonly(slot);
>  
> -	return __gfn_to_hva_many(gfn_to_memslot(kvm, gfn), gfn, NULL, false);
> +	return hva;
>  }
>  
>  static int kvm_read_hva(void *data, void __user *hva, int len)
> --
> 			Gleb.
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>


      reply	other threads:[~2013-10-01 17:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-01 16:58 [PATCH] Fix NULL dereference in gfn_to_hva_prot() Gleb Natapov
2013-10-01 17:03 ` Paolo Bonzini [this message]

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=524B0047.3080700@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=gleb@redhat.com \
    --cc=kvm@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.