From: "tip-bot2 for Wen Yang" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Wen Yang <wenyang@linux.alibaba.com>,
Thomas Gleixner <tglx@linutronix.de>, x86 <x86@kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: [tip: timers/core] timekeeping: Prevent 32bit truncation in scale64_check_overflow()
Date: Wed, 04 Mar 2020 09:20:10 -0000 [thread overview]
Message-ID: <158331361093.28353.8221399414721139924.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20200120100523.45656-1-wenyang@linux.alibaba.com>
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 <wenyang@linux.alibaba.com>
AuthorDate: Mon, 20 Jan 2020 18:05:23 +08:00
Committer: Thomas Gleixner <tglx@linutronix.de>
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 <wenyang@linux.alibaba.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
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;
}
prev parent reply other threads:[~2020-03-04 9:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-20 10:05 [PATCH] timekeeping: improve arithmetic division " Wen Yang
2020-03-04 9:20 ` tip-bot2 for Wen Yang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=158331361093.28353.8221399414721139924.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=wenyang@linux.alibaba.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®