From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751709AbdFGInl (ORCPT ); Wed, 7 Jun 2017 04:43:41 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:55734 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751708AbdFGImn (ORCPT ); Wed, 7 Jun 2017 04:42:43 -0400 From: Al Viro To: linux-kernel@vger.kernel.org Cc: Thomas Gleixner Subject: [PATCH 15/16] time()/stime(): move compat to native Date: Wed, 7 Jun 2017 09:42:40 +0100 Message-Id: <20170607084241.28657-15-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170607084241.28657-1-viro@ZenIV.linux.org.uk> References: <20170607084106.GV6365@ZenIV.linux.org.uk> <20170607084241.28657-1-viro@ZenIV.linux.org.uk> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro Signed-off-by: Al Viro --- 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