* [PATCH] arm64: topology: fix possible overflow in amu_fie_setup()
@ 2022-09-16 20:17 Sergey Shtylyov
2022-09-22 12:45 ` Will Deacon
0 siblings, 1 reply; 2+ messages in thread
From: Sergey Shtylyov @ 2022-09-16 20:17 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon, linux-arm-kernel; +Cc: lvc-project
cpufreq_get_hw_max_freq() returns max frequency in kHz as *unsigned int*,
while freq_inv_set_max_ratio() gets passed this frequency in Hz as 'u64'.
Multiplying max frequency by 1000 can potentially result in overflow --
multiplying by 1000ULL instead should avoid that...
Found by Linux Verification Center (linuxtesting.org) with the SVACE static
analysis tool.
Fixes: cd0ed03a8903 ("arm64: use activity monitors for frequency invariance")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
The patch is against the 'for-next/fixes' branch of the ARM64 repo...
arch/arm64/kernel/topology.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux/arch/arm64/kernel/topology.c
===================================================================
--- linux.orig/arch/arm64/kernel/topology.c
+++ linux/arch/arm64/kernel/topology.c
@@ -237,7 +237,7 @@ static void amu_fie_setup(const struct c
for_each_cpu(cpu, cpus) {
if (!freq_counters_valid(cpu) ||
freq_inv_set_max_ratio(cpu,
- cpufreq_get_hw_max_freq(cpu) * 1000,
+ cpufreq_get_hw_max_freq(cpu) * 1000ULL,
arch_timer_get_rate()))
return;
}
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] arm64: topology: fix possible overflow in amu_fie_setup()
2022-09-16 20:17 [PATCH] arm64: topology: fix possible overflow in amu_fie_setup() Sergey Shtylyov
@ 2022-09-22 12:45 ` Will Deacon
0 siblings, 0 replies; 2+ messages in thread
From: Will Deacon @ 2022-09-22 12:45 UTC (permalink / raw)
To: Sergey Shtylyov, linux-arm-kernel, Catalin Marinas
Cc: kernel-team, Will Deacon, lvc-project
On Fri, 16 Sep 2022 23:17:07 +0300, Sergey Shtylyov wrote:
> cpufreq_get_hw_max_freq() returns max frequency in kHz as *unsigned int*,
> while freq_inv_set_max_ratio() gets passed this frequency in Hz as 'u64'.
> Multiplying max frequency by 1000 can potentially result in overflow --
> multiplying by 1000ULL instead should avoid that...
>
> Found by Linux Verification Center (linuxtesting.org) with the SVACE static
> analysis tool.
>
> [...]
Applied to arm64 (for-next/fixes), thanks!
[1/1] arm64: topology: fix possible overflow in amu_fie_setup()
https://git.kernel.org/arm64/c/d4955c0ad77d
Cheers,
--
Will
https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-22 12:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-16 20:17 [PATCH] arm64: topology: fix possible overflow in amu_fie_setup() Sergey Shtylyov
2022-09-22 12:45 ` Will Deacon
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.