All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vfio/pci: Fix integer overflow/heap memory disclosure
@ 2016-10-11 11:02 Vlad Tsyrklevich
  2016-10-11 16:10 ` Alex Williamson
  0 siblings, 1 reply; 10+ messages in thread
From: Vlad Tsyrklevich @ 2016-10-11 11:02 UTC (permalink / raw)
  To: kvm; +Cc: alex.williamson, Vlad Tsyrklevich

The VFIO_DEVICE_SET_IRQS and VFIO_DEVICE_GET_PCI_HOT_RESET_INFO ioctls
do not sufficiently sanitize user-supplied integers, allowing users to
read arbitrary amounts of kernel heap memory or cause a crash.

Signed-off-by: Vlad Tsyrklevich <vlad@tsyrklevich.net>

---
 drivers/vfio/pci/vfio_pci.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index d624a52..c3fbfb8 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -838,6 +838,7 @@ static long vfio_pci_ioctl(void *device_data,
 			return -EFAULT;
 
 		if (hdr.argsz < minsz || hdr.index >= VFIO_PCI_NUM_IRQS ||
+		    hdr.count >= (U32_MAX - hdr.start) ||
 		    hdr.flags & ~(VFIO_IRQ_SET_DATA_TYPE_MASK |
 				  VFIO_IRQ_SET_ACTION_TYPE_MASK))
 			return -EINVAL;
@@ -909,6 +910,9 @@ static long vfio_pci_ioctl(void *device_data,
 
 		WARN_ON(!fill.max); /* Should always be at least one */
 
+		if (hdr.count > fill.max)
+			hdr.count = fill.max;
+
 		/*
 		 * If there's enough space, fill it now, otherwise return
 		 * -ENOSPC and the number of devices affected.
-- 
2.7.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-10-26 21:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-11 11:02 [PATCH] vfio/pci: Fix integer overflow/heap memory disclosure Vlad Tsyrklevich
2016-10-11 16:10 ` Alex Williamson
2016-10-11 20:04   ` Vlad Tsyrklevich
2016-10-11 22:39     ` Alex Williamson
2016-10-12  7:53       ` [PATCH v2] vfio/pci: Fix integer overflows, bitmask check Vlad Tsyrklevich
2016-10-12 14:51         ` Alex Williamson
2016-10-12 15:06           ` Vlad Tsyrklevich
2016-10-12 15:39             ` Alex Williamson
2016-10-12 16:51               ` [PATCH v3] " Vlad Tsyrklevich
2016-10-26 21:19                 ` Alex Williamson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.