From nobody Mon Feb 9 12:10:07 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1630667274; cv=none; d=zohomail.com; s=zohoarc; b=nUmSugoAqMt2EFPWfFlXDmJx1CILnRePpw6nDLUhaEqg65p7NsGKIGiL6wkEuDjda0g09ae2Qaw/ZPmKy2kbKliR7IjXtt2FK6lvJqK3FVJ4bm/uMTTFzxvn6aUgPOuHtB5naph4w1MtEtLIqLc7NPIY5vd+pl6qr7pJlVIc4gU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630667274; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=6osDXRphDo8TIq2I2JrJLj4Iq8ymwMld3GU8FS2XmwE=; b=ZWB6SigW4xOP2Q71WY+Ut2OH2GCTlPQlDCDlV/d9VoD90vgiI9GIKYnq2U+MKU/7IYGEBhndqCAyU4OTbtnO7KcMSlW2dKsc09r6t/QKPJKfyQupt3heXysnsR9r8vIlKrQpWaDBXWpcGFplgVlqms4kbHNJVo9DLn/+/YnIowE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1630667274527874.9316137257139; Fri, 3 Sep 2021 04:07:54 -0700 (PDT) Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-182-nFFD01lDNQyUaLbjDsF3fw-1; Fri, 03 Sep 2021 07:07:52 -0400 Received: by mail-wr1-f69.google.com with SMTP id m16-20020a056000181000b0015964e4ae48so416739wrh.14 for ; Fri, 03 Sep 2021 04:07:52 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.. (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id b12sm5141598wrx.72.2021.09.03.04.07.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 04:07:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630667273; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6osDXRphDo8TIq2I2JrJLj4Iq8ymwMld3GU8FS2XmwE=; b=TkEmPXBsWJ4NulsSwSQJFuR809PslHT3DRkY6kKp5TG0W1CpMaixflAxVxThJYhcL03Ktw O6BFFWEQi/G9nxcLo08kvNYbW8szuWXquauiXFXn20ENUmsF92rjzFgLe2WoIn8XwghMwL 7k80mBXvWZ76y191Gw+mAIWkTvjMcMM= X-MC-Unique: nFFD01lDNQyUaLbjDsF3fw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6osDXRphDo8TIq2I2JrJLj4Iq8ymwMld3GU8FS2XmwE=; b=ukkswlHzzlMGEIJyFb6cG+fvoXjTdIKjqoZizXl8KRZVGSv/8X7GMCWM24hs7BgnHJ R/UynIfdo5fuvaLLmsCm5y8tb7ZcstH/LDX+NaikyTs92y+6+ONwkM7rFACzoisrY+zJ 4AGNmWSaE30muiPj6x8QKPL5efbhwkWTwtSJkRWSC3C5sQs+29po7XpfZwj0BCVuHQuh //7dkkUjJJjZNb7YyTn8/lh/cySHQtgpmcfM7Mefonl8HAITRQLvTtOkx7DPXK1dWiCs 5x+83ldDtKCVgwbrdASQd0DYjQDEHOnipR/H23ZhuwkespebtGEd2FsCp/lC+4AP2jYy 4fQg== X-Gm-Message-State: AOAM5325Toqt75VE2POWkZuxUmQbXyoUvupHTZaTpplOFNW1vuvjDorw ybAA7DKIfDZvm0qdwMrhAET8n0gDg//LzwbR/JskRNkTwq5NM1lOBfQykBUZVUI0c5q1qewW4Mc 7pkDgEwmrD/wuzg== X-Received: by 2002:a5d:526a:: with SMTP id l10mr3307813wrc.279.1630667271412; Fri, 03 Sep 2021 04:07:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcJFg+fUtt74cezEjGtPfJjbB/p8oBH6n6a0g8f/lUmZ5V9PLYMGF1/ZME4j9YjZI6HscUjA== X-Received: by 2002:a5d:526a:: with SMTP id l10mr3307771wrc.279.1630667271215; Fri, 03 Sep 2021 04:07:51 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Hanna Reitz , Igor Mammedov , Laurent Vivier , Alexandre Iooss , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Michael Roth , Zhang Chen , Shannon Zhao , Richard Henderson , Alex Williamson , Eduardo Habkost , Markus Armbruster , Eric Blake , Stefan Weil , John Snow , Mahmoud Mandour , Li Zhijian , Marcel Apfelbaum , qemu-block@nongnu.org, Helge Deller , "Michael S. Tsirkin" , David Gibson , Peter Xu , "Gonglei (Arei)" , Gerd Hoffmann , Fam Zheng , Jason Wang , Vladimir Sementsov-Ogievskiy , Christian Schoenebeck , Kevin Wolf , Yuval Shaia , Paolo Bonzini , Peter Maydell , qemu-arm@nongnu.org, Thomas Huth , Laurent Vivier , Greg Kurz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, David Hildenbrand Subject: [PATCH 08/28] hw/acpi: Avoid truncating acpi_data_len() to 32-bit Date: Fri, 3 Sep 2021 13:06:42 +0200 Message-Id: <20210903110702.588291-9-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210903110702.588291-1-philmd@redhat.com> References: <20210903110702.588291-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630667275489100001 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=C3=A9 Acked-by: Igor Mammedov --- 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, AcpiBuildTa= bles *tables) =20 static void acpi_ram_update(MemoryRegion *mr, GArray *data) { - uint32_t size =3D acpi_data_len(data); + unsigned size =3D acpi_data_len(data); =20 /* 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) =20 static void acpi_ram_update(MemoryRegion *mr, GArray *data) { - uint32_t size =3D acpi_data_len(data); + unsigned size =3D acpi_data_len(data); =20 /* Make sure RAM size is correct - in case it got changed e.g. by migr= ation */ 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 =3D acpi_data_len(tables.rsdp); + unsigned rsdp_size =3D acpi_data_len(tables.rsdp); =20 build_state->rsdp =3D g_memdup(tables.rsdp->data, rsdp_size); fw_cfg_add_file_callback(x86ms->fw_cfg, ACPI_BUILD_RSDP_FILE, --=20 2.31.1