projects
/
wrapfs-5.3.y.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
df7c233
)
timekeeping: Prevent 32bit truncation in scale64_check_overflow()
author
Wen Yang
<wenyang@linux.alibaba.com>
Mon, 20 Jan 2020 10:05:23 +0000
(18:05 +0800)
committer
Greg Kroah-Hartman
<gregkh@linuxfoundation.org>
Thu, 1 Oct 2020 11:12:36 +0000
(13:12 +0200)
[ 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>
kernel/time/timekeeping.c
patch
|
blob
|
history
diff --git
a/kernel/time/timekeeping.c
b/kernel/time/timekeeping.c
index 1ce7c404d0b03556f71bcef3c3acd0148c7d3ef8..5b6f815a74ee3aff720479a888e08730bc966a42 100644
(file)
--- a/
kernel/time/timekeeping.c
+++ b/
kernel/time/timekeeping.c
@@
-988,9
+988,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;
}