Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1705006ybi; Wed, 17 Jul 2019 20:27:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCtFweM3uyYwlXJ6UJpEMcomRblLJM3y5LbowR2UCKWk7m1Y+EVFED4V1rf2XG85fHYxCt X-Received: by 2002:a17:902:28:: with SMTP id 37mr44007747pla.188.1563420459403; Wed, 17 Jul 2019 20:27:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563420459; cv=none; d=google.com; s=arc-20160816; b=gAdWXrNoDhfY7qk0JNP3JKmejfzWt15tiv5HowVcKamUfyKY86MJ4wwQbfX4GblQjx s3KaQwek5e20eOuunRGfKne1FH+y2SNjA2XmD4hckglrFdzksMHFiMv0lis9MYdEJmR+ SR6NFQZdheO57vSHXGHBFolgckkYb31wgdeMHLdY3OeayGvVRBRb18ZzGsyR6PrD3fUl CzboHVZZXCBrjvl0R9e8mqf9YyZLIfYaSgNu8oVDTCmTxJgCz0vfvDrTHEvltfK4ITJX ur2s0dkeobOQLLPMBF3w63LhNxDP/DuqnkS/5LPHX7rL0NGsd5EKLFnPtDQoO39yJApC Ph8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=z5o/P2KzvqTmygktzR41E/gla+VTfBIToABYPcnu/mQ=; b=00+07bSWiAK9LZ1zXxsLARWea+9ZldREgG3zUfFtYz5L2wJRRM162HR+mXBeldI59i 3WNGwmmLD2Y4zBTON5OA4MRGysIevGn3B0Qmpp4CmBM7L3yCIBhqnW1TlqeLXhtl9OYI mORMAZrxrJj94HIJ+8RVIUCeSfTCGPAXnWVeEds2F7Z5imLmixYa9QxhN6Y+7HM29hHj 5/dIrQEP0NUKXTaivG5QCovFUkKkAmFxNvMpXuAWy4gOjCgTPt33vmfXVutZtTdRyFTL VLCqNM5if2WymxEzcQ35kHAF+tk2ATc/5zZS4uAo/Aap4wVWBs5ep+MZH12OTzBMkSOK 7Bjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JHa9+uWh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p12si24165967plq.331.2019.07.17.20.27.23; Wed, 17 Jul 2019 20:27:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JHa9+uWh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390091AbfGRDFz (ORCPT + 99 others); Wed, 17 Jul 2019 23:05:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:36992 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390076AbfGRDFv (ORCPT ); Wed, 17 Jul 2019 23:05:51 -0400 Received: from localhost (115.42.148.210.bf.2iij.net [210.148.42.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5E97A204EC; Thu, 18 Jul 2019 03:05:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563419150; bh=ll71j7Z6eqb6ZtBhw+Rmj5cmjVRWfbFb2Cv8/1M6umE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JHa9+uWhWCWI37ZVO+FYLDdp6uNGD9GC6iE9pQXPskQKiKRkyiSrwARmHsyEqtOd0 VXjfXz76e6B8/kryTQzndRX3C3E53rNDsGREslc7FqsUFIYUjoh+K3Hd0K1kcf3Gew gQTLadjWfIE1VKk3jpFC2dZfdcubsFX39yF649Xk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Thomas Gleixner , Borislav Petkov , "H . Peter Anvin" , kernel-janitors@vger.kernel.org, Sasha Levin Subject: [PATCH 5.1 20/54] x86/apic: Fix integer overflow on 10 bit left shift of cpu_khz Date: Thu, 18 Jul 2019 12:01:15 +0900 Message-Id: <20190718030054.951661808@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190718030053.287374640@linuxfoundation.org> References: <20190718030053.287374640@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ 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 Signed-off-by: Thomas Gleixner Cc: Borislav Petkov Cc: "H . Peter Anvin" Cc: kernel-janitors@vger.kernel.org Link: https://lkml.kernel.org/r/20190619181446.13635-1-colin.king@canonical.com Signed-off-by: Sasha Levin --- 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 b7bcdd781651..ec6225cb94f9 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -1458,7 +1458,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--; } -- 2.20.1