Commit 904c680c authored by Alex Williamson's avatar Alex Williamson

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: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
parent 25e9789d
...@@ -346,6 +346,7 @@ static long vfio_pci_ioctl(void *device_data, ...@@ -346,6 +346,7 @@ static long vfio_pci_ioctl(void *device_data,
if (!(hdr.flags & VFIO_IRQ_SET_DATA_NONE)) { if (!(hdr.flags & VFIO_IRQ_SET_DATA_NONE)) {
size_t size; size_t size;
int max = vfio_pci_get_irq_count(vdev, hdr.index);
if (hdr.flags & VFIO_IRQ_SET_DATA_BOOL) if (hdr.flags & VFIO_IRQ_SET_DATA_BOOL)
size = sizeof(uint8_t); size = sizeof(uint8_t);
...@@ -355,7 +356,7 @@ static long vfio_pci_ioctl(void *device_data, ...@@ -355,7 +356,7 @@ static long vfio_pci_ioctl(void *device_data,
return -EINVAL; return -EINVAL;
if (hdr.argsz - minsz < hdr.count * size || if (hdr.argsz - minsz < hdr.count * size ||
hdr.count > vfio_pci_get_irq_count(vdev, hdr.index)) hdr.start >= max || hdr.start + hdr.count > max)
return -EINVAL; return -EINVAL;
data = memdup_user((void __user *)(arg + minsz), data = memdup_user((void __user *)(arg + minsz),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment