aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/vfio/pci
diff options
context:
space:
mode:
authorAlex Williamson <alex.williamson@redhat.com>2013-03-26 13:33:16 -0400
committerAlex Williamson <alex.williamson@redhat.com>2013-03-26 13:33:16 -0400
commit904c680c7bf016a8619a045850937427f8d7368c (patch)
treec1f3e2c8ba7fb2e5f96070f8125003730a71d222 /drivers/vfio/pci
parent25e9789ddd9d14a8971f4a421d04f282719ab733 (diff)
vfio-pci: Fix possible integer overflow
The VFIO_DEVICE_SET_IRQS ioctl takes a start and count parameter, both of which are unsigned. We attempt to bounds check these, but fail to account for the case where start is a very large number, allowing start + count to wrap back into the valid range. Bounds check both start and start + count. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'drivers/vfio/pci')
-rw-r--r--drivers/vfio/pci/vfio_pci.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index 8189cb6a86af..7abc5c81af2c 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -346,6 +346,7 @@ static long vfio_pci_ioctl(void *device_data,
346 346
347 if (!(hdr.flags & VFIO_IRQ_SET_DATA_NONE)) { 347 if (!(hdr.flags & VFIO_IRQ_SET_DATA_NONE)) {
348 size_t size; 348 size_t size;
349 int max = vfio_pci_get_irq_count(vdev, hdr.index);
349 350
350 if (hdr.flags & VFIO_IRQ_SET_DATA_BOOL) 351 if (hdr.flags & VFIO_IRQ_SET_DATA_BOOL)
351 size = sizeof(uint8_t); 352 size = sizeof(uint8_t);
@@ -355,7 +356,7 @@ static long vfio_pci_ioctl(void *device_data,
355 return -EINVAL; 356 return -EINVAL;
356 357
357 if (hdr.argsz - minsz < hdr.count * size || 358 if (hdr.argsz - minsz < hdr.count * size ||
358 hdr.count > vfio_pci_get_irq_count(vdev, hdr.index)) 359 hdr.start >= max || hdr.start + hdr.count > max)
359 return -EINVAL; 360 return -EINVAL;
360 361
361 data = memdup_user((void __user *)(arg + minsz), 362 data = memdup_user((void __user *)(arg + minsz),