Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1687759ybi; Wed, 17 Jul 2019 20:08:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqyumR0hS6rrSvwqNxqpjA8jYddiM10cbMU3Q6tfgrN7EUC0QGGNDNuVvxzpYcvdRJcT/soQ X-Received: by 2002:a17:90a:21ac:: with SMTP id q41mr49160213pjc.31.1563419339185; Wed, 17 Jul 2019 20:08:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563419339; cv=none; d=google.com; s=arc-20160816; b=nPTGbODrjbfNIjnWTYEz+c2aGb8pEmItNpJ4G+jkA8emfk3Fs64Od1ckxkisGMKGOH ZLn7xuhSgQC3SAbBaX8qFVKmGyY1t8zUgGJdEUM1Rm142OjlsISR0lc+xPhdHkKyFTvb CgwMsMrrE1xR0uqU2C6bgQtK2sD4bAi8YrINRpFrNWJp/oRCbkQBgWtHSJWSkBIm57Xx sDbnJVJKBD6pIGigmYAQ4vAAZ03gLqoxMPcUFW0AC8mqRPOAPyUZidvTfj+T8/e2drfK Wx2aIpfmAu3r/OmrNGC0NThcozVssr7VToo4Bv4h6Rg+l6W/Aip6a3LYA1GhwlUVicPG 7ZLw== 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=2/2x9GUFmrCgzNW5G9kDgBZdIjjJSUS7v9vJmXN/SfI=; b=GnjxWHw2hP9wRqx8ly64bLb/p84M3NvAyADa9kQY4pjJf049JpBkz999R7727Uw2wS muLmAI3qdUAs/jPQYI9tu8AiWAhNADjuAAdfArHojNP4RoHHTOkr+mqf2MVqe4g8PWqZ pCD0L+QHE222rmW3YVY8cF2QdBkrOpPM4oFRmXnCNo/qsaQ2mCW4ipPVWdMMRgbxELPU 0DnjQ5oBs4NQDiM7OofmlElWSHvp3fhmNAcRAGwhyDH5J8GzXRUCJDo8kcSiD6EqpLDo SmoqHfnIazESbYOLcCjO+bEZg1T+0C1EvN0WyxNYaERJM5Rwqvbuma5+6Rbh7lchskAv PzAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rFajYKcp; 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 r72si430973pjb.33.2019.07.17.20.08.43; Wed, 17 Jul 2019 20:08:59 -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=rFajYKcp; 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 S2390470AbfGRDHc (ORCPT + 99 others); Wed, 17 Jul 2019 23:07:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:39094 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390444AbfGRDH3 (ORCPT ); Wed, 17 Jul 2019 23:07:29 -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 331CC205F4; Thu, 18 Jul 2019 03:07:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563419248; bh=+aLMt1fy/uI6haRV10yA2RxZH9dLBlZq0WeY9Fm1h5Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rFajYKcpBXgImxldw7VLLOEs+tJOiNKnwec7XVR0LQA44w6qPF8p8dwtS1LiGJk46 yym7W5dfQYGloo9h07fzFufF3RnpHTa2BNWHKbiq/b7IrjLsH2wknoh1qsFBgHl1ZU 2Km3JFIRkcKcaxkXl+bls47DZx23dXfErIJ5GbOU= 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 4.19 14/47] x86/apic: Fix integer overflow on 10 bit left shift of cpu_khz Date: Thu, 18 Jul 2019 12:01:28 +0900 Message-Id: <20190718030049.850839591@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190718030045.780672747@linuxfoundation.org> References: <20190718030045.780672747@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 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--; } -- 2.20.1