* [Qemu-devel] [PATCH] acpi: fix buffer overrun on migration
@ 2015-11-19 13:35 Michael S. Tsirkin
2015-11-20 8:02 ` Igor Mammedov
2015-11-23 19:23 ` John Snow
0 siblings, 2 replies; 3+ messages in thread
From: Michael S. Tsirkin @ 2015-11-19 13:35 UTC (permalink / raw)
To: qemu-devel; +Cc: Igor Mammedov, Dr. David Alan Gilbert, qemu-stable
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" <dgilbert@redhat.com>
Reported-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
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)
--
MST
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] acpi: fix buffer overrun on migration
2015-11-19 13:35 [Qemu-devel] [PATCH] acpi: fix buffer overrun on migration Michael S. Tsirkin
@ 2015-11-20 8:02 ` Igor Mammedov
2015-11-23 19:23 ` John Snow
1 sibling, 0 replies; 3+ messages in thread
From: Igor Mammedov @ 2015-11-20 8:02 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-stable, qemu-devel, Dr. David Alan Gilbert
On Thu, 19 Nov 2015 15:35:00 +0200
"Michael S. Tsirkin" <mst@redhat.com> 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" <dgilbert@redhat.com>
> Reported-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
> ---
> 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)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] acpi: fix buffer overrun on migration
2015-11-19 13:35 [Qemu-devel] [PATCH] acpi: fix buffer overrun on migration Michael S. Tsirkin
2015-11-20 8:02 ` Igor Mammedov
@ 2015-11-23 19:23 ` John Snow
1 sibling, 0 replies; 3+ messages in thread
From: John Snow @ 2015-11-23 19:23 UTC (permalink / raw)
To: Michael S. Tsirkin, qemu-devel
Cc: Igor Mammedov, Dr. David Alan Gilbert, qemu-stable
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" <dgilbert@redhat.com>
> Reported-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> 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 <jsnow@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-11-23 19:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-19 13:35 [Qemu-devel] [PATCH] acpi: fix buffer overrun on migration Michael S. Tsirkin
2015-11-20 8:02 ` Igor Mammedov
2015-11-23 19:23 ` John Snow
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).