From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0whg-0000Kr-Li for qemu-devel@nongnu.org; Mon, 23 Nov 2015 14:23:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a0whd-0001JJ-HT for qemu-devel@nongnu.org; Mon, 23 Nov 2015 14:23:08 -0500 References: <1447939973-5147-1-git-send-email-mst@redhat.com> From: John Snow Message-ID: <56536797.8040002@redhat.com> Date: Mon, 23 Nov 2015 14:23:03 -0500 MIME-Version: 1.0 In-Reply-To: <1447939973-5147-1-git-send-email-mst@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] acpi: fix buffer overrun on migration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" , qemu-devel@nongnu.org Cc: Igor Mammedov , "Dr. David Alan Gilbert" , qemu-stable@nongnu.org On 11/19/2015 08:35 AM, Michael S. Tsirkin wrote: > ich calls acpi_gpe_init with length ICH9_PMIO_GPE0_LEN so > ICH9_PMIO_GPE0_LEN/2 bytes are allocated, but then the full > ICH9_PMIO_GPE0_LEN bytes are migrated. > > As a quick work-around, allocate twice the memory. > We'll probably want to tweak code to avoid > migrating the extra ICH9_PMIO_GPE0_LEN/2 bytes, > but that is a bit trickier to do without breaking > migration compatibility. > > Tested-by: "Dr. David Alan Gilbert" > Reported-by: "Dr. David Alan Gilbert" > Cc: qemu-stable@nongnu.org > Signed-off-by: Michael S. Tsirkin > --- > hw/acpi/core.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/hw/acpi/core.c b/hw/acpi/core.c > index fe6215a..21e113d 100644 > --- a/hw/acpi/core.c > +++ b/hw/acpi/core.c > @@ -625,8 +625,12 @@ void acpi_pm1_cnt_reset(ACPIREGS *ar) > void acpi_gpe_init(ACPIREGS *ar, uint8_t len) > { > ar->gpe.len = len; > - ar->gpe.sts = g_malloc0(len / 2); > - ar->gpe.en = g_malloc0(len / 2); > + /* Only first len / 2 bytes are ever used, > + * but the caller in ich9.c migrates full len bytes. > + * TODO: fix ich9.c and drop the extra allocation. > + */ > + ar->gpe.sts = g_malloc0(len); > + ar->gpe.en = g_malloc0(len); > } > > void acpi_gpe_reset(ACPIREGS *ar) > Reviewed-by: John Snow