[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v2 0/2] Fix QEMU crashes when passing IGD to a guest VM under XEN
This is the v1 cover letter - the patches now include a detailed description of the changes. Hi, This patch series is a small subset of a bigger patch set spanning few projects aiming to isolate the GPU in QUBES OS to a dedicated security domain. I'm doing this together with 3 colleagues as part of our Bachelors thesis. When passing an Intel Graphic Device to a HVM guest under XEN, QEMU sometimes crashes when starting the VM. It turns out that the code responsible for setting up the legacy VBIOS for the IGD contains a bug which results in a memcpy of an undefined size between the QEMU heap and the physical memory of the guest. If the size of the memcpy is small enough qemu does not crash - this means that this bug is actually a small security issue - a hostile guest kernel might determine the memory layout of QEMU simply by looking at physical memory beyond 0xdffff - this defeats ASLR and might make exploitation easier if other issues were to be found. The problem is the current mechanism for obtaining a copy of the ROM of the IGD. We first allocate a buffer which holds the vbios - the size of which is obtained from sysfs. We then try to read the rom from sysfs, if we fail then we just return without setting the size of the buffer. This would be ok if the size of the ROM reported by sysfs would be 0, but the size is always 32 pages as this corresponds to legacy memory ranges. It turns out that reading the ROM fails on every single device I've tested(spanning few generations of IGD), which means qemu never sets the size of the buffer and returns a valid pointer to code which basically does a memcpy of an undefined size. I'm including two patches. The first one fixes the security issue by making failing to read the ROM from sysfs fatal. The second patch introduces a better method for obtaining the VBIOS. I've haven't yet seen a single device on which the old code was working, the new code basically creates a shadow copy directly by reading from /dev/mem - this should be fine as a quick grep of the codebase shows that this approach is already being used to handle MSI. I've tested the new code on few different laptops and it works fine and the guest VMS finally stopped complaining that the VBIOS tables are missing. Grzegorz Uriasz (2): Fix undefined behaviour Improve legacy vbios handling hw/xen/xen_pt.c | 8 +++++-- hw/xen/xen_pt_graphics.c | 48 +++++++++++++++++++++++++++++++++++++--- hw/xen/xen_pt_load_rom.c | 13 +++++------ 3 files changed, 57 insertions(+), 12 deletions(-) -- 2.26.1
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |