qemu-e2k/hw/virtio
Stefan Hajnoczi afd9096eb1 virtio: error out if guest exceeds virtqueue size
A broken or malicious guest can submit more requests than the virtqueue
size permits, causing unbounded memory allocation in QEMU.

The guest can submit requests without bothering to wait for completion
and is therefore not bound by virtqueue size.  This requires reusing
vring descriptors in more than one request, which is not allowed by the
VIRTIO 1.0 specification.

In "3.2.1 Supplying Buffers to The Device", the VIRTIO 1.0 specification
says:

  1. The driver places the buffer into free descriptor(s) in the
     descriptor table, chaining as necessary

and

  Note that the above code does not take precautions against the
  available ring buffer wrapping around: this is not possible since the
  ring buffer is the same size as the descriptor table, so step (1) will
  prevent such a condition.

This implies that placing more buffers into the virtqueue than the
descriptor table size is not allowed.

QEMU is missing the check to prevent this case.  Processing a request
allocates a VirtQueueElement leading to unbounded memory allocation
controlled by the guest.

Exit with an error if the guest provides more requests than the
virtqueue size permits.  This bounds memory allocation and makes the
buggy guest visible to the user.

This patch fixes CVE-2016-5403 and was reported by Zhenhao Hong from 360
Marvel Team, China.

Reported-by: Zhenhao Hong <hongzhenhao@360.cn>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2016-07-27 14:04:40 +01:00
..
Makefile.objs vring: remove 2016-02-25 13:14:19 +02:00
trace-events trace: split out trace events for hw/virtio/ directory 2016-06-20 17:22:15 +01:00
vhost-backend.c Use #include "..." for our own headers, <...> for others 2016-07-12 16:19:16 +02:00
vhost-user.c memory: split memory_region_from_host from qemu_ram_addr_from_host 2016-05-29 09:11:12 +02:00
vhost.c tap: vhost busy polling support 2016-07-07 14:29:04 +08:00
virtio-balloon.c virtio-balloon: Wrap in vmstate 2016-07-21 20:44:20 +03:00
virtio-bus.c virtio: revert host notifiers to old semantics 2016-07-04 14:52:10 +03:00
virtio-mmio.c virtio-mmio: format transport base address in BusClass.get_dev_path 2016-07-14 16:51:36 +01:00
virtio-pci.c kvm-irqchip: do explicit commit when update irq 2016-07-21 20:44:19 +03:00
virtio-pci.h hw/virtio: group virtio flags into an enum 2016-03-11 14:54:28 +02:00
virtio-rng.c virtio-rng: Wrap in vmstate 2016-07-21 20:44:20 +03:00
virtio.c virtio: error out if guest exceeds virtqueue size 2016-07-27 14:04:40 +01:00