From: Colin King <colin.king@canonical.com>
To: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
"H . Peter Anvin" <hpa@zytor.com>,
x86@kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH][V2] x86/apic: fix integer overflow on 10 bit left shift of cpu_khz
Date: Wed, 19 Jun 2019 19:14:46 +0100 [thread overview]
Message-ID: <20190619181446.13635-1-colin.king@canonical.com> (raw)
From: Colin Ian King <colin.king@canonical.com>
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 (just
less than 4.2 GHz). Also wrap line to avoid checkpatch wide line
warning.
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>
---
arch/x86/kernel/apic/apic.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 8956072f677d..31426126e5e0 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1464,7 +1464,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) -
+ (ntsc - tsc);
} else {
max_loops--;
}
--
V2: replace right with left in commit subject and message. Doh.
--
2.20.1
next reply other threads:[~2019-06-19 18:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-19 18:14 Colin King [this message]
2019-06-20 7:59 ` Dan Carpenter
2019-06-22 10:19 ` [tip:x86/urgent] x86/apic: Fix " tip-bot for Colin Ian King
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=20190619181446.13635-1-colin.king@canonical.com \
--to=colin.king@canonical.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®