From patchwork Tue Sep 29 10:59:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 262971 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D24AEC47423 for ; Tue, 29 Sep 2020 12:30:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8BBEA2083B for ; Tue, 29 Sep 2020 12:30:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601382612; bh=wQXJfT8WA5kfeNeMHishl9gXwYueYqlkMbStvBPTDrM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=gVrocrAj/mQuTr2+FZYkmi7wWv856aqFFgsenMGiM2ECD99hy8Zg/ExlhABkXI0yx 3bDt5zhVCZT3yzKM/4gGJkVyZ6f4RMmeUA3BDuLEhZ79oUPMthREaiqkEOF36ONowV Y2Wo1ox8br6Pu5K4HNHWBLvoDlvJT/MuOPNuv7ek= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732884AbgI2M3q (ORCPT ); Tue, 29 Sep 2020 08:29:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:41880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728378AbgI2LaY (ORCPT ); Tue, 29 Sep 2020 07:30:24 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 3D4D923AC9; Tue, 29 Sep 2020 11:24:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601378672; bh=wQXJfT8WA5kfeNeMHishl9gXwYueYqlkMbStvBPTDrM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AX2UNMIDjcZkPBpw35lsfzUyeTf0tq71uu5UkwLBxtihmIA/5YeSsLYgm67V1FY4G 82CR5jaAGpkOz1FSSy7MZ+YGonpK0WiWEwHpdlJIHAJSRCv7N/tBTfvum5BgJNt57w t8Dv/r05JQKH9t0SKwf2bAOwAiwmhT+qE6yopBf4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wen Yang , Thomas Gleixner , Sasha Levin Subject: [PATCH 4.19 097/245] timekeeping: Prevent 32bit truncation in scale64_check_overflow() Date: Tue, 29 Sep 2020 12:59:08 +0200 Message-Id: <20200929105951.718285648@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929105946.978650816@linuxfoundation.org> References: <20200929105946.978650816@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Wen Yang [ Upstream commit 4cbbc3a0eeed675449b1a4d080008927121f3da3 ] 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 Signed-off-by: Sasha Levin --- 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 81ee5b83c9200..c66fd11d94bc4 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1004,9 +1004,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; }