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]
Message-Id: <20180713150703.3156256-1-arnd@arndb.de>
Date:   Fri, 13 Jul 2018 17:06:37 +0200
From:   Arnd Bergmann <arnd@...db.de>
To:     Rob Springer <rspringer@...gle.com>,
        John Joseph <jnjoseph@...gle.com>,
        Ben Chan <benchan@...omium.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     Arnd Bergmann <arnd@...db.de>, Simon Que <sque@...omium.org>,
        devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org
Subject: [PATCH] staging: gasket remove current_kernel_time usage

A new user of the deprecated current_kernel_time() function has appeared
here. This code won't work correct during leap seconds or a concurrent
settimeofday() call, and it probably doesn't do what the author intended
even for the normal case, as it passes a timeout in nanoseconds but
reads the time using a jiffies-granularity accessor.

I'm changing it to ktime_get_ns() here, which simplifies the logic,
and uses a high-res clocksource. This is a bit slower, but that
probably doesn't matter in a busy-wait loop.

Note: it also doesn't matter in the current version, as there are no
callers of this function.

Fixes: 9a69f5087ccc ("drivers/staging: Gasket driver framework + Apex driver")
Signed-off-by: Arnd Bergmann <arnd@...db.de>
---
 drivers/staging/gasket/gasket_core.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c
index 45914ebc8f44..248c99a841a9 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -2090,19 +2090,14 @@ int gasket_wait_sync(
 	u64 timeout_ns)
 {
 	u64 reg;
-	struct timespec start_time, cur_time;
-	u64 diff_nanosec;
+	u64 start_time, diff_nanosec;
 	int count = 0;
 
 	reg = gasket_dev_read_64(gasket_dev, bar, offset);
-	start_time = current_kernel_time();
+	start_time = ktime_get_ns();
 	while ((reg & mask) != val) {
 		count++;
-		cur_time = current_kernel_time();
-		diff_nanosec = (u64)(cur_time.tv_sec - start_time.tv_sec) *
-				       1000000000LL +
-			       (u64)(cur_time.tv_nsec) -
-			       (u64)(start_time.tv_nsec);
+		diff_nanosec = ktime_get_ns() - start_time;
 		if (diff_nanosec > timeout_ns) {
 			gasket_log_error(
 				gasket_dev,
-- 
2.9.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ