Skip to content

Commit 61f27ba

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 e500a98 commit 61f27ba

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
@@ -950,9 +950,8 @@ static int scale64_check_overflow(u64 mult, u64 div, u64 *base)
950950
((int)sizeof(u64)*8 - fls64(mult) < fls64(rem)))
951951
return -EOVERFLOW;
952952
tmp *= mult;
953-
rem *= mult;
954953

955-
do_div(rem, div);
954+
rem = div64_u64(rem * mult, div);
956955
*base = tmp + rem;
957956
return 0;
958957
}

0 commit comments

Comments
 (0)