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
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 30 Jan 2020 21:08:51 +0800
From:   Wen Yang <wenyang@...ux.alibaba.com>
To:     Thomas Gleixner <tglx@...utronix.de>
Cc:     Wen Yang <wenyang@...ux.alibaba.com>, linux-kernel@...r.kernel.org
Subject: [PATCH] hrtimer: fix an explicit cast in __ktime_divns()

do_div() does a 64-by-32 division, while the divisor 'div' is
explicitly casted to unsigned long, thus 64-bit on 64-bit platforms.
In addition, the above lines also ensures that the divisor is less
than 2^32. Hence the proper cast type is u32.

Signed-off-by: Wen Yang <wenyang@...ux.alibaba.com>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: linux-kernel@...r.kernel.org
---
 kernel/time/hrtimer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index d8b62f93fc8d..57e543860660 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -311,7 +311,7 @@ s64 __ktime_divns(const ktime_t kt, s64 div)
 		div >>= 1;
 	}
 	tmp >>= sft;
-	do_div(tmp, (unsigned long) div);
+	do_div(tmp, (u32) div);
 	return dclc < 0 ? -tmp : tmp;
 }
 EXPORT_SYMBOL_GPL(__ktime_divns);
-- 
2.23.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ