Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp878995pxk; Thu, 17 Sep 2020 20:08:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxT+KU3vS/FoWGF/DjfVKNMO8esd0JZMgOW95mn9fJjNH2ChTuKO5luZ2yKcgW8xP8LvVTo X-Received: by 2002:a17:906:c0c4:: with SMTP id bn4mr25718756ejb.27.1600398516184; Thu, 17 Sep 2020 20:08:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600398516; cv=none; d=google.com; s=arc-20160816; b=f3LmbG5X55P0P913K4fpqHp9hKSnqhr8CX0e3pM6t+w2TWuDWustjV/ogW8pd5SHM4 Cd706TXG+kqKUrGkKOupSggiu7OthsevUiws7HD9rqUGy5lxeu1TpOc2i/0JwKSGPBH7 TJ2NV5uU4zzC5qzfzo22W1xRvTwozdfrU7wzp4P0bE79fvwH9USriy94bZ4gmuZ5cU8I 35pGHW92596VmWu65OMQq5+wkwb/UFtYBYgzhpG0xP7ARzmByNfjET11B4RRoYwH9wrR ES9oCvFlkyHgd2r3ibzPrDTX0Ac4qZvfrJa4iLYj4F7XP+LFD5BYtAOED31e3Jo/lnic C3fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rXul63R8vU+RKZTZNYiU+WUCczqIPpCvnN5u7VtOW/Y=; b=sdX8ZhIcQYQdPiQ1uPN3buPYRJQH6AC9J1ke/T4lqPkFDInMuxHQlu8M5vzeyOlkDc 56U5UJZmJsU+olHvymD+p7WZAQSoyqSvK1b7E6Pmo1O9tkE5ANJ7Jw7KHMIg+1ebY1U1 2wlzcuAQTacTe/TJl8xYa7LZsR17GIpOMnWBbhzbIbl+2nCmedQwyEjbwyTq3ahIf0FV rkK2D6yXoWqC+1MJbqr7kBmzll4tcHNGKYzXya6Vh5a+UHvDs8i/OONzpB2EjyXIffHo w+a7y267S0qFowvLO9F7ZovCq2FGoIavsgasrgeDtcQOWL+4qouKMc4SGSErDybmMYkd s1AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=U9Mlh8Wf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n12si1146980edv.103.2020.09.17.20.08.12; Thu, 17 Sep 2020 20:08:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=U9Mlh8Wf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729385AbgIRDF6 (ORCPT + 99 others); Thu, 17 Sep 2020 23:05:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:51532 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727263AbgIRCES (ORCPT ); Thu, 17 Sep 2020 22:04:18 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 71D4723788; Fri, 18 Sep 2020 02:04:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394656; bh=BrIFdQk10NoUb6X1ATgRqNtGNFzWLv/ksH9Kyx983J4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U9Mlh8WftGesF/Ez45cDL8grZfZIhmJVAR2ZunOwpSwrBjnq0N5XmyLeEyuTBl6v5 dDENmuzBcxBPSb6W3XLwzb41ke4z0z75z1syhwL19kmFipuojqH6GI0T166WDLPqGS Fs7SP5Rm5JjiFhLCPpL7+AUGr8ATy9fCv6AMKbIg= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Wen Yang , Thomas Gleixner , Sasha Levin Subject: [PATCH AUTOSEL 5.4 152/330] timekeeping: Prevent 32bit truncation in scale64_check_overflow() Date: Thu, 17 Sep 2020 21:58:12 -0400 Message-Id: <20200918020110.2063155-152-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 ca69290bee2a3..4fc2af4367a7b 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; } -- 2.25.1