aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2011-06-20 13:42:27 +0300
committerMichael S. Tsirkin <mst@redhat.com>2011-07-17 18:47:34 +0300
commitc8eac1cfa1e9104a658b4614ada758861b8d823a (patch)
tree6f8207e0e7a006386d6cec4d7aa1634f4282254d /hw
parent0d2b962d16feaf1eb1a4658a4c1b85642418cd07 (diff)
downloadqemu-c8eac1cfa1e9104a658b4614ada758861b8d823a.zip
qemu-c8eac1cfa1e9104a658b4614ada758861b8d823a.tar.gz
qemu-c8eac1cfa1e9104a658b4614ada758861b8d823a.tar.bz2
virtio: fix indirect descriptor buffer overflow
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>
Diffstat (limited to 'hw')
-rw-r--r--hw/virtio.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/hw/virtio.c b/hw/virtio.c
index cc47a06..a8f4940 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -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++];
}