aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/time
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2017-06-07 09:42:40 +0100
committerThomas Gleixner <tglx@linutronix.de>2017-06-14 00:00:45 +0200
commitb180db2c8ca6692a10b79631cadc18d03303d494 (patch)
treeba94924a438f4c504dd1709647f299cf5081a2c2 /kernel/time
parentposix-timers: Move compat_timer_create() to native, get rid of set_fs() (diff)
downloadlinux-dev-b180db2c8ca6692a10b79631cadc18d03303d494.tar.xz
linux-dev-b180db2c8ca6692a10b79631cadc18d03303d494.zip
time: Move compat_time()/stime() to native
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: John Stultz <john.stultz@linaro.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20170607084241.28657-15-viro@ZenIV.linux.org.uk
Diffstat (limited to 'kernel/time')
-rw-r--r--kernel/time/time.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 400662f16c5a..e5d44999ff78 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -100,6 +100,47 @@ 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)
+{
+ struct timeval tv;
+ compat_time_t i;
+
+ 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)
{