From: Michael Roth Date: Thu, 3 Apr 2014 16:51:46 +0000 (+0300) Subject: virtio: avoid buffer overrun on incoming migration X-Git-Tag: qemu-xen-4.4.3-rc1~36 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=d961961ec93227065fd343f5725a1ff756d6981f;p=qemu-xen.git virtio: avoid buffer overrun on incoming migration CVE-2013-6399 vdev->queue_sel is read from the wire, and later used in the emulation code as an index into vdev->vq[]. If the value of vdev->queue_sel exceeds the length of vdev->vq[], currently allocated to be VIRTIO_PCI_QUEUE_MAX elements, subsequent PIO operations such as VIRTIO_PCI_QUEUE_PFN can be used to overrun the buffer with arbitrary data originating from the source. Fix this by failing migration if the value from the wire exceeds VIRTIO_PCI_QUEUE_MAX. Signed-off-by: Michael Roth Signed-off-by: Michael S. Tsirkin Reviewed-by: Peter Maydell Signed-off-by: Juan Quintela --- diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 423b446462..3c59631f5b 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -910,6 +910,9 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f) qemu_get_8s(f, &vdev->status); qemu_get_8s(f, &vdev->isr); qemu_get_be16s(f, &vdev->queue_sel); + if (vdev->queue_sel >= VIRTIO_PCI_QUEUE_MAX) { + return -1; + } qemu_get_be32s(f, &features); if (virtio_set_features(vdev, features) < 0) {