Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1659536

[PATCH 15/16] time()/stime(): move compat to native

From Al Viro <viro@ZenIV.linux.org.uk>
Newsgroups linux.kernel
Subject [PATCH 15/16] time()/stime(): move compat to native
Date 2017-06-07 10:50 +0200
Message-ID <tPEP8-4gO-27@gated-at.bofh.it> (permalink)
References <tPEP7-4gO-5@gated-at.bofh.it> <tPEP7-4gO-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Al Viro <viro@zeniv.linux.org.uk>

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 kernel/compat.c    | 40 ----------------------------------------
 kernel/time/time.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 40 deletions(-)

diff --git a/kernel/compat.c b/kernel/compat.c
index 92ba0afafddc..a56aa5777987 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -737,46 +737,6 @@ COMPAT_SYSCALL_DEFINE4(rt_sigtimedwait, compat_sigset_t __user *, uthese,
 	return ret;
 }
 
-#ifdef __ARCH_WANT_COMPAT_SYS_TIME
-
-/* compat_time_t is a 32 bit "long" and needs to get converted. */
-
-COMPAT_SYSCALL_DEFINE1(time, compat_time_t __user *, tloc)
-{
-	compat_time_t i;
-	struct timeval tv;
-
-	do_gettimeofday(&tv);
-	i = tv.tv_sec;
-
-	if (tloc) {
-		if (put_user(i,tloc))
-			return -EFAULT;
-	}
-	force_successful_syscall_return();
-	return i;
-}
-
-COMPAT_SYSCALL_DEFINE1(stime, compat_time_t __user *, tptr)
-{
-	struct timespec tv;
-	int err;
-
-	if (get_user(tv.tv_sec, tptr))
-		return -EFAULT;
-
-	tv.tv_nsec = 0;
-
-	err = security_settime(&tv, NULL);
-	if (err)
-		return err;
-
-	do_settimeofday(&tv);
-	return 0;
-}
-
-#endif /* __ARCH_WANT_COMPAT_SYS_TIME */
-
 #ifdef CONFIG_NUMA
 COMPAT_SYSCALL_DEFINE6(move_pages, pid_t, pid, compat_ulong_t, nr_pages,
 		       compat_uptr_t __user *, pages32,
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 400662f16c5a..1d5ebf6a8d9e 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -100,6 +100,48 @@ SYSCALL_DEFINE1(stime, time_t __user *, tptr)
 
 #endif /* __ARCH_WANT_SYS_TIME */
 
+#ifdef CONFIG_COMPAT
+#ifdef __ARCH_WANT_COMPAT_SYS_TIME
+
+/* compat_time_t is a 32 bit "long" and needs to get converted. */
+
+COMPAT_SYSCALL_DEFINE1(time, compat_time_t __user *, tloc)
+{
+	compat_time_t i;
+	struct timeval tv;
+
+	do_gettimeofday(&tv);
+	i = tv.tv_sec;
+
+	if (tloc) {
+		if (put_user(i,tloc))
+			return -EFAULT;
+	}
+	force_successful_syscall_return();
+	return i;
+}
+
+COMPAT_SYSCALL_DEFINE1(stime, compat_time_t __user *, tptr)
+{
+	struct timespec tv;
+	int err;
+
+	if (get_user(tv.tv_sec, tptr))
+		return -EFAULT;
+
+	tv.tv_nsec = 0;
+
+	err = security_settime(&tv, NULL);
+	if (err)
+		return err;
+
+	do_settimeofday(&tv);
+	return 0;
+}
+
+#endif /* __ARCH_WANT_COMPAT_SYS_TIME */
+#endif
+
 SYSCALL_DEFINE2(gettimeofday, struct timeval __user *, tv,
 		struct timezone __user *, tz)
 {
-- 
2.11.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 01/16] move copyout of timespec into do_cpu_nanosleep() Al Viro <viro@ZenIV.linux.org.uk> - 2017-06-07 10:50 +0200
  [PATCH 06/16] nanosleep/clock_nanosleep: teach to do compat copyouts Al Viro <viro@ZenIV.linux.org.uk> - 2017-06-07 10:50 +0200
    Re: [PATCH 06/16] nanosleep/clock_nanosleep: teach to do compat  copyouts Peter Zijlstra <peterz@infradead.org> - 2017-06-07 12:10 +0200
    [tip:timers/core] time/posix-timers: Move the compat copyouts to  the nanosleep implementations tip-bot for Al Viro <tipbot@zytor.com> - 2017-06-14 00:20 +0200
  [PATCH 15/16] time()/stime(): move compat to native Al Viro <viro@ZenIV.linux.org.uk> - 2017-06-07 10:50 +0200
    [tip:timers/core] time: Move compat_time()/stime() to native tip-bot for Al Viro <tipbot@zytor.com> - 2017-06-14 00:20 +0200
  [PATCH 12/16] move compat itimer syscalls to native ones Al Viro <viro@ZenIV.linux.org.uk> - 2017-06-07 10:50 +0200
    [tip:timers/core] itimers: Move compat itimer syscalls to native  ones tip-bot for Al Viro <tipbot@zytor.com> - 2017-06-14 00:20 +0200
  [PATCH 04/16] move copyout to do_nanosleel() Al Viro <viro@ZenIV.linux.org.uk> - 2017-06-07 10:50 +0200
    [tip:timers/core] hrtimer: Move copyout of remaining time to  do_nanosleep() tip-bot for Al Viro <tipbot@zytor.com> - 2017-06-14 00:10 +0200
  [PATCH 14/16] timer_create(): move compat to native, get rid of set_fs() Al Viro <viro@ZenIV.linux.org.uk> - 2017-06-07 10:50 +0200
    [tip:timers/core] posix-timers: Move compat_timer_create() to  native, get rid of set_fs() tip-bot for Al Viro <tipbot@zytor.com> - 2017-06-14 00:20 +0200
  [PATCH 09/16] move adjtimex-related compat syscalls to native counterparts Al Viro <viro@ZenIV.linux.org.uk> - 2017-06-07 10:50 +0200
    [tip:timers/core] ntp: Move adjtimex related compat syscalls to  native counterparts tip-bot for Al Viro <tipbot@zytor.com> - 2017-06-14 00:20 +0200
  [PATCH 03/16] hrtimer_nanosleep(): pass rmtp in restart_block Al Viro <viro@ZenIV.linux.org.uk> - 2017-06-07 10:50 +0200
    [tip:timers/core] hrtimer_nanosleep(): Pass rmtp in restart_block tip-bot for Al Viro <tipbot@zytor.com> - 2017-06-14 00:10 +0200
  [PATCH 08/16] kill ->nsleep_restart() Al Viro <viro@ZenIV.linux.org.uk> - 2017-06-07 10:50 +0200
    [tip:timers/core] posix-timers: Kill ->nsleep_restart() tip-bot for Al Viro <tipbot@zytor.com> - 2017-06-14 00:20 +0200
  [PATCH 10/16] take compat timer_settime(2) to native one Al Viro <viro@ZenIV.linux.org.uk> - 2017-06-07 10:50 +0200
    [tip:timers/core] posix-timers: Take compat timer_settime(2) to  native one tip-bot for Al Viro <tipbot@zytor.com> - 2017-06-14 00:20 +0200
  Re: [PATCH 01/16] move copyout of timespec into do_cpu_nanosleep() Thomas Gleixner <tglx@linutronix.de> - 2017-06-13 01:10 +0200
    Re: [PATCH 01/16] move copyout of timespec into do_cpu_nanosleep() Thomas Gleixner <tglx@linutronix.de> - 2017-06-13 09:50 +0200
  [tip:timers/core] posix-cpu-timers: Move copyout of timespec into  do_cpu_nanosleep() tip-bot for Al Viro <tipbot@zytor.com> - 2017-06-14 00:10 +0200

csiph-web