lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Mon, 20 Jan 2020 18:05:23 +0800 From: Wen Yang <wenyang@...ux.alibaba.com> To: John Stultz <john.stultz@...aro.org>, Thomas Gleixner <tglx@...utronix.de> Cc: Wen Yang <wenyang@...ux.alibaba.com>, Stephen Boyd <sboyd@...nel.org>, linux-kernel@...r.kernel.org Subject: [PATCH] timekeeping: improve arithmetic division in scale64_check_overflow() do_div() does a 64-by-32 division. Use div64_u64() instead of it if the divisor is u64, to avoid truncation to 32-bit. And as a nice side effect also cleans up the function a bit. Signed-off-by: Wen Yang <wenyang@...ux.alibaba.com> Cc: John Stultz <john.stultz@...aro.org> Cc: Thomas Gleixner <tglx@...utronix.de> Cc: Stephen Boyd <sboyd@...nel.org> Cc: linux-kernel@...r.kernel.org --- 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 ca69290bee2a..4fc2af4367a7 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; } -- 2.23.0
Powered by blists - more mailing lists