qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v4 0/9] virtio: avoid inappropriate QEMU termination in device code
@ 2016-09-30 15:12 Greg Kurz
  2016-09-30 15:12 ` [Qemu-devel] [PATCH v4 1/9] virtio-9p: add parentheses to sizeof operator Greg Kurz
                   ` (9 more replies)
  0 siblings, 10 replies; 12+ messages in thread
From: Greg Kurz @ 2016-09-30 15:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Michael S. Tsirkin, Jason Wang, Greg Kurz, Max Reitz,
	Aneesh Kumar K.V, Stefan Hajnoczi, Cornelia Huck, Paolo Bonzini

Since commit "f5ed36635d8f virtio: stop virtqueue processing if device is
broken", QEMU has the ability to deactivate a virtio device that has hit
an unrecoverable issue. This is performed by calling the virtio_error()
function, which can also print an error message to the QEMU monitor.

The device-specific virtio code has many locations where exit() is called
because the guest sent malformed requests. This is suboptimal: the guest OS
may try to recover by resetting the device or at worse do a fast-reboot,
which is probably better than putting down the entire machine. Also, as
mentioned by Stefan Hajnoczi, this could be used by a malicious nested
guest with a passed through device to kill the parent QEMU, and thus all
its sibling VMs.

This series converts all the affected exit() call sites in the device-specific
code to call virtio_error() instead. Note that virtio-9p currently calls
assert() instead of exit(), but since this is exactly the same issue, it
is also converted.

The offending VirtQueueElement, and any previously received but still
unprocessed VirtQueueElement, are detached from the virtqueue and freed
altogether. This part requires the following patch, which is not upstream
yet:

	virtio: add virtio_detach_element()

Message-Id: <1474291685-24226-2-git-send-email-stefanha@redhat.com>

Next work will be to check all assert() call sites in the device-specific code,
in case some of them actually refer to a bug in the guest, and should be
converted to use virtio_error() as well.

It is based on the virtio maintainer tree:

https://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git fb9f592623b0

and the "virtio: add virtio_detach_element()" patch mentionned above.

This v4 is basically the same as v3, with a trivial fix in patch 8/9.

Please apply.

---

Greg Kurz (9):
      virtio-9p: add parentheses to sizeof operator
      virtio-blk: make some functions static
      virtio-9p: handle handle_9p_output() error
      virtio-blk: handle virtio_blk_handle_request() errors
      virtio-net: handle virtio_net_handle_ctrl() error
      virtio-net: handle virtio_net_receive() errors
      virtio-net: handle virtio_net_flush_tx() errors
      virtio-scsi: convert virtio_scsi_bad_req() to use virtio_error()
      virtio-scsi: handle virtio_scsi_set_config() error


 hw/9pfs/virtio-9p-device.c     |   30 +++++++++++++++-----
 hw/block/virtio-blk.c          |   46 +++++++++++++++++++++----------
 hw/net/virtio-net.c            |   60 +++++++++++++++++++++++++---------------
 hw/scsi/virtio-scsi.c          |   51 +++++++++++++++++++++++-----------
 include/hw/virtio/virtio-blk.h |    8 -----
 5 files changed, 128 insertions(+), 67 deletions(-)

--
Greg

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-10-04 16:00 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-30 15:12 [Qemu-devel] [PATCH v4 0/9] virtio: avoid inappropriate QEMU termination in device code Greg Kurz
2016-09-30 15:12 ` [Qemu-devel] [PATCH v4 1/9] virtio-9p: add parentheses to sizeof operator Greg Kurz
2016-09-30 15:12 ` [Qemu-devel] [PATCH v4 2/9] virtio-blk: make some functions static Greg Kurz
2016-09-30 15:12 ` [Qemu-devel] [PATCH v4 3/9] virtio-9p: handle handle_9p_output() error Greg Kurz
2016-09-30 15:13 ` [Qemu-devel] [PATCH v4 4/9] virtio-blk: handle virtio_blk_handle_request() errors Greg Kurz
2016-09-30 15:13 ` [Qemu-devel] [PATCH v4 5/9] virtio-net: handle virtio_net_handle_ctrl() error Greg Kurz
2016-09-30 15:13 ` [Qemu-devel] [PATCH v4 6/9] virtio-net: handle virtio_net_receive() errors Greg Kurz
2016-09-30 15:13 ` [Qemu-devel] [PATCH v4 7/9] virtio-net: handle virtio_net_flush_tx() errors Greg Kurz
2016-09-30 15:13 ` [Qemu-devel] [PATCH v4 8/9] virtio-scsi: convert virtio_scsi_bad_req() to use virtio_error() Greg Kurz
2016-10-04 15:59   ` Stefan Hajnoczi
2016-09-30 15:13 ` [Qemu-devel] [PATCH v4 9/9] virtio-scsi: handle virtio_scsi_set_config() error Greg Kurz
2016-09-30 15:51 ` [Qemu-devel] [PATCH v4 0/9] virtio: avoid inappropriate QEMU termination in device code no-reply

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).