From: sashiko-bot@kernel.org
To: "Marc Zyngier" <maz@kernel.org>
Cc: krzk+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org,
conor+dt@kernel.org
Subject: Re: [PATCH v2 01/17] ACPI: GTDT: Account for GTDTv3 size when walking the platform timer descriptors
Date: Thu, 14 May 2026 19:54:13 +0000 [thread overview]
Message-ID: <20260514195413.C6FB0C2BCB3@smtp.kernel.org> (raw)
In-Reply-To: <20260514150945.3917510-2-maz@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Insufficient bounds checking in `platform_timer_valid()` allows reading past the end of the ACPI table.
- [High] Missing base table length validation in `acpi_gtdt_init()` allows an out-of-bounds read of the GTDT table.
--
commit 4d6d9fd7f79fd90d8c3bbeefd718d1658523dfab
Author: Marc Zyngier <maz@kernel.org>
ACPI: GTDT: Account for GTDTv3 size when walking the platform timer descriptors
This commit updates the GTDT table parsing to correctly account for the expanded
size of the base table when dealing with GTDT revision 3. It adds support for
the additional EL2 virtual timer structure when walking the platform timer
descriptors.
> diff --git a/drivers/acpi/arm64/gtdt.c b/drivers/acpi/arm64/gtdt.c
> index ffc867bac2d60..b9d9b8edf2df7 100644
> --- a/drivers/acpi/arm64/gtdt.c
> +++ b/drivers/acpi/arm64/gtdt.c
> @@ -39,8 +45,14 @@ static struct acpi_gtdt_descriptor acpi_gtdt_desc __initdata;
> static __init bool platform_timer_valid(void *platform_timer)
> {
> struct acpi_gtdt_header *gh = platform_timer;
> + void *platform_timer_begin;
> +
> + if (acpi_gtdt_desc.v3)
> + platform_timer_begin = container_of(acpi_gtdt_desc.gtdt, struct gtdt_v3, gtdt_v2) + 1;
> + else
> + platform_timer_begin = acpi_gtdt_desc.gtdt + 1;
>
> - return (platform_timer >= (void *)(acpi_gtdt_desc.gtdt + 1) &&
> + return (platform_timer >= platform_timer_begin &&
> platform_timer < acpi_gtdt_desc.gtdt_end &&
> gh->length != 0 &&
Is there an out-of-bounds read regression here where the code allows reading
past the end of the ACPI table?
The condition platform_timer < acpi_gtdt_desc.gtdt_end only ensures that at
least 1 byte remains within the mapped table limits. If a malformed table
positions platform_timer exactly 1 or 2 bytes before gtdt_end, evaluating
gh->length reads a 16-bit integer at offset 1 from platform_timer.
This causes a read of 1 to 2 bytes past gtdt_end. Should this enforce
platform_timer + sizeof(struct acpi_gtdt_header) <= acpi_gtdt_desc.gtdt_end
before dereferencing gh->length?
> platform_timer + gh->length <= acpi_gtdt_desc.gtdt_end);
> }
[ ... ]
> @@ -169,6 +181,7 @@ int __init acpi_gtdt_init(struct acpi_table_header *table,
> acpi_gtdt_desc.gtdt = gtdt;
> acpi_gtdt_desc.gtdt_end = (void *)table + table->length;
> acpi_gtdt_desc.platform_timer = NULL;
> + acpi_gtdt_desc.v3 = gtdt->header.revision >= 3 && gtdt->header.length >= sizeof(struct gtdt_v3);
Could the lack of base table length validation lead to an out-of-bounds read
regression?
While this patch adds a size check for V3 tables, it doesn't appear to verify
that the base V2 table meets the minimum length requirement
(table->length >= sizeof(struct acpi_table_gtdt)).
If firmware provides a truncated GTDT table containing only the standard
36-byte ACPI header, accessing gtdt->platform_timer_count later in this
function reads out-of-bounds memory.
> if (platform_timer_count)
> *platform_timer_count = 0;
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260514150945.3917510-1-maz@kernel.org?part=1
next prev parent reply other threads:[~2026-05-14 19:54 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-14 15:09 [PATCH v2 00/17] arm64: Use EL2 virtual timer when running VHE Marc Zyngier
2026-05-14 15:09 ` [PATCH v2 01/17] ACPI: GTDT: Account for GTDTv3 size when walking the platform timer descriptors Marc Zyngier
2026-05-14 19:54 ` sashiko-bot [this message]
2026-05-14 15:09 ` [PATCH v2 02/17] ACPI: GTDT: Parse information related to the EL2 virtual timer Marc Zyngier
2026-05-14 15:09 ` [PATCH v2 03/17] clocksource/drivers/arm_arch_timer: Default to EL2 virtual timer when running VHE Marc Zyngier
2026-05-14 21:23 ` sashiko-bot
2026-05-14 15:09 ` [PATCH v2 04/17] dt-bindings: timer: arm,arch_timer: Fix requirements for interrupt description Marc Zyngier
2026-05-14 15:09 ` [PATCH v2 05/17] arm64: dts: allwinner: Add EL2 virtual timer interrupt Marc Zyngier
2026-05-14 15:09 ` [PATCH v2 06/17] arm64: dts: amlogic: " Marc Zyngier
2026-05-14 15:09 ` [PATCH v2 07/17] arm64: dts: bst: " Marc Zyngier
2026-05-14 15:09 ` [PATCH v2 08/17] arm64: dts: exynos: " Marc Zyngier
2026-05-14 15:09 ` [PATCH v2 09/17] arm64: dts: freescale: " Marc Zyngier
2026-05-14 15:09 ` [PATCH v2 10/17] arm64: dts: intel: " Marc Zyngier
2026-05-14 15:09 ` [PATCH v2 11/17] arm64: dts: mediatek: " Marc Zyngier
2026-05-14 15:09 ` [PATCH v2 12/17] arm64: dts: nvidia: " Marc Zyngier
2026-05-14 15:09 ` [PATCH v2 13/17] arm64: dts: qcom: " Marc Zyngier
2026-05-14 15:09 ` [PATCH v2 14/17] arm64: dts: realtek: " Marc Zyngier
2026-05-14 15:09 ` [PATCH v2 15/17] arm64: dts: rockchip: " Marc Zyngier
2026-05-14 15:09 ` [PATCH v2 16/17] arm64: dts: sprd: " Marc Zyngier
2026-05-14 15:09 ` [PATCH v2 17/17] arm64: dts: xilinx: " Marc Zyngier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260514195413.C6FB0C2BCB3@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=maz@kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox