[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v5 15/24] virtio: validate num_sg when mapping
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PATCH v5 15/24] virtio: validate num_sg when mapping |
Date: |
Thu, 3 Apr 2014 19:51:53 +0300 |
CVE-2013-4535
CVE-2013-4536
Both virtio-block and virtio-serial read,
VirtQueueElements are read in as buffers, and passed to
virtqueue_map_sg(), where num_sg is taken from the wire and can force
writes to indicies beyond VIRTQUEUE_MAX_SIZE.
To fix, validate num_sg.
Reported-by: Michael Roth <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
Cc: Amit Shah <address@hidden>
---
hw/virtio/virtio.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index bcbfbb2..3bad71e 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -430,6 +430,12 @@ void virtqueue_map_sg(struct iovec *sg, hwaddr *addr,
unsigned int i;
hwaddr len;
+ if (num_sg >= VIRTQUEUE_MAX_SIZE) {
+ error_report("virtio: map attempt out of bounds: %zd > %d",
+ num_sg, VIRTQUEUE_MAX_SIZE);
+ exit(1);
+ }
+
for (i = 0; i < num_sg; i++) {
len = sg[i].iov_len;
sg[i].iov_base = cpu_physical_memory_map(addr[i], &len, is_write);
--
MST
- Re: [Qemu-devel] [PATCH v5 09/24] hpet: fix buffer overrun on invalid state load, (continued)
- [Qemu-devel] [PATCH v5 10/24] hw/pci/pcie_aer.c: fix buffer overruns on invalid state load, Michael S. Tsirkin, 2014/04/03
- [Qemu-devel] [PATCH v5 11/24] pl022: fix buffer overun on invalid state load, Michael S. Tsirkin, 2014/04/03
- [Qemu-devel] [PATCH v5 12/24] vmstate: fix buffer overflow in target-arm/machine.c, Michael S. Tsirkin, 2014/04/03
- [Qemu-devel] [PATCH v5 13/24] virtio: avoid buffer overrun on incoming migration, Michael S. Tsirkin, 2014/04/03
- [Qemu-devel] [PATCH v5 14/24] openpic: avoid buffer overrun on incoming migration, Michael S. Tsirkin, 2014/04/03
- [Qemu-devel] [PATCH v5 16/24] pxa2xx: avoid buffer overrun on incoming migration, Michael S. Tsirkin, 2014/04/03
- [Qemu-devel] [PATCH v5 15/24] virtio: validate num_sg when mapping,
Michael S. Tsirkin <=
- [Qemu-devel] [PATCH v5 17/24] ssi-sd: fix buffer overrun on invalid state load, Michael S. Tsirkin, 2014/04/03
- [Qemu-devel] [PATCH v5 18/24] ssd0323: fix buffer overun on invalid state load, Michael S. Tsirkin, 2014/04/03
- [Qemu-devel] [PATCH v5 19/24] tsc210x: fix buffer overrun on invalid state load, Michael S. Tsirkin, 2014/04/03
- [Qemu-devel] [PATCH v5 21/24] virtio-scsi: fix buffer overrun on invalid state load, Michael S. Tsirkin, 2014/04/03
- [Qemu-devel] [PATCH v5 20/24] zaurus: fix buffer overrun on invalid state load, Michael S. Tsirkin, 2014/04/03
- [Qemu-devel] [PATCH v5 22/24] vmstate: s/VMSTATE_INT32_LE/VMSTATE_INT32_POSITIVE_LE/, Michael S. Tsirkin, 2014/04/03