All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>, qemu-devel@nongnu.org
Cc: dgilbert@redhat.com, Juan Quintela <quintela@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/4] migration: fix parameter validation on ram load
Date: Wed, 12 Nov 2014 10:49:42 +0100	[thread overview]
Message-ID: <54632D36.10500@redhat.com> (raw)
In-Reply-To: <1415785203-26938-2-git-send-email-mst@redhat.com>



On 12/11/2014 10:44, Michael S. Tsirkin wrote:
> During migration, the values read from migration stream during ram load
> are not validated. Especially offset in host_from_stream_offset() and
> also the length of the writes in the callers of said function.
> 
> To fix this, we need to make sure that the [offset, offset + length]
> range fits into one of the allocated memory regions.
> 
> Validating addr < len should be sufficient since data seems to always be
> managed in TARGET_PAGE_SIZE chunks.
> 
> Fixes: CVE-2014-7840
> 
> Note: follow-up patches add extra checks on each block->host access.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  arch_init.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/arch_init.c b/arch_init.c
> index 88a5ba0..593a990 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
>      uint8_t len;
>  
>      if (flags & RAM_SAVE_FLAG_CONTINUE) {
> -        if (!block) {
> +        if (!block || block->length <= offset) {
>              error_report("Ack, bad migration stream!");
>              return NULL;
>          }
> @@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
>      id[len] = 0;
>  
>      QTAILQ_FOREACH(block, &ram_list.blocks, next) {
> -        if (!strncmp(id, block->idstr, sizeof(id)))
> +        if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
>              return memory_region_get_ram_ptr(block->mr) + offset;
> +        }
>      }
>  
>      error_report("Can't find block %s!", id);
> 

Sort-of Yoda conditionals, i.e. I think "offset >= block->length" and
"offset < block->length" would have been more common and indeed that's
what you use in patch 3.  That's the only comment I have.

Series

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

  reply	other threads:[~2014-11-12  9:50 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-12  9:44 [Qemu-devel] [PATCH 0/4] migration: fix CVE-2014-7840 Michael S. Tsirkin
2014-11-12  9:44 ` [Qemu-devel] [PATCH 1/4] migration: fix parameter validation on ram load Michael S. Tsirkin
2014-11-12  9:49   ` Paolo Bonzini [this message]
2014-11-12  9:44 ` [Qemu-devel] [PATCH 2/4] exec: add wrapper for host pointer access Michael S. Tsirkin
2014-11-17 10:58   ` Dr. David Alan Gilbert
2014-11-17 11:36     ` Michael S. Tsirkin
2014-11-17 12:59       ` Dr. David Alan Gilbert
2014-11-17 16:16         ` Michael S. Tsirkin
2014-11-12  9:44 ` [Qemu-devel] [PATCH 3/4] cpu: assert host pointer offset within block Michael S. Tsirkin
2014-11-12  9:44 ` [Qemu-devel] [PATCH 4/4] cpu: verify that block->host is set Michael S. Tsirkin
2014-11-17  6:36 ` [Qemu-devel] [PATCH 0/4] migration: fix CVE-2014-7840 Amit Shah
2014-11-17 10:32   ` Michael S. Tsirkin
2014-11-17 10:38     ` Amit Shah
2014-11-17 10:52       ` Michael S. Tsirkin
2014-11-17 11:07         ` Amit Shah
2014-11-17 11:48           ` Michael S. Tsirkin
2014-11-17 12:20             ` Amit Shah
2014-11-17 12:36               ` Michael S. Tsirkin
2014-11-18  9:03                 ` Amit Shah
2014-11-18  9:01 ` Amit Shah
2014-11-18  9:11   ` Dr. David Alan Gilbert
2014-11-18  9:27   ` Michael S. Tsirkin
2014-11-18  9:32     ` Dr. David Alan Gilbert
2014-12-08 23:32 ` Amos Kong
2014-12-10  2:55 ` Amit Shah

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=54632D36.10500@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.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 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.