ntp: Move adjtimex related compat syscalls to native counterparts
Get rid of set_fs() mess and sanitize compat_{get,put}_timex(), while we are at it. 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-9-viro@ZenIV.linux.org.uk
此提交包含在:
@@ -28,6 +28,7 @@ asmlinkage long sys_ni_posix_timers(void)
|
||||
}
|
||||
|
||||
#define SYS_NI(name) SYSCALL_ALIAS(sys_##name, sys_ni_posix_timers)
|
||||
#define COMPAT_SYS_NI(name) SYSCALL_ALIAS(compat_sys_##name, sys_ni_posix_timers)
|
||||
|
||||
SYS_NI(timer_create);
|
||||
SYS_NI(timer_gettime);
|
||||
@@ -40,6 +41,7 @@ SYS_NI(setitimer);
|
||||
#ifdef __ARCH_WANT_SYS_ALARM
|
||||
SYS_NI(alarm);
|
||||
#endif
|
||||
COMPAT_SYS_NI(clock_adjtime);
|
||||
|
||||
/*
|
||||
* We preserve minimal support for CLOCK_REALTIME and CLOCK_MONOTONIC
|
||||
|
@@ -1018,6 +1018,33 @@ SYSCALL_DEFINE2(clock_adjtime, const clockid_t, which_clock,
|
||||
return err;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_COMPAT
|
||||
|
||||
COMPAT_SYSCALL_DEFINE2(clock_adjtime, clockid_t, which_clock,
|
||||
struct compat_timex __user *, utp)
|
||||
{
|
||||
const struct k_clock *kc = clockid_to_kclock(which_clock);
|
||||
struct timex ktx;
|
||||
int err;
|
||||
|
||||
if (!kc)
|
||||
return -EINVAL;
|
||||
if (!kc->clock_adj)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
err = compat_get_timex(&ktx, utp);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = kc->clock_adj(which_clock, &ktx);
|
||||
|
||||
if (err >= 0)
|
||||
err = compat_put_timex(utp, &ktx);
|
||||
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock,
|
||||
struct timespec __user *, tp)
|
||||
{
|
||||
|
@@ -39,6 +39,7 @@
|
||||
#include <linux/ptrace.h>
|
||||
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/compat.h>
|
||||
#include <asm/unistd.h>
|
||||
|
||||
#include <generated/timeconst.h>
|
||||
@@ -224,12 +225,33 @@ SYSCALL_DEFINE1(adjtimex, struct timex __user *, txc_p)
|
||||
* structure. But bear in mind that the structures
|
||||
* may change
|
||||
*/
|
||||
if(copy_from_user(&txc, txc_p, sizeof(struct timex)))
|
||||
if (copy_from_user(&txc, txc_p, sizeof(struct timex)))
|
||||
return -EFAULT;
|
||||
ret = do_adjtimex(&txc);
|
||||
return copy_to_user(txc_p, &txc, sizeof(struct timex)) ? -EFAULT : ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_COMPAT
|
||||
|
||||
COMPAT_SYSCALL_DEFINE1(adjtimex, struct compat_timex __user *, utp)
|
||||
{
|
||||
struct timex txc;
|
||||
int err, ret;
|
||||
|
||||
err = compat_get_timex(&txc, utp);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
ret = do_adjtimex(&txc);
|
||||
|
||||
err = compat_put_timex(utp, &txc);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Convert jiffies to milliseconds and back.
|
||||
*
|
||||
|
新增問題並參考
封鎖使用者