Skip to content

Commit efc95f2

Browse files
tasksetgregkh
authored andcommitted
timekeeping: Prevent 32bit truncation in scale64_check_overflow()
[ Upstream commit 4cbbc3a ] 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>
1 parent 202e2ff commit efc95f2

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

kernel/time/timekeeping.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,9 +1005,8 @@ static int scale64_check_overflow(u64 mult, u64 div, u64 *base)
10051005
((int)sizeof(u64)*8 - fls64(mult) < fls64(rem)))
10061006
return -EOVERFLOW;
10071007
tmp *= mult;
1008-
rem *= mult;
10091008

1010-
do_div(rem, div);
1009+
rem = div64_u64(rem * mult, div);
10111010
*base = tmp + rem;
10121011
return 0;
10131012
}

0 commit comments

Comments
 (0)