Skip to content

Commit

Permalink
time: Move compat_time()/stime() to native
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Cc: John Stultz <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
  • Loading branch information
Al Viro authored and KAGA-KOKO committed Jun 13, 2017
1 parent 2482097 commit b180db2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 40 deletions.
40 changes: 0 additions & 40 deletions kernel/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,46 +739,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,
Expand Down
41 changes: 41 additions & 0 deletions kernel/time/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit b180db2

Please sign in to comment.