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>] [day] [month] [year] [list]
Message-Id: <1433159858-5070-1-git-send-email-baolin.wang@linaro.org>
Date:	Mon,  1 Jun 2015 19:57:38 +0800
From:	Baolin Wang <baolin.wang@...aro.org>
To:	tglx@...utronix.de
Cc:	arnd@...db.de, linux-kernel@...r.kernel.org,
	baolin.wang@...aro.org, y2038@...ts.linaro.org
Subject: [PATCH v4 14/25] posix-timers:Convert to the 64bit methods for the clock_gettime syscall function

This patch introduces the clock_get64 method with timespec64 type for
k_clock structure, that makes it ready for the 2038 year.

Convert to the 64bit method with timespec64 type for the clock_gettime
syscall function, and change the clock_gettime syscall implementation.

Also add a default 64bit method for the clock_get64 pointer of k_clock
structure, and it will be removed after all the drivers are converted
to 64bit methods.

Signed-off-by: Baolin Wang <baolin.wang@...aro.org>
---
 include/linux/posix-timers.h |    1 +
 kernel/time/posix-timers.c   |   28 ++++++++++++++++++++++------
 2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 2b19ec8..be2123d 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -103,6 +103,7 @@ struct k_clock {
 	int (*clock_set64) (const clockid_t which_clock,
 			    const struct timespec64 *tp);
 	int (*clock_get) (const clockid_t which_clock, struct timespec * tp);
+	int (*clock_get64) (const clockid_t which_clock, struct timespec64 *tp);
 	int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
 	int (*timer_create) (struct k_itimer *timer);
 	int (*nsleep) (const clockid_t which_clock, int flags,
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 12affd5..9b5352a 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -582,6 +582,20 @@ static int default_clock_set64(const clockid_t which_clock,
 	return ret;
 }
 
+static int default_clock_get64(const clockid_t which_clock,
+			       struct timespec64 *tp64)
+{
+	struct k_clock *kc = clockid_to_kclock(which_clock);
+	struct timespec tp;
+	int ret;
+
+	ret = kc->clock_get(which_clock, &tp);
+	if (!ret)
+		*tp64 = timespec_to_timespec64(tp);
+
+	return ret;
+}
+
 void posix_timers_register_clock(const clockid_t clock_id,
 				 struct k_clock *new_clock)
 {
@@ -591,8 +605,8 @@ void posix_timers_register_clock(const clockid_t clock_id,
 		return;
 	}
 
-	if (!new_clock->clock_get) {
-		printk(KERN_WARNING "POSIX clock id %d lacks clock_get()\n",
+	if (!new_clock->clock_get && !new_clock->clock_get64) {
+		printk(KERN_WARNING "POSIX clock id %d lacks clock_get() and clock_get64()\n",
 		       clock_id);
 		return;
 	}
@@ -608,6 +622,8 @@ void posix_timers_register_clock(const clockid_t clock_id,
 		new_clock->timer_set64 = default_timer_set64;
 	if (new_clock->clock_set && !new_clock->clock_set64)
 		new_clock->clock_set64 = default_clock_set64;
+	if (new_clock->clock_get && !new_clock->clock_get64)
+		new_clock->clock_get64 = default_clock_get64;
 
 	posix_clocks[clock_id] = *new_clock;
 }
@@ -1117,25 +1133,25 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
 	return __clock_settime(which_clock, &new_tp);
 }
 
-static int __clock_gettime(clockid_t which_clock, struct timespec *ts)
+static int __clock_gettime(clockid_t which_clock, struct timespec64 *ts)
 {
 	struct k_clock *kc = clockid_to_kclock(which_clock);
 
 	if (!kc)
 		return -EINVAL;
 
-	return kc->clock_get(which_clock, ts);
+	return kc->clock_get64(which_clock, ts);
 }
 
 SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
 		struct timespec __user *,tp)
 {
-	struct timespec kernel_tp;
+	struct timespec64 kernel_tp;
 	int error;
 
 	error = __clock_gettime(which_clock, &kernel_tp);
 
-	if (!error && copy_to_user(tp, &kernel_tp, sizeof (kernel_tp)))
+	if (!error && put_timespec(&kernel_tp, tp))
 		error = -EFAULT;
 
 	return error;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ