mirror of
https://github.com/hardkernel/linux.git
synced 2026-03-24 19:40:21 +09:00
vfio-pci: Fix possible integer overflow
BugLink: http://bugs.launchpad.net/bugs/1168506
commit 904c680c7b upstream.
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
This commit is contained in:
committed by
Tim Gardner
parent
1ee5641212
commit
1d3555bcaf
@@ -331,6 +331,7 @@ static long vfio_pci_ioctl(void *device_data,
|
||||
|
||||
if (!(hdr.flags & VFIO_IRQ_SET_DATA_NONE)) {
|
||||
size_t size;
|
||||
int max = vfio_pci_get_irq_count(vdev, hdr.index);
|
||||
|
||||
if (hdr.flags & VFIO_IRQ_SET_DATA_BOOL)
|
||||
size = sizeof(uint8_t);
|
||||
@@ -340,7 +341,7 @@ static long vfio_pci_ioctl(void *device_data,
|
||||
return -EINVAL;
|
||||
|
||||
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;
|
||||
|
||||
data = memdup_user((void __user *)(arg + minsz),
|
||||
|
||||
Reference in New Issue
Block a user