posix-timers: fix nanosleep_copyout() for CONFIG_COMPAT_32BIT_TIME
Subsystems (2)
PATCH 1/3 posix-timers: fix nanosleep_copyout() for CONFIG_COMPAT_32BIT_TIME
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.
--- kernel/time/hrtimer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/hrtimer.c +1 -1
@@ -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 ;
Signature · 1 line
2.9.0
PATCH 2/3 time: use ktime_get_real_seconds() in time syscall
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.
--- kernel/time/time.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
kernel/time/time.c +2 -4
@@ -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))
Signature · 1 line
2.9.0
tip-bot for Arnd Bergmann
merge bot[tip:timers/core] time: Use ktime_get_real_seconds() in time syscall
time: Use ktime_get_real_seconds() in time syscall
Commit-ID: f5a89295e2f566d8e9f1d4f3d524d8d3c966958c Gitweb: https://git.kernel.org/tip/f5a89295e2f566d8e9f1d4f3d524d8d3c966958c Author: Arnd Bergmann <[email protected]> AuthorDate: Mon, 18 Jun 2018 16:08:00 +0200 Committer: Thomas Gleixner <[email protected]> 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.
--- kernel/time/time.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
kernel/time/time.c +2 -4
@@ -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))
PATCH 3/3 timekeeping: use ktime_get_real_ts64() instead of getnstimeofday64()
In reply to Arnd BergmannThe two do the same, this moves all users to the newer name for consistency.
--- kernel/time/ntp.c | 6 +++--- kernel/time/timekeeping.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
kernel/time/ntp.c +3 -3
@@ -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 );
kernel/time/timekeeping.c +1 -1
@@ -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);
Signature · 1 line
2.9.0
tip-bot for Arnd Bergmann
merge bot[tip:timers/core] timekeeping: Use ktime_get_real_ts64() instead of getnstimeofday64()
timekeeping: Use ktime_get_real_ts64() instead of getnstimeofday64()
Commit-ID: d30faff900e666f9a6395a159fdd353c02f5bed0 Gitweb: https://git.kernel.org/tip/d30faff900e666f9a6395a159fdd353c02f5bed0 Author: Arnd Bergmann <[email protected]> AuthorDate: Mon, 18 Jun 2018 16:08:01 +0200 Committer: Thomas Gleixner <[email protected]> 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.
--- kernel/time/ntp.c | 6 +++--- kernel/time/timekeeping.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
kernel/time/ntp.c +3 -3
@@ -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 );
kernel/time/timekeeping.c +1 -1
@@ -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);
tip-bot for Arnd Bergmann
merge bot[tip:timers/urgent] posix-timers: Fix nanosleep_copyout() for CONFIG_COMPAT_32BIT_TIME
In reply to Arnd Bergmannposix-timers: Fix nanosleep_copyout() for CONFIG_COMPAT_32BIT_TIME
Commit-ID: 0fe2795516b9e1c59b58b02bdf8658698117ec4e Gitweb: https://git.kernel.org/tip/0fe2795516b9e1c59b58b02bdf8658698117ec4e Author: Arnd Bergmann <[email protected]> AuthorDate: Mon, 18 Jun 2018 16:07:59 +0200 Committer: Thomas Gleixner <[email protected]> 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.
--- kernel/time/hrtimer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/hrtimer.c +1 -1
@@ -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 ;