cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
9ae3a8
From 27b471e574edcee7ac065a7a46f558dca0fd7bf0 Mon Sep 17 00:00:00 2001
9ae3a8
From: Alex Williamson <alex.williamson@redhat.com>
9ae3a8
Date: Fri, 10 Apr 2015 16:34:08 +0200
9ae3a8
Subject: [PATCH 06/14] vfio-pci: Fix BAR size overflow
9ae3a8
9ae3a8
Message-id: <20150410163408.15324.43004.stgit@gimli.home>
9ae3a8
Patchwork-id: 64792
9ae3a8
O-Subject: [RHEL7.2 qemu-kvm PATCH 6/8] vfio-pci: Fix BAR size overflow
9ae3a8
Bugzilla: 1181267
9ae3a8
RH-Acked-by: Thomas Huth <thuth@redhat.com>
9ae3a8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
RH-Acked-by: Bandan Das <bsd@redhat.com>
9ae3a8
9ae3a8
Upstream: 29c6e6df492d81b1843e5dd999171bb84c6effea
9ae3a8
9ae3a8
We use an unsigned int when working with the PCI BAR size, which can
9ae3a8
obviously overflow if the BAR is 4GB or larger.  This needs to change
9ae3a8
to a fixed length uint64_t.  A similar issue is possible, though even
9ae3a8
more unlikely, when mapping the region above an MSI-X table.  The
9ae3a8
start of the MSI-X vector table must be below 4GB, but the end, and
9ae3a8
therefore the start of the next mapping region, could still land at
9ae3a8
4GB.
9ae3a8
9ae3a8
Suggested-by: Nishank Trivedi <nishank.trivedi@netapp.com>
9ae3a8
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
9ae3a8
Reviewed-by: Don Slutz <dslutz@verizon.com>
9ae3a8
Tested-by: Alexey Kardashevskiy <aik@ozlabs.ru>
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/misc/vfio.c | 4 ++--
9ae3a8
 1 file changed, 2 insertions(+), 2 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
9ae3a8
index f6e019c..607dbf4 100644
9ae3a8
--- a/hw/misc/vfio.c
9ae3a8
+++ b/hw/misc/vfio.c
9ae3a8
@@ -2579,7 +2579,7 @@ empty_region:
9ae3a8
 static void vfio_map_bar(VFIODevice *vdev, int nr)
9ae3a8
 {
9ae3a8
     VFIOBAR *bar = &vdev->bars[nr];
9ae3a8
-    unsigned size = bar->size;
9ae3a8
+    uint64_t size = bar->size;
9ae3a8
     char name[64];
9ae3a8
     uint32_t pci_bar;
9ae3a8
     uint8_t type;
9ae3a8
@@ -2628,7 +2628,7 @@ static void vfio_map_bar(VFIODevice *vdev, int nr)
9ae3a8
     }
9ae3a8
 
9ae3a8
     if (vdev->msix && vdev->msix->table_bar == nr) {
9ae3a8
-        unsigned start;
9ae3a8
+        uint64_t start;
9ae3a8
 
9ae3a8
         start = TARGET_PAGE_ALIGN(vdev->msix->table_offset +
9ae3a8
                                   (vdev->msix->entries * PCI_MSIX_ENTRY_SIZE));
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8