[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 33/38] kvmvapic: Catch invalid ROM size
From: |
Michael Roth |
Subject: |
[Qemu-stable] [PATCH 33/38] kvmvapic: Catch invalid ROM size |
Date: |
Wed, 25 Sep 2013 07:58:01 -0500 |
From: Jan Kiszka <address@hidden>
If not caught early, a zero-length ROM will cause a NULL-pointer access
later on in patch_hypercalls when allocating a zero-length ROM copy and
trying to read from it.
CC: address@hidden
Signed-off-by: Jan Kiszka <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
(cherry picked from commit 18e5eec4db96a00907eb588a2b803401637c7f67)
Signed-off-by: Michael Roth <address@hidden>
---
hw/i386/kvmvapic.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c
index 15beb80..7ac0fe1 100644
--- a/hw/i386/kvmvapic.c
+++ b/hw/i386/kvmvapic.c
@@ -578,7 +578,7 @@ static int patch_hypercalls(VAPICROMState *s)
* enable write access to the option ROM so that variables can be updated by
* the guest.
*/
-static void vapic_map_rom_writable(VAPICROMState *s)
+static int vapic_map_rom_writable(VAPICROMState *s)
{
hwaddr rom_paddr = s->rom_state_paddr & ROM_BLOCK_MASK;
MemoryRegionSection section;
@@ -599,6 +599,9 @@ static void vapic_map_rom_writable(VAPICROMState *s)
/* read ROM size from RAM region */
ram = memory_region_get_ram_ptr(section.mr);
rom_size = ram[rom_paddr + 2] * ROM_BLOCK_SIZE;
+ if (rom_size == 0) {
+ return -1;
+ }
s->rom_size = rom_size;
/* We need to round to avoid creating subpages
@@ -612,11 +615,15 @@ static void vapic_map_rom_writable(VAPICROMState *s)
memory_region_add_subregion_overlap(as, rom_paddr, &s->rom, 1000);
s->rom_mapped_writable = true;
memory_region_unref(section.mr);
+
+ return 0;
}
static int vapic_prepare(VAPICROMState *s)
{
- vapic_map_rom_writable(s);
+ if (vapic_map_rom_writable(s) < 0) {
+ return -1;
+ }
if (patch_hypercalls(s) < 0) {
return -1;
--
1.7.9.5
- [Qemu-stable] [PATCH 23/38] Revert "memory: Return -1 again on reads from unsigned regions", (continued)
- [Qemu-stable] [PATCH 23/38] Revert "memory: Return -1 again on reads from unsigned regions", Michael Roth, 2013/09/25
- [Qemu-stable] [PATCH 24/38] exec: check offset_within_address_space for register subpage, Michael Roth, 2013/09/25
- [Qemu-stable] [PATCH 22/38] memory: Provide separate handling of unassigned io ports accesses, Michael Roth, 2013/09/25
- [Qemu-stable] [PATCH 28/38] pc: Initializing ram_memory under Xen., Michael Roth, 2013/09/25
- [Qemu-stable] [PATCH 25/38] ne2000: mark I/O as LITTLE_ENDIAN, Michael Roth, 2013/09/25
- [Qemu-stable] [PATCH 31/38] pcnet-pci: mark I/O and MMIO as LITTLE_ENDIAN, Michael Roth, 2013/09/25
- [Qemu-stable] [PATCH 30/38] qapi-types.py: Fix enum struct sizes on i686, Michael Roth, 2013/09/25
- [Qemu-stable] [PATCH 36/38] tci: Fix qemu-alpha on 32 bit hosts (wrong assertions), Michael Roth, 2013/09/25
- [Qemu-stable] [PATCH 34/38] kvmvapic: Enter inactive state on hardware reset, Michael Roth, 2013/09/25
- [Qemu-stable] [PATCH 29/38] pc_q35: Initialize Xen., Michael Roth, 2013/09/25
- [Qemu-stable] [PATCH 33/38] kvmvapic: Catch invalid ROM size,
Michael Roth <=
- [Qemu-stable] [PATCH 35/38] kvmvapic: Clear also physical ROM address when entering INACTIVE state, Michael Roth, 2013/09/25
- [Qemu-stable] [PATCH 32/38] chardev: fix pty_chr_timer, Michael Roth, 2013/09/25
- [Qemu-stable] [PATCH 38/38] virtio-blk: do not relay a previous driver's WCE configuration to the current, Michael Roth, 2013/09/25
- [Qemu-stable] [PATCH 37/38] blockdev: do not default cache.no-flush to true, Michael Roth, 2013/09/25
- [Qemu-stable] [PATCH 26/38] ehci: save device pointer in EHCIState, Michael Roth, 2013/09/25
- [Qemu-stable] [PATCH 27/38] qxl: fix local renderer, Michael Roth, 2013/09/25
- Re: [Qemu-stable] Patch Round-up for stable 1.6.1, freeze on 2013-09-30, Cole Robinson, 2013/09/25
- Re: [Qemu-stable] [Qemu-devel] Patch Round-up for stable 1.6.1, freeze on 2013-09-30, Stefan Weil, 2013/09/26