linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ACPI: GTDT: Tighten the check for the first platform timer entry
@ 2024-10-10 14:47 Zheng Zengkai
  2024-10-10 15:52 ` Marc Zyngier
  0 siblings, 1 reply; 3+ messages in thread
From: Zheng Zengkai @ 2024-10-10 14:47 UTC (permalink / raw)
  To: lpieralisi, guohanjun, sudeep.holla, mark.rutland, maz, rafael,
	lenb
  Cc: daniel.lezcano, tglx, linux-acpi, linux-arm-kernel, linux-kernel,
	zhengzengkai

As suggested by Marc and Lorenzo, first we need to check whether
the platform_timer pointer is within gtdt bounds (< gtdt_end) before
de-referencing what it points at to detect the (first) platform
timer entry length and check that next platform_timer pointer is
within gtdt_end too. Now we do that only in next_platform_timer()
for subsequent platform timers.

So add check against table length (gtdt_end) for the first platform
timer entry.

Suggested-by: Marc Zyngier <maz@kernel.org>
Suggested-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com>
---
 drivers/acpi/arm64/gtdt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/arm64/gtdt.c b/drivers/acpi/arm64/gtdt.c
index c0e77c1c8e09..f249af1ed1cd 100644
--- a/drivers/acpi/arm64/gtdt.c
+++ b/drivers/acpi/arm64/gtdt.c
@@ -177,7 +177,8 @@ int __init acpi_gtdt_init(struct acpi_table_header *table,
 	}
 
 	platform_timer = (void *)gtdt + gtdt->platform_timer_offset;
-	if (platform_timer < (void *)table + sizeof(struct acpi_table_gtdt)) {
+	if (platform_timer < (void *)table + sizeof(struct acpi_table_gtdt) ||
+			platform_timer >= acpi_gtdt_desc.gtdt_end) {
 		pr_err(FW_BUG "invalid timer data.\n");
 		return -EINVAL;
 	}
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-12  8:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-10 14:47 [PATCH] ACPI: GTDT: Tighten the check for the first platform timer entry Zheng Zengkai
2024-10-10 15:52 ` Marc Zyngier
2024-10-12  8:14   ` Zheng Zengkai

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).