From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754022AbdFMWQB (ORCPT ); Tue, 13 Jun 2017 18:16:01 -0400 Received: from terminus.zytor.com ([65.50.211.136]:38813 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753866AbdFMWP7 (ORCPT ); Tue, 13 Jun 2017 18:15:59 -0400 Date: Tue, 13 Jun 2017 15:12:26 -0700 From: tip-bot for Al Viro Message-ID: Cc: peterz@infradead.org, mingo@kernel.org, john.stultz@linaro.org, hpa@zytor.com, linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, tglx@linutronix.de Reply-To: hpa@zytor.com, john.stultz@linaro.org, mingo@kernel.org, peterz@infradead.org, tglx@linutronix.de, viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org In-Reply-To: <20170607084241.28657-16-viro@ZenIV.linux.org.uk> References: <20170607084241.28657-16-viro@ZenIV.linux.org.uk> To: linux-tip-commits@vger.kernel.org Subject: [tip:timers/core] time: Move compat_gettimeofday()/settimeofday() to native Git-Commit-ID: 2b2d02856b3176701c91d723356f766d6ee27853 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 2b2d02856b3176701c91d723356f766d6ee27853 Gitweb: http://git.kernel.org/tip/2b2d02856b3176701c91d723356f766d6ee27853 Author: Al Viro AuthorDate: Wed, 7 Jun 2017 09:42:41 +0100 Committer: Thomas Gleixner CommitDate: Wed, 14 Jun 2017 00:00:46 +0200 time: Move compat_gettimeofday()/settimeofday() to native Signed-off-by: Al Viro Signed-off-by: Thomas Gleixner Cc: John Stultz Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20170607084241.28657-16-viro@ZenIV.linux.org.uk --- kernel/compat.c | 38 -------------------------------------- kernel/time/time.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 38 deletions(-) diff --git a/kernel/compat.c b/kernel/compat.c index aa7b9a2..ebd8bdc 100644 --- a/kernel/compat.c +++ b/kernel/compat.c @@ -92,44 +92,6 @@ int compat_put_timex(struct compat_timex __user *utp, const struct timex *txc) return 0; } -COMPAT_SYSCALL_DEFINE2(gettimeofday, struct compat_timeval __user *, tv, - struct timezone __user *, tz) -{ - if (tv) { - struct timeval ktv; - do_gettimeofday(&ktv); - if (compat_put_timeval(&ktv, tv)) - return -EFAULT; - } - if (tz) { - if (copy_to_user(tz, &sys_tz, sizeof(sys_tz))) - return -EFAULT; - } - - return 0; -} - -COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval __user *, tv, - struct timezone __user *, tz) -{ - struct timespec64 new_ts; - struct timeval user_tv; - struct timezone new_tz; - - if (tv) { - if (compat_get_timeval(&user_tv, tv)) - return -EFAULT; - new_ts.tv_sec = user_tv.tv_sec; - new_ts.tv_nsec = user_tv.tv_usec * NSEC_PER_USEC; - } - if (tz) { - if (copy_from_user(&new_tz, tz, sizeof(*tz))) - return -EFAULT; - } - - return do_sys_settimeofday64(tv ? &new_ts : NULL, tz ? &new_tz : NULL); -} - static int __compat_get_timeval(struct timeval *tv, const struct compat_timeval __user *ctv) { return (!access_ok(VERIFY_READ, ctv, sizeof(*ctv)) || diff --git a/kernel/time/time.c b/kernel/time/time.c index e5d4499..7c89e43 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c @@ -257,6 +257,47 @@ SYSCALL_DEFINE2(settimeofday, struct timeval __user *, tv, return do_sys_settimeofday64(tv ? &new_ts : NULL, tz ? &new_tz : NULL); } +#ifdef CONFIG_COMPAT +COMPAT_SYSCALL_DEFINE2(gettimeofday, struct compat_timeval __user *, tv, + struct timezone __user *, tz) +{ + if (tv) { + struct timeval ktv; + + do_gettimeofday(&ktv); + if (compat_put_timeval(&ktv, tv)) + return -EFAULT; + } + if (tz) { + if (copy_to_user(tz, &sys_tz, sizeof(sys_tz))) + return -EFAULT; + } + + return 0; +} + +COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval __user *, tv, + struct timezone __user *, tz) +{ + struct timespec64 new_ts; + struct timeval user_tv; + struct timezone new_tz; + + if (tv) { + if (compat_get_timeval(&user_tv, tv)) + return -EFAULT; + new_ts.tv_sec = user_tv.tv_sec; + new_ts.tv_nsec = user_tv.tv_usec * NSEC_PER_USEC; + } + if (tz) { + if (copy_from_user(&new_tz, tz, sizeof(*tz))) + return -EFAULT; + } + + return do_sys_settimeofday64(tv ? &new_ts : NULL, tz ? &new_tz : NULL); +} +#endif + SYSCALL_DEFINE1(adjtimex, struct timex __user *, txc_p) { struct timex txc; /* Local copy of parameter */