[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190620075959.GQ28859@kadam>
Date: Thu, 20 Jun 2019 10:59:59 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: Colin King <colin.king@...onical.com>
Cc: Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
"H . Peter Anvin" <hpa@...or.com>, x86@...nel.org,
kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH][V2] x86/apic: fix integer overflow on 10 bit left shift
of cpu_khz
On Wed, Jun 19, 2019 at 07:14:46PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@...onical.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@...onical.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.
>
Uh, why are you putting the v2 explanation here instead of between the
--- cut off and the diffstat/
regards,
dan carpenter
Powered by blists - more mailing lists