qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	qemu-stable@nongnu.org, dgilbert@redhat.com,
	mdroth@linux.vnet.ibm.com
Subject: [Qemu-devel] [PATCH v5 00/24] qemu state loading issues
Date: Thu, 3 Apr 2014 19:50:23 +0300	[thread overview]
Message-ID: <1396543778-22307-1-git-send-email-mst@redhat.com> (raw)

Changes from v4:
    Addressed comments by Peter, David, Amit, Laszlo
    dropped vmxnet3 patches: will re-add when author
        addresses comments raised
    dropped stellaris patches: superceded by Peter's rewrite
    Added Peter's better fix for savevm crash

Changes from v3:
    Rewritten input validation in multiple patches using the new
    VMSTATE_VALIDATE macro.
    Addressed review comments from Peter Maydell,
    Andreas Färber, Don Koch and Dr. David Alan Gilbert.

The following is the list of patches unmodified from v4:
 vmstate: add VMS_MUST_EXIST
 vmstate: add VMSTATE_VALIDATE
 virtio-net: fix buffer overflow on invalid state load
    [patch unchanged, comment tweaked as suggested by Laszlo]
 virtio-net: out-of-bounds buffer write on invalid state load
 virtio: out-of-bounds buffer write on invalid state load
 ahci: fix buffer overrun on invalid state load
 hpet: fix buffer overrun on invalid state load
 hw/pci/pcie_aer.c: fix buffer overruns on invalid state load
 virtio: avoid buffer overrun on incoming migration
 pxa2xx: avoid buffer overrun on incoming migration
 zaurus: fix buffer overrun on invalid state load
 virtio-scsi: fix buffer overrun on invalid state load

The following is the list of patches unmodified from v1:
 virtio: out-of-bounds buffer write on invalid state load
 ahci: fix buffer overrun on invalid state load
 virtio: avoid buffer overrun on incoming migration


In some cases CVEs have been created to track specific issues.
Where available, CVE # is listed in the commit log.

I doubt it makes sense to push this urgently into 2.0.

Let's fix for 2.1, and backport as appropriate.

Cover latter from v1:
The state loading functionality was written under
the assumption that the state being loaded can be trusted. This is
mostly true, but we have identified at least two scenarios where it's
not:

* An attacker who has complete control over source qemu-kvm/node (via
  another flaw) and wants to attack destination node (source and
  destination for live migration). He can thus change the migration
  data that will be processed on the destination node, potentially
  allowing exploitation and remote code execution.

  Also, migration initiation is a privileged operation, but I think the
  attacker on the source node could probably fake some symptoms that
  would either make some automated process to start migrating off VMs
  from the node or make node admin to notice and start manual
  migration.

  MITM attack is not considered to be security relevant since the
  security between endpoints can be considered to be configuration
  issue.

* Saving/Loading state to/from file.

  For example, some bugzilla entries supply a savevm file
  and ask developer to load that to reproduce.
  
  After I have identified a first issue like this,
  a full audit of the qemu code base was done by Anthony Liguori, Michael
  Roth, myself and others, and found multiple instances where loading in
  invalid image would corrupt QEMU memory, in some instances making it
  possible to overwrite it with attacker-controlled data.
  
  This patchset is the result of that audit: it addresses this set of
  security issues by adding input validation and failing migration on
  invalid input.
  
  Considering the preconditions, I think that the impact on typical qemu usage is
  low.  Still, I think these patches make sense for qemu-stable.
  
  Lots of thanks to Stefan Hajnoczi, Gerd Hoffmann, Kevin Wolf, Paolo
  Bonzini and Hans de Goede, for help with the code audit.  Petr
  Matousek for review. I hope I didn't forget anyone involved, if I did
  I apologize in advance.
  
  I have parked them on my tree for now so they are not lost.
  
  Please review, and consider for master and stable.

Michael Roth (2):
  virtio: avoid buffer overrun on incoming migration
  openpic: avoid buffer overrun on incoming migration

Michael S. Tsirkin (21):
  vmstate: reduce code duplication
  vmstate: add VMS_MUST_EXIST
  vmstate: add VMSTATE_VALIDATE
  virtio-net: fix buffer overflow on invalid state load
  virtio-net: out-of-bounds buffer write on load
  virtio-net: out-of-bounds buffer write on invalid state load
  virtio: out-of-bounds buffer write on invalid state load
  ahci: fix buffer overrun on invalid state load
  hpet: fix buffer overrun on invalid state load
  hw/pci/pcie_aer.c: fix buffer overruns on invalid state load
  pl022: fix buffer overun on invalid state load
  vmstate: fix buffer overflow in target-arm/machine.c
  virtio: validate num_sg when mapping
  pxa2xx: avoid buffer overrun on incoming migration
  ssi-sd: fix buffer overrun on invalid state load
  ssd0323: fix buffer overun on invalid state load
  tsc210x: fix buffer overrun on invalid state load
  zaurus: fix buffer overrun on invalid state load
  virtio-scsi: fix buffer overrun on invalid state load
  vmstate: s/VMSTATE_INT32_LE/VMSTATE_INT32_POSITIVE_LE/
  usb: sanity check setup_index+setup_len in post_load

Peter Maydell (1):
  savevm: Ignore minimum_version_id_old if there is no load_state_old

 include/hw/virtio/virtio-net.h |   4 +-
 include/migration/vmstate.h    |  11 +++-
 hw/arm/pxa2xx.c                |   8 ++-
 hw/display/ssd0323.c           |  24 ++++++++
 hw/gpio/zaurus.c               |  10 ++++
 hw/ide/ahci.c                  |   2 +-
 hw/input/tsc210x.c             |  12 ++++
 hw/intc/openpic.c              |  14 ++++-
 hw/net/virtio-net.c            |  19 +++++--
 hw/pci/pci.c                   |   4 +-
 hw/pci/pcie_aer.c              |  10 +++-
 hw/scsi/virtio-scsi.c          |   9 +++
 hw/sd/ssi-sd.c                 |   8 +++
 hw/ssi/pl022.c                 |  14 +++++
 hw/timer/hpet.c                |  13 +++++
 hw/usb/bus.c                   |   4 +-
 hw/virtio/virtio.c             |  17 +++++-
 target-arm/machine.c           |   2 +-
 vmstate.c                      | 126 +++++++++++++++++++++++------------------
 docs/migration.txt             |  12 ++--
 20 files changed, 243 insertions(+), 80 deletions(-)

-- 
MST

             reply	other threads:[~2014-04-03 16:50 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-03 16:50 Michael S. Tsirkin [this message]
2014-04-03 16:50 ` [Qemu-devel] [PATCH v5 01/24] vmstate: reduce code duplication Michael S. Tsirkin
2014-04-04  9:37   ` Juan Quintela
2014-04-03 16:50 ` [Qemu-devel] [PATCH v5 03/24] vmstate: add VMSTATE_VALIDATE Michael S. Tsirkin
2014-04-03 16:50 ` [Qemu-devel] [PATCH v5 04/24] virtio-net: fix buffer overflow on invalid state load Michael S. Tsirkin
2014-04-03 16:50 ` [Qemu-devel] [PATCH v5 05/24] virtio-net: out-of-bounds buffer write on load Michael S. Tsirkin
2014-04-03 17:26   ` Peter Maydell
2014-04-03 16:50 ` [Qemu-devel] [PATCH v5 06/24] virtio-net: out-of-bounds buffer write on invalid state load Michael S. Tsirkin
2014-04-03 16:51 ` [Qemu-devel] [PATCH v5 07/24] virtio: " Michael S. Tsirkin
2014-04-03 16:51 ` [Qemu-devel] [PATCH v5 08/24] ahci: fix buffer overrun " Michael S. Tsirkin
2014-04-03 16:51 ` [Qemu-devel] [PATCH v5 09/24] hpet: " Michael S. Tsirkin
2014-04-04  9:51   ` Juan Quintela
2014-04-04 14:47     ` Michael S. Tsirkin
2014-04-04 15:04       ` Michael S. Tsirkin
2014-04-04 15:11         ` Michael S. Tsirkin
2014-04-03 16:51 ` [Qemu-devel] [PATCH v5 10/24] hw/pci/pcie_aer.c: fix buffer overruns " Michael S. Tsirkin
2014-04-03 16:51 ` [Qemu-devel] [PATCH v5 11/24] pl022: fix buffer overun " Michael S. Tsirkin
2014-04-03 16:51 ` [Qemu-devel] [PATCH v5 12/24] vmstate: fix buffer overflow in target-arm/machine.c Michael S. Tsirkin
2014-04-04  9:43   ` Juan Quintela
2014-04-03 16:51 ` [Qemu-devel] [PATCH v5 13/24] virtio: avoid buffer overrun on incoming migration Michael S. Tsirkin
2014-04-03 16:51 ` [Qemu-devel] [PATCH v5 14/24] openpic: " Michael S. Tsirkin
2014-04-03 18:04   ` Alexander Graf
2014-04-03 16:51 ` [Qemu-devel] [PATCH v5 15/24] virtio: validate num_sg when mapping Michael S. Tsirkin
2014-04-03 16:51 ` [Qemu-devel] [PATCH v5 16/24] pxa2xx: avoid buffer overrun on incoming migration Michael S. Tsirkin
2014-04-03 16:52 ` [Qemu-devel] [PATCH v5 17/24] ssi-sd: fix buffer overrun on invalid state load Michael S. Tsirkin
2014-04-03 17:05   ` Peter Maydell
2014-04-03 17:51     ` Michael S. Tsirkin
2014-04-03 16:52 ` [Qemu-devel] [PATCH v5 18/24] ssd0323: fix buffer overun " Michael S. Tsirkin
2014-04-03 17:13   ` Peter Maydell
2014-04-03 16:52 ` [Qemu-devel] [PATCH v5 19/24] tsc210x: fix buffer overrun " Michael S. Tsirkin
2014-04-03 16:52 ` [Qemu-devel] [PATCH v5 20/24] zaurus: " Michael S. Tsirkin
2014-04-03 16:52 ` [Qemu-devel] [PATCH v5 21/24] virtio-scsi: " Michael S. Tsirkin
2014-04-03 16:52 ` [Qemu-devel] [PATCH v5 22/24] vmstate: s/VMSTATE_INT32_LE/VMSTATE_INT32_POSITIVE_LE/ Michael S. Tsirkin
2014-04-04  9:43   ` Juan Quintela
2014-04-03 16:52 ` [Qemu-devel] [PATCH v5 23/24] usb: sanity check setup_index+setup_len in post_load Michael S. Tsirkin
2014-04-07  7:14   ` Gerd Hoffmann
2014-04-03 16:52 ` [Qemu-devel] [PATCH v5 24/24] savevm: Ignore minimum_version_id_old if there is no load_state_old Michael S. Tsirkin
2014-04-04  9:45   ` Juan Quintela
     [not found] ` <1396543778-22307-3-git-send-email-mst@redhat.com>
2014-04-04  9:41   ` [Qemu-devel] [PATCH v5 02/24] vmstate: add VMS_MUST_EXIST Juan Quintela
2014-04-04  9:54     ` Dr. David Alan Gilbert

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=1396543778-22307-1-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.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 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).