diff options
author | Colin Ian King <colin.king@canonical.com> | 2019-06-19 19:14:46 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-07-21 09:03:06 +0200 |
commit | 2a6ee36917f02682e387d3e127af06bcb4a66aad (patch) | |
tree | 4b261b94bab625dd582fd2aba23ec30ed55b4597 /arch | |
parent | fdfff855cd3633680d26872771d10aeab0b7f340 (diff) | |
download | linux-stable-2a6ee36917f02682e387d3e127af06bcb4a66aad.tar.gz linux-stable-2a6ee36917f02682e387d3e127af06bcb4a66aad.tar.bz2 linux-stable-2a6ee36917f02682e387d3e127af06bcb4a66aad.zip |
x86/apic: Fix integer overflow on 10 bit left shift of cpu_khz
[ Upstream commit ea136a112d89bade596314a1ae49f748902f4727 ]
The left shift of unsigned int cpu_khz will overflow for large values of
cpu_khz, so cast it to a long long before shifting it to avoid overvlow.
For example, this can happen when cpu_khz is 4194305, i.e. ~4.2 GHz.
Addresses-Coverity: ("Unintentional integer overflow")
Fixes: 8c3ba8d04924 ("x86, apic: ack all pending irqs when crashed/on kexec")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H . Peter Anvin" <hpa@zytor.com>
Cc: kernel-janitors@vger.kernel.org
Link: https://lkml.kernel.org/r/20190619181446.13635-1-colin.king@canonical.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kernel/apic/apic.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index 84132eddb5a8..2646234380cc 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -1452,7 +1452,8 @@ static void apic_pending_intr_clear(void) if (queued) { if (boot_cpu_has(X86_FEATURE_TSC) && cpu_khz) { ntsc = rdtsc(); - max_loops = (cpu_khz << 10) - (ntsc - tsc); + max_loops = (long long)cpu_khz << 10; + max_loops -= ntsc - tsc; } else { max_loops--; } |