Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp4312015ybf; Wed, 4 Mar 2020 01:20:43 -0800 (PST) X-Google-Smtp-Source: ADFU+vsX4cuSPSi1MOeb90Mu1W/C7O9SnxFIJVaid+oS+bD75//D+GwO1+GCZb2yv4bwOZBLCvXy X-Received: by 2002:a9d:2028:: with SMTP id n37mr1635261ota.127.1583313642443; Wed, 04 Mar 2020 01:20:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583313642; cv=none; d=google.com; s=arc-20160816; b=Bh0brOPFX02jV2TXH9z71frH4T2EChmYNNrzdx/dSxj/Ta4yoUD9QQ9/1FBTakdXRV /JOyA/4jEU3OlkLfsz147WvmIDHOqZy4dkNS8utKcXQdb1oIxAJOW4yYYc1kO8NE55nN QmUz4Vf2qcSz7PWOgsBxZBviQuxpqhXA036rAMFMYpIVTUsWmvuih0Yw7yuSQEolrkcv wsszbQJ0+5892ysayKLXlbieXUMYqafJRkt9ib3Tf50vDIBvk/KmeVEY7NSwoU+b5XgT tBhGGORHARM3b48Dr6AyN6PGH3vn1Ii8zgRdG/+JCzINslL6tXxqr/xXEW4YqBjSx4CN X74w== 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 :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=ZtLtMj7epOXGbl5bTsIkUAYg/BxgNSEJDXEDT7rcfqM=; b=teEPyTy9Q14wtyGcocwMOY3R394uSgDCGr6ASNdKTtPj4dCxf/TtSLK1UziyB/PYLe oCWpBYFl/6Xv87utnNIFJxhe3rHTWozRQm0SN34eNUnTvR4VMqnJ1qGOfEcOLRhoM1kJ vXr+uaVXIVK2GzWJxZVHcyuFRSaap31tIBJ602v0riOk0MB9UGkgECC3QYROFHFq7cbq Why/TgM5ZGwAgW1VUutMGzLl14+9DQ2vHx6V/jbeeOYPZTw+H+qoDwyVA/YGQpI5/y2A xLENm12CBqHeMd1x6SLIBYLDN2O6XHlUCUyVPhogFZVd3/5wgLXSjnOIpF40GurKbPUh 5/qg== ARC-Authentication-Results: i=1; mx.google.com; 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 p10si847915oti.275.2020.03.04.01.20.30; Wed, 04 Mar 2020 01:20:42 -0800 (PST) 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; 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 S1729028AbgCDJUQ (ORCPT + 99 others); Wed, 4 Mar 2020 04:20:16 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:46365 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726860AbgCDJUP (ORCPT ); Wed, 4 Mar 2020 04:20:15 -0500 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1j9QCJ-0007g2-Gm; Wed, 04 Mar 2020 10:20:11 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 2EE681C20C4; Wed, 4 Mar 2020 10:20:11 +0100 (CET) Date: Wed, 04 Mar 2020 09:20:10 -0000 From: "tip-bot2 for Wen Yang" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] timekeeping: Prevent 32bit truncation in scale64_check_overflow() Cc: Wen Yang , Thomas Gleixner , x86 , LKML In-Reply-To: <20200120100523.45656-1-wenyang@linux.alibaba.com> References: <20200120100523.45656-1-wenyang@linux.alibaba.com> MIME-Version: 1.0 Message-ID: <158331361093.28353.8221399414721139924.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the timers/core branch of tip: Commit-ID: 4cbbc3a0eeed675449b1a4d080008927121f3da3 Gitweb: https://git.kernel.org/tip/4cbbc3a0eeed675449b1a4d080008927121f3da3 Author: Wen Yang AuthorDate: Mon, 20 Jan 2020 18:05:23 +08:00 Committer: Thomas Gleixner CommitterDate: Wed, 04 Mar 2020 10:17:51 +01:00 timekeeping: Prevent 32bit truncation in scale64_check_overflow() While unlikely the divisor in scale64_check_overflow() could be >= 32bit in scale64_check_overflow(). do_div() truncates the divisor to 32bit at least on 32bit platforms. Use div64_u64() instead to avoid the truncation to 32-bit. [ tglx: Massaged changelog ] Signed-off-by: Wen Yang Signed-off-by: Thomas Gleixner Link: https://lkml.kernel.org/r/20200120100523.45656-1-wenyang@linux.alibaba.com --- kernel/time/timekeeping.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index ca69290..4fc2af4 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1005,9 +1005,8 @@ static int scale64_check_overflow(u64 mult, u64 div, u64 *base) ((int)sizeof(u64)*8 - fls64(mult) < fls64(rem))) return -EOVERFLOW; tmp *= mult; - rem *= mult; - do_div(rem, div); + rem = div64_u64(rem * mult, div); *base = tmp + rem; return 0; }