[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 08/28] hw/acpi: Avoid truncating acpi_data_len() to 32-bit
From: |
Igor Mammedov |
Subject: |
Re: [PATCH 08/28] hw/acpi: Avoid truncating acpi_data_len() to 32-bit |
Date: |
Wed, 8 Sep 2021 09:15:58 +0200 |
On Fri, 3 Sep 2021 13:06:42 +0200
Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
> acpi_data_len() returns an unsigned type, which might be bigger
> than 32-bit (although it is unlikely such value is returned).
> Hold the returned value in an 'unsigned' type to avoid unlikely
> size truncation.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Acked-by: Igor Mammedov <imammedo@redhat.com>
> ---
> hw/arm/virt-acpi-build.c | 2 +-
> hw/i386/acpi-build.c | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index 037cc1fd82c..95543d43e2a 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -885,7 +885,7 @@ void virt_acpi_build(VirtMachineState *vms,
> AcpiBuildTables *tables)
>
> static void acpi_ram_update(MemoryRegion *mr, GArray *data)
> {
> - uint32_t size = acpi_data_len(data);
> + unsigned size = acpi_data_len(data);
>
> /* Make sure RAM size is correct - in case it got changed
> * e.g. by migration */
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index a33ac8b91e1..aa269914b49 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -2660,7 +2660,7 @@ void acpi_build(AcpiBuildTables *tables, MachineState
> *machine)
>
> static void acpi_ram_update(MemoryRegion *mr, GArray *data)
> {
> - uint32_t size = acpi_data_len(data);
> + unsigned size = acpi_data_len(data);
>
> /* Make sure RAM size is correct - in case it got changed e.g. by
> migration */
> memory_region_ram_resize(mr, size, &error_abort);
> @@ -2783,7 +2783,7 @@ void acpi_setup(void)
> * Though RSDP is small, its contents isn't immutable, so
> * we'll update it along with the rest of tables on guest access.
> */
> - uint32_t rsdp_size = acpi_data_len(tables.rsdp);
> + unsigned rsdp_size = acpi_data_len(tables.rsdp);
>
> build_state->rsdp = g_memdup(tables.rsdp->data, rsdp_size);
> fw_cfg_add_file_callback(x86ms->fw_cfg, ACPI_BUILD_RSDP_FILE,
- Re: [PATCH 02/28] glib-compat: Introduce g_memdup2() wrapper, (continued)
- [PATCH 03/28] qapi: Replace g_memdup() by g_memdup2_qemu(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH 04/28] accel/tcg: Replace g_memdup() by g_memdup2_qemu(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH 05/28] block/qcow2-bitmap: Replace g_memdup() by g_memdup2_qemu(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH 06/28] softmmu: Replace g_memdup() by g_memdup2_qemu(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH 07/28] hw/9pfs: Replace g_memdup() by g_memdup2_qemu(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH 08/28] hw/acpi: Avoid truncating acpi_data_len() to 32-bit, Philippe Mathieu-Daudé, 2021/09/03
- Re: [PATCH 08/28] hw/acpi: Avoid truncating acpi_data_len() to 32-bit,
Igor Mammedov <=
- [PATCH 09/28] hw/acpi: Replace g_memdup() by g_memdup2_qemu(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH 10/28] hw/core/machine: Replace g_memdup() by g_memdup2_qemu(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH 11/28] hw/hppa/machine: Replace g_memdup() by g_memdup2_qemu(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH 12/28] hw/i386/multiboot: Replace g_memdup() by g_memdup2_qemu(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH 13/28] hw/net/eepro100: Replace g_memdup() by g_memdup2_qemu(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH 14/28] hw/nvram/fw_cfg: Replace g_memdup() by g_memdup2_qemu(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH 16/28] hw/ppc/spapr_pci: Replace g_memdup() by g_memdup2_qemu(), Philippe Mathieu-Daudé, 2021/09/03
- [PATCH 17/28] hw/rdma: Replace g_memdup() by g_memdup2_qemu(), Philippe Mathieu-Daudé, 2021/09/03