]> www.infradead.org Git - users/jedix/linux-maple.git/commit
ACPI: GTDT: Tighten the check for the array of platform timer structures
authorZheng Zengkai <zhengzengkai@huawei.com>
Wed, 16 Oct 2024 09:54:58 +0000 (17:54 +0800)
committerCatalin Marinas <catalin.marinas@arm.com>
Mon, 4 Nov 2024 12:51:50 +0000 (12:51 +0000)
commit263e22d6bd1f8a12dc2e770cf190f8dfb31f867e
tree8d88f04fb0df132edf6239a17cfc18ac3fcbe53f
parent525fd6a1b34ea8ce42e12db38380eed0efefb5d5
ACPI: GTDT: Tighten the check for the array of platform timer structures

As suggested by Marc and Lorenzo, first we need to check whether the
platform_timer entry pointer is within gtdt bounds (< gtdt_end) before
de-referencing what it points at to detect the length of the platform
timer struct and then check that the length of current platform_timer
struct is also valid, i.e. the length is not zero and within gtdt_end.
Now next_platform_timer() only checks against gtdt_end for the entry of
subsequent platform timer without checking the length of it and will
not report error if the check failed and the existing check in function
acpi_gtdt_init() is also not enough.

Modify the for_each_platform_timer() iterator and use it combined with
a dedicated check function platform_timer_valid() to do the check
against table length (gtdt_end) for each element of platform timer
array in function acpi_gtdt_init(), making sure that both their entry
and length actually fit in the table.

Suggested-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Co-developed-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Reviewed-by: Hanjun Guo <guohanjun@huawei.com>
Tested-by: Hanjun Guo <guohanjun@huawei.com>
Link: https://lore.kernel.org/r/20241016095458.34126-1-zhengzengkai@huawei.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
drivers/acpi/arm64/gtdt.c