diff options
author | Wen Yang <wenyang@linux.alibaba.com> | 2020-01-20 18:05:23 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-10-01 20:40:09 +0200 |
commit | 61f27ba2dd639ddbffd64ea2c975481bb386d7d2 (patch) | |
tree | 31ac52f014f37b6188a0d8f0e27e016586ae3c06 | |
parent | e500a986ebb951b6a51ff972ab1727f185b6b3eb (diff) | |
download | linux-stable-61f27ba2dd639ddbffd64ea2c975481bb386d7d2.tar.gz linux-stable-61f27ba2dd639ddbffd64ea2c975481bb386d7d2.tar.bz2 linux-stable-61f27ba2dd639ddbffd64ea2c975481bb386d7d2.zip |
timekeeping: Prevent 32bit truncation in scale64_check_overflow()
[ 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 <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
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | kernel/time/timekeeping.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index e24e1f0c5690..e21b4d8b7240 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -950,9 +950,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; } |