qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: "Justin M. Forbes" <jforbes@redhat.com>
Cc: qemu-devel@nongnu.org,
	Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] virtio: guard against negative vq notifies
Date: Mon, 9 May 2011 14:57:49 +0100	[thread overview]
Message-ID: <BANLkTikXhozSOfWwAbAXr4i-oK9CFJ3n6g@mail.gmail.com> (raw)
In-Reply-To: <1304890147-26679-1-git-send-email-stefanha@linux.vnet.ibm.com>

On Sun, May 8, 2011 at 10:29 PM, Stefan Hajnoczi
<stefanha@linux.vnet.ibm.com> wrote:
> The virtio_queue_notify() function checks that the virtqueue number is
> less than the maximum number of virtqueues.  A signed comparison is used
> but the virtqueue number could be negative if a buggy or malicious guest
> is run.  This results in memory accesses outside of the virtqueue array.
>
> It is risky doing input validation in common code instead of at the
> guest<->host boundary.  Note that virtio_queue_set_addr(),
> virtio_queue_get_addr(), virtio_queue_get_num(), and many other virtio
> functions do *not* validate the virtqueue number argument.
>
> Instead of fixing the comparison in virtio_queue_notify(), move the
> comparison to the virtio bindings (just like VIRTIO_PCI_QUEUE_SEL) where
> we have a uint32_t value and can avoid ever calling into common virtio
> code if the virtqueue number is invalid.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
> ---
>  hw/syborg_virtio.c |    4 +++-
>  hw/virtio-pci.c    |    4 +++-
>  hw/virtio.c        |    4 +---
>  3 files changed, 7 insertions(+), 5 deletions(-)

Please consider this patch for the stable tree once Michael is happy:
http://patchwork.ozlabs.org/patch/94604/

Stefan

  reply	other threads:[~2011-05-09 13:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-08 21:29 [Qemu-devel] [PATCH] virtio: guard against negative vq notifies Stefan Hajnoczi
2011-05-09 13:57 ` Stefan Hajnoczi [this message]
2011-05-19 14:25 ` Michael S. Tsirkin

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=BANLkTikXhozSOfWwAbAXr4i-oK9CFJ3n6g@mail.gmail.com \
    --to=stefanha@gmail.com \
    --cc=jforbes@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@linux.vnet.ibm.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;
as well as URLs for NNTP newsgroup(s).