]> git.proxmox.com Git - qemu.git/commitdiff
virtio: fix indirect descriptor buffer overflow
authorMichael S. Tsirkin <mst@redhat.com>
Mon, 20 Jun 2011 10:42:27 +0000 (13:42 +0300)
committerMichael S. Tsirkin <mst@redhat.com>
Sun, 17 Jul 2011 15:47:34 +0000 (18:47 +0300)
We were previously allowing arbitrarily-long indirect descriptors, which
could lead to a buffer overflow in qemu-kvm process.

CVE-2011-2212

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/virtio.c

index cc47a06a4e16d5ad91927514d419be4206e51e7b..a8f4940da2263c998b6d2373aeb24f3d1f4a0790 100644 (file)
@@ -449,9 +449,17 @@ int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem)
         struct iovec *sg;
 
         if (vring_desc_flags(desc_pa, i) & VRING_DESC_F_WRITE) {
+            if (elem->in_num >= ARRAY_SIZE(elem->in_sg)) {
+                error_report("Too many write descriptors in indirect table");
+                exit(1);
+            }
             elem->in_addr[elem->in_num] = vring_desc_addr(desc_pa, i);
             sg = &elem->in_sg[elem->in_num++];
         } else {
+            if (elem->out_num >= ARRAY_SIZE(elem->out_sg)) {
+                error_report("Too many read descriptors in indirect table");
+                exit(1);
+            }
             elem->out_addr[elem->out_num] = vring_desc_addr(desc_pa, i);
             sg = &elem->out_sg[elem->out_num++];
         }