linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] posix-timers: fix nanosleep_copyout() for CONFIG_COMPAT_32BIT_TIME
@ 2018-06-18 14:07 Arnd Bergmann
  2018-06-18 14:08 ` [PATCH 2/3] time: use ktime_get_real_seconds() in time syscall Arnd Bergmann
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Arnd Bergmann @ 2018-06-18 14:07 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: y2038, Arnd Bergmann, Ingo Molnar, Anna-Maria Gleixner,
	Deepa Dinamani, Rafael J. Wysocki, linux-kernel

Commit b5793b0d92c9 ("posix-timers: Make compat syscalls depend on
CONFIG_COMPAT_32BIT_TIME") added support for building the nanosleep
compat system call on 32-bit architectures, but missed one change
in nanosleep_copyout(), which would trigger a BUG() as soon as we
switch any architecture over to use it.

This makes sure the TT_COMPAT handler is available when we need it.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 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 055a4a728c00..3e93c54bd3a1 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1659,7 +1659,7 @@ EXPORT_SYMBOL_GPL(hrtimer_init_sleeper);
 int nanosleep_copyout(struct restart_block *restart, struct timespec64 *ts)
 {
 	switch(restart->nanosleep.type) {
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_COMPAT_32BIT_TIME
 	case TT_COMPAT:
 		if (compat_put_timespec64(ts, restart->nanosleep.compat_rmtp))
 			return -EFAULT;
-- 
2.9.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] time: use ktime_get_real_seconds() in time syscall
  2018-06-18 14:07 [PATCH 1/3] posix-timers: fix nanosleep_copyout() for CONFIG_COMPAT_32BIT_TIME Arnd Bergmann
@ 2018-06-18 14:08 ` Arnd Bergmann
  2018-06-19  8:00   ` [tip:timers/core] time: Use " tip-bot for Arnd Bergmann
  2018-06-18 14:08 ` [PATCH 3/3] timekeeping: use ktime_get_real_ts64() instead of getnstimeofday64() Arnd Bergmann
  2018-06-19  7:27 ` [tip:timers/urgent] posix-timers: Fix nanosleep_copyout() for CONFIG_COMPAT_32BIT_TIME tip-bot for Arnd Bergmann
  2 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2018-06-18 14:08 UTC (permalink / raw)
  To: Thomas Gleixner, John Stultz
  Cc: y2038, Arnd Bergmann, Stephen Boyd, Deepa Dinamani, Al Viro,
	linux-kernel

Both get_seconds() and do_gettimeofday() are deprecated. Let's
change the time() implementation to use the replacement function
instead.

Obviously the system call will still overflow in 2038, but this
gets us closer to removing the old helper functions.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 kernel/time/time.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/kernel/time/time.c b/kernel/time/time.c
index 8e4f3fd2f84b..90867ece5c09 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -63,7 +63,7 @@ EXPORT_SYMBOL(sys_tz);
  */
 SYSCALL_DEFINE1(time, time_t __user *, tloc)
 {
-	time_t i = get_seconds();
+	time_t i = (time_t)ktime_get_real_seconds();
 
 	if (tloc) {
 		if (put_user(i,tloc))
@@ -106,11 +106,9 @@ SYSCALL_DEFINE1(stime, time_t __user *, tptr)
 /* compat_time_t is a 32 bit "long" and needs to get converted. */
 COMPAT_SYSCALL_DEFINE1(time, compat_time_t __user *, tloc)
 {
-	struct timeval tv;
 	compat_time_t i;
 
-	do_gettimeofday(&tv);
-	i = tv.tv_sec;
+	i = (compat_time_t)ktime_get_real_seconds();
 
 	if (tloc) {
 		if (put_user(i,tloc))
-- 
2.9.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] timekeeping: use ktime_get_real_ts64() instead of getnstimeofday64()
  2018-06-18 14:07 [PATCH 1/3] posix-timers: fix nanosleep_copyout() for CONFIG_COMPAT_32BIT_TIME Arnd Bergmann
  2018-06-18 14:08 ` [PATCH 2/3] time: use ktime_get_real_seconds() in time syscall Arnd Bergmann
@ 2018-06-18 14:08 ` Arnd Bergmann
  2018-06-19  8:01   ` [tip:timers/core] timekeeping: Use " tip-bot for Arnd Bergmann
  2018-06-19  7:27 ` [tip:timers/urgent] posix-timers: Fix nanosleep_copyout() for CONFIG_COMPAT_32BIT_TIME tip-bot for Arnd Bergmann
  2 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2018-06-18 14:08 UTC (permalink / raw)
  To: Thomas Gleixner, John Stultz
  Cc: y2038, Arnd Bergmann, Stephen Boyd, Ingo Molnar,
	Miroslav Lichvar, linux-kernel

The two do the same, this moves all users to the newer name for consistency.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 kernel/time/ntp.c         | 6 +++---
 kernel/time/timekeeping.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index a09ded765f6c..10a79053e82f 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -502,7 +502,7 @@ static void sched_sync_hw_clock(struct timespec64 now,
 {
 	struct timespec64 next;
 
-	getnstimeofday64(&next);
+	ktime_get_real_ts64(&next);
 	if (!fail)
 		next.tv_sec = 659;
 	else {
@@ -537,7 +537,7 @@ static void sync_rtc_clock(void)
 	if (!IS_ENABLED(CONFIG_RTC_SYSTOHC))
 		return;
 
-	getnstimeofday64(&now);
+	ktime_get_real_ts64(&now);
 
 	adjust = now;
 	if (persistent_clock_is_local)
@@ -591,7 +591,7 @@ static bool sync_cmos_clock(void)
 	 * Architectures are strongly encouraged to use rtclib and not
 	 * implement this legacy API.
 	 */
-	getnstimeofday64(&now);
+	ktime_get_real_ts64(&now);
 	if (rtc_tv_nsec_ok(-1 * target_nsec, &adjust, &now)) {
 		if (persistent_clock_is_local)
 			adjust.tv_sec -= (sys_tz.tz_minuteswest * 60);
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 4786df904c22..77c436a0070b 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -2310,7 +2310,7 @@ int do_adjtimex(struct timex *txc)
 			return ret;
 	}
 
-	getnstimeofday64(&ts);
+	ktime_get_real_ts64(&ts);
 
 	raw_spin_lock_irqsave(&timekeeper_lock, flags);
 	write_seqcount_begin(&tk_core.seq);
-- 
2.9.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [tip:timers/urgent] posix-timers: Fix nanosleep_copyout() for CONFIG_COMPAT_32BIT_TIME
  2018-06-18 14:07 [PATCH 1/3] posix-timers: fix nanosleep_copyout() for CONFIG_COMPAT_32BIT_TIME Arnd Bergmann
  2018-06-18 14:08 ` [PATCH 2/3] time: use ktime_get_real_seconds() in time syscall Arnd Bergmann
  2018-06-18 14:08 ` [PATCH 3/3] timekeeping: use ktime_get_real_ts64() instead of getnstimeofday64() Arnd Bergmann
@ 2018-06-19  7:27 ` tip-bot for Arnd Bergmann
  2 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Arnd Bergmann @ 2018-06-19  7:27 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, rafael.j.wysocki, arnd, deepa.kernel, hpa, anna-maria,
	linux-kernel, tglx

Commit-ID:  0fe2795516b9e1c59b58b02bdf8658698117ec4e
Gitweb:     https://git.kernel.org/tip/0fe2795516b9e1c59b58b02bdf8658698117ec4e
Author:     Arnd Bergmann <arnd@arndb.de>
AuthorDate: Mon, 18 Jun 2018 16:07:59 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 19 Jun 2018 09:23:19 +0200

posix-timers: Fix nanosleep_copyout() for CONFIG_COMPAT_32BIT_TIME

Commit b5793b0d92c9 added support for building the nanosleep compat system
call on 32-bit architectures, but missed one change in nanosleep_copyout(),
which would trigger a BUG() as soon as any architecture is switched over to
use it.

Use the proper config symbol to enable the code path.

Fixes: Commit b5793b0d92c9 ("posix-timers: Make compat syscalls depend on CONFIG_COMPAT_32BIT_TIME")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: y2038@lists.linaro.org
Cc: Anna-Maria Gleixner <anna-maria@linutronix.de>
Cc: Deepa Dinamani <deepa.kernel@gmail.com>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Link: https://lkml.kernel.org/r/20180618140811.2998503-1-arnd@arndb.de

---
 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 055a4a728c00..3e93c54bd3a1 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1659,7 +1659,7 @@ EXPORT_SYMBOL_GPL(hrtimer_init_sleeper);
 int nanosleep_copyout(struct restart_block *restart, struct timespec64 *ts)
 {
 	switch(restart->nanosleep.type) {
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_COMPAT_32BIT_TIME
 	case TT_COMPAT:
 		if (compat_put_timespec64(ts, restart->nanosleep.compat_rmtp))
 			return -EFAULT;

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [tip:timers/core] time: Use ktime_get_real_seconds() in time syscall
  2018-06-18 14:08 ` [PATCH 2/3] time: use ktime_get_real_seconds() in time syscall Arnd Bergmann
@ 2018-06-19  8:00   ` tip-bot for Arnd Bergmann
  0 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Arnd Bergmann @ 2018-06-19  8:00 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: arnd, sboyd, deepa.kernel, linux-kernel, hpa, john.stultz, tglx,
	mingo, viro

Commit-ID:  f5a89295e2f566d8e9f1d4f3d524d8d3c966958c
Gitweb:     https://git.kernel.org/tip/f5a89295e2f566d8e9f1d4f3d524d8d3c966958c
Author:     Arnd Bergmann <arnd@arndb.de>
AuthorDate: Mon, 18 Jun 2018 16:08:00 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 19 Jun 2018 09:56:26 +0200

time: Use ktime_get_real_seconds() in time syscall

Both get_seconds() and do_gettimeofday() are deprecated. Change the time()
implementation to use the replacement function instead.

Obviously the system call will still overflow in 2038, but this gets us
closer to removing the old helper functions.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: John Stultz <john.stultz@linaro.org>
Cc: y2038@lists.linaro.org
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Deepa Dinamani <deepa.kernel@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Link: https://lkml.kernel.org/r/20180618140811.2998503-2-arnd@arndb.de

---
 kernel/time/time.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/kernel/time/time.c b/kernel/time/time.c
index 6fa99213fc72..b1225db61eb2 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -63,7 +63,7 @@ EXPORT_SYMBOL(sys_tz);
  */
 SYSCALL_DEFINE1(time, time_t __user *, tloc)
 {
-	time_t i = get_seconds();
+	time_t i = (time_t)ktime_get_real_seconds();
 
 	if (tloc) {
 		if (put_user(i,tloc))
@@ -106,11 +106,9 @@ SYSCALL_DEFINE1(stime, time_t __user *, tptr)
 /* compat_time_t is a 32 bit "long" and needs to get converted. */
 COMPAT_SYSCALL_DEFINE1(time, compat_time_t __user *, tloc)
 {
-	struct timeval tv;
 	compat_time_t i;
 
-	do_gettimeofday(&tv);
-	i = tv.tv_sec;
+	i = (compat_time_t)ktime_get_real_seconds();
 
 	if (tloc) {
 		if (put_user(i,tloc))

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [tip:timers/core] timekeeping: Use ktime_get_real_ts64() instead of getnstimeofday64()
  2018-06-18 14:08 ` [PATCH 3/3] timekeeping: use ktime_get_real_ts64() instead of getnstimeofday64() Arnd Bergmann
@ 2018-06-19  8:01   ` tip-bot for Arnd Bergmann
  0 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Arnd Bergmann @ 2018-06-19  8:01 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, john.stultz, mlichvar, arnd, sboyd, hpa, mingo, tglx

Commit-ID:  d30faff900e666f9a6395a159fdd353c02f5bed0
Gitweb:     https://git.kernel.org/tip/d30faff900e666f9a6395a159fdd353c02f5bed0
Author:     Arnd Bergmann <arnd@arndb.de>
AuthorDate: Mon, 18 Jun 2018 16:08:01 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 19 Jun 2018 09:56:26 +0200

timekeeping: Use ktime_get_real_ts64() instead of getnstimeofday64()

The two do the same, this moves all users to the newer name for consistency.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: John Stultz <john.stultz@linaro.org>
Cc: y2038@lists.linaro.org
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Miroslav Lichvar <mlichvar@redhat.com>
Link: https://lkml.kernel.org/r/20180618140811.2998503-3-arnd@arndb.de

---
 kernel/time/ntp.c         | 6 +++---
 kernel/time/timekeeping.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index a09ded765f6c..10a79053e82f 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -502,7 +502,7 @@ static void sched_sync_hw_clock(struct timespec64 now,
 {
 	struct timespec64 next;
 
-	getnstimeofday64(&next);
+	ktime_get_real_ts64(&next);
 	if (!fail)
 		next.tv_sec = 659;
 	else {
@@ -537,7 +537,7 @@ static void sync_rtc_clock(void)
 	if (!IS_ENABLED(CONFIG_RTC_SYSTOHC))
 		return;
 
-	getnstimeofday64(&now);
+	ktime_get_real_ts64(&now);
 
 	adjust = now;
 	if (persistent_clock_is_local)
@@ -591,7 +591,7 @@ static bool sync_cmos_clock(void)
 	 * Architectures are strongly encouraged to use rtclib and not
 	 * implement this legacy API.
 	 */
-	getnstimeofday64(&now);
+	ktime_get_real_ts64(&now);
 	if (rtc_tv_nsec_ok(-1 * target_nsec, &adjust, &now)) {
 		if (persistent_clock_is_local)
 			adjust.tv_sec -= (sys_tz.tz_minuteswest * 60);
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 4786df904c22..77c436a0070b 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -2310,7 +2310,7 @@ int do_adjtimex(struct timex *txc)
 			return ret;
 	}
 
-	getnstimeofday64(&ts);
+	ktime_get_real_ts64(&ts);
 
 	raw_spin_lock_irqsave(&timekeeper_lock, flags);
 	write_seqcount_begin(&tk_core.seq);

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-06-19  8:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-18 14:07 [PATCH 1/3] posix-timers: fix nanosleep_copyout() for CONFIG_COMPAT_32BIT_TIME Arnd Bergmann
2018-06-18 14:08 ` [PATCH 2/3] time: use ktime_get_real_seconds() in time syscall Arnd Bergmann
2018-06-19  8:00   ` [tip:timers/core] time: Use " tip-bot for Arnd Bergmann
2018-06-18 14:08 ` [PATCH 3/3] timekeeping: use ktime_get_real_ts64() instead of getnstimeofday64() Arnd Bergmann
2018-06-19  8:01   ` [tip:timers/core] timekeeping: Use " tip-bot for Arnd Bergmann
2018-06-19  7:27 ` [tip:timers/urgent] posix-timers: Fix nanosleep_copyout() for CONFIG_COMPAT_32BIT_TIME tip-bot for Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).