Skip to content

Commit

Permalink
virtio: out-of-bounds buffer write on invalid state load
Browse files Browse the repository at this point in the history
CVE-2013-4151 QEMU 1.0 out-of-bounds buffer write in
virtio_load@hw/virtio/virtio.c

So we have this code since way back when:

    num = qemu_get_be32(f);

    for (i = 0; i < num; i++) {
        vdev->vq[i].vring.num = qemu_get_be32(f);

array of vqs has size VIRTIO_PCI_QUEUE_MAX, so
on invalid input this will write beyond end of buffer.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
(cherry picked from commit cc45995)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
  • Loading branch information
mstsirkin authored and mdroth committed Jun 26, 2014
1 parent 7b6444a commit 5544b7e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion hw/virtio/virtio.c
Expand Up @@ -888,7 +888,8 @@ int virtio_set_features(VirtIODevice *vdev, uint32_t val)

int virtio_load(VirtIODevice *vdev, QEMUFile *f)
{
int num, i, ret;
int i, ret;
uint32_t num;
uint32_t features;
uint32_t supported_features;
BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
Expand Down Expand Up @@ -916,6 +917,11 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)

num = qemu_get_be32(f);

if (num > VIRTIO_PCI_QUEUE_MAX) {
error_report("Invalid number of PCI queues: 0x%x", num);
return -1;
}

for (i = 0; i < num; i++) {
vdev->vq[i].vring.num = qemu_get_be32(f);
if (k->has_variable_vring_alignment) {
Expand Down

0 comments on commit 5544b7e

Please sign in to comment.