1 From d9a3b33d2c9f996537b7f1d0246dee2d0120cefb Mon Sep 17 00:00:00 2001
2 From: "Michael S. Tsirkin" <mst@redhat.com>
3 Date: Thu, 19 Nov 2015 15:14:07 +0200
4 Subject: [PATCH] acpi: fix buffer overrun on migration
6 ich calls acpi_gpe_init with length ICH9_PMIO_GPE0_LEN so
7 ICH9_PMIO_GPE0_LEN/2 bytes are allocated, but then the full
8 ICH9_PMIO_GPE0_LEN bytes are migrated.
10 As a quick work-around, allocate twice the memory.
11 We'll probably want to tweak code to avoid
12 migrating the extra ICH9_PMIO_GPE0_LEN/2 bytes,
13 but that is a bit trickier to do without breaking
14 migration compatibility.
16 Tested-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
17 Reported-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
18 Cc: qemu-stable@nongnu.org
19 Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
21 hw/acpi/core.c | 8 ++++++--
22 1 file changed, 6 insertions(+), 2 deletions(-)
24 diff --git a/hw/acpi/core.c b/hw/acpi/core.c
25 index fe6215a..21e113d 100644
28 @@ -625,8 +625,12 @@ void acpi_pm1_cnt_reset(ACPIREGS *ar)
29 void acpi_gpe_init(ACPIREGS *ar, uint8_t len)
32 - ar->gpe.sts = g_malloc0(len / 2);
33 - ar->gpe.en = g_malloc0(len / 2);
34 + /* Only first len / 2 bytes are ever used,
35 + * but the caller in ich9.c migrates full len bytes.
36 + * TODO: fix ich9.c and drop the extra allocation.
38 + ar->gpe.sts = g_malloc0(len);
39 + ar->gpe.en = g_malloc0(len);
42 void acpi_gpe_reset(ACPIREGS *ar)