From: Alex Williamson <alex.williamson@redhat.com>
To: alex.williamson@redhat.com
Cc: lersek@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH for-2.4 1/2] vfio-pci: Further fix BAR size overflow
Date: Thu, 16 Apr 2015 12:00:53 -0600 [thread overview]
Message-ID: <20150416180053.3224.5870.stgit@gimli.home> (raw)
In-Reply-To: <20150416175945.3224.58452.stgit@gimli.home>
In an analysis by Laszlo, the resulting type of our calculation for
the end of the MSI-X table, and thus the start of memory after the
table, is uint32_t. We're therefore not correctly preventing the
corner case overflow that we intended to fix here where a BAR >=4G
could place the MSI-X table to end exactly at the 4G boundary. The
MSI-X table offset is defined by the hardware spec to 32bits, so we
simply use a cast rather than changing data structure types. This
scenario is purely theoretically, typically the MSI-X table is located
at the front of the BAR.
Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
hw/vfio/pci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 6b80539..d387fbd 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2394,7 +2394,7 @@ static void vfio_map_bar(VFIOPCIDevice *vdev, int nr)
if (vdev->msix && vdev->msix->table_bar == nr) {
uint64_t start;
- start = HOST_PAGE_ALIGN(vdev->msix->table_offset +
+ start = HOST_PAGE_ALIGN((uint64_t)vdev->msix->table_offset +
(vdev->msix->entries * PCI_MSIX_ENTRY_SIZE));
size = start < bar->region.size ? bar->region.size - start : 0;
next prev parent reply other threads:[~2015-04-16 18:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-16 18:00 [Qemu-devel] [PATCH for-2.4 0/2] vfio-pci: Fixes for fixes Alex Williamson
2015-04-16 18:00 ` Alex Williamson [this message]
2015-04-16 18:00 ` [Qemu-devel] [PATCH for-2.4 2/2] vfio-pci: Fix error path sign Alex Williamson
2015-04-16 18:17 ` [Qemu-devel] [PATCH for-2.4 0/2] vfio-pci: Fixes for fixes Laszlo Ersek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150416180053.3224.5870.stgit@gimli.home \
--to=alex.williamson@redhat.com \
--cc=lersek@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).