diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2017-06-07 04:42:34 -0400 |
|---|---|---|
| committer | Thomas Gleixner <tglx@linutronix.de> | 2017-06-13 18:00:43 -0400 |
| commit | 3a4d44b6162555070194e486ff6b3799a8d323a2 (patch) | |
| tree | 095069878df5402d3616164b523fe7e65e894f6f /kernel/time | |
| parent | fb923c4a3c2ee735755d4a93522150fc35d0ecbd (diff) | |
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
Diffstat (limited to 'kernel/time')
| -rw-r--r-- | kernel/time/posix-stubs.c | 2 | ||||
| -rw-r--r-- | kernel/time/posix-timers.c | 27 | ||||
| -rw-r--r-- | kernel/time/time.c | 24 |
3 files changed, 52 insertions, 1 deletions
diff --git a/kernel/time/posix-stubs.c b/kernel/time/posix-stubs.c index 749b76f2d757..954d1d8ff9e6 100644 --- a/kernel/time/posix-stubs.c +++ b/kernel/time/posix-stubs.c | |||
| @@ -28,6 +28,7 @@ asmlinkage long sys_ni_posix_timers(void) | |||
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | #define SYS_NI(name) SYSCALL_ALIAS(sys_##name, sys_ni_posix_timers) | 30 | #define SYS_NI(name) SYSCALL_ALIAS(sys_##name, sys_ni_posix_timers) |
| 31 | #define COMPAT_SYS_NI(name) SYSCALL_ALIAS(compat_sys_##name, sys_ni_posix_timers) | ||
| 31 | 32 | ||
| 32 | SYS_NI(timer_create); | 33 | SYS_NI(timer_create); |
| 33 | SYS_NI(timer_gettime); | 34 | SYS_NI(timer_gettime); |
| @@ -40,6 +41,7 @@ SYS_NI(setitimer); | |||
| 40 | #ifdef __ARCH_WANT_SYS_ALARM | 41 | #ifdef __ARCH_WANT_SYS_ALARM |
| 41 | SYS_NI(alarm); | 42 | SYS_NI(alarm); |
| 42 | #endif | 43 | #endif |
| 44 | COMPAT_SYS_NI(clock_adjtime); | ||
| 43 | 45 | ||
| 44 | /* | 46 | /* |
| 45 | * We preserve minimal support for CLOCK_REALTIME and CLOCK_MONOTONIC | 47 | * We preserve minimal support for CLOCK_REALTIME and CLOCK_MONOTONIC |
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index ea4a463436bf..b1b6d52d6425 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c | |||
| @@ -1018,6 +1018,33 @@ SYSCALL_DEFINE2(clock_adjtime, const clockid_t, which_clock, | |||
| 1018 | return err; | 1018 | return err; |
| 1019 | } | 1019 | } |
| 1020 | 1020 | ||
| 1021 | #ifdef CONFIG_COMPAT | ||
| 1022 | |||
| 1023 | COMPAT_SYSCALL_DEFINE2(clock_adjtime, clockid_t, which_clock, | ||
| 1024 | struct compat_timex __user *, utp) | ||
| 1025 | { | ||
| 1026 | const struct k_clock *kc = clockid_to_kclock(which_clock); | ||
| 1027 | struct timex ktx; | ||
| 1028 | int err; | ||
| 1029 | |||
| 1030 | if (!kc) | ||
| 1031 | return -EINVAL; | ||
| 1032 | if (!kc->clock_adj) | ||
| 1033 | return -EOPNOTSUPP; | ||
| 1034 | |||
| 1035 | err = compat_get_timex(&ktx, utp); | ||
| 1036 | if (err) | ||
| 1037 | return err; | ||
| 1038 | |||
| 1039 | err = kc->clock_adj(which_clock, &ktx); | ||
| 1040 | |||
| 1041 | if (err >= 0) | ||
| 1042 | err = compat_put_timex(utp, &ktx); | ||
| 1043 | |||
| 1044 | return err; | ||
| 1045 | } | ||
| 1046 | #endif | ||
| 1047 | |||
| 1021 | SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock, | 1048 | SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock, |
| 1022 | struct timespec __user *, tp) | 1049 | struct timespec __user *, tp) |
| 1023 | { | 1050 | { |
diff --git a/kernel/time/time.c b/kernel/time/time.c index 49c73c6ed648..400662f16c5a 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c | |||
| @@ -39,6 +39,7 @@ | |||
| 39 | #include <linux/ptrace.h> | 39 | #include <linux/ptrace.h> |
| 40 | 40 | ||
| 41 | #include <linux/uaccess.h> | 41 | #include <linux/uaccess.h> |
| 42 | #include <linux/compat.h> | ||
| 42 | #include <asm/unistd.h> | 43 | #include <asm/unistd.h> |
| 43 | 44 | ||
| 44 | #include <generated/timeconst.h> | 45 | #include <generated/timeconst.h> |
| @@ -224,12 +225,33 @@ SYSCALL_DEFINE1(adjtimex, struct timex __user *, txc_p) | |||
| 224 | * structure. But bear in mind that the structures | 225 | * structure. But bear in mind that the structures |
| 225 | * may change | 226 | * may change |
| 226 | */ | 227 | */ |
| 227 | if(copy_from_user(&txc, txc_p, sizeof(struct timex))) | 228 | if (copy_from_user(&txc, txc_p, sizeof(struct timex))) |
| 228 | return -EFAULT; | 229 | return -EFAULT; |
| 229 | ret = do_adjtimex(&txc); | 230 | ret = do_adjtimex(&txc); |
| 230 | return copy_to_user(txc_p, &txc, sizeof(struct timex)) ? -EFAULT : ret; | 231 | return copy_to_user(txc_p, &txc, sizeof(struct timex)) ? -EFAULT : ret; |
| 231 | } | 232 | } |
| 232 | 233 | ||
| 234 | #ifdef CONFIG_COMPAT | ||
| 235 | |||
| 236 | COMPAT_SYSCALL_DEFINE1(adjtimex, struct compat_timex __user *, utp) | ||
| 237 | { | ||
| 238 | struct timex txc; | ||
| 239 | int err, ret; | ||
| 240 | |||
| 241 | err = compat_get_timex(&txc, utp); | ||
| 242 | if (err) | ||
| 243 | return err; | ||
| 244 | |||
| 245 | ret = do_adjtimex(&txc); | ||
| 246 | |||
| 247 | err = compat_put_timex(utp, &txc); | ||
| 248 | if (err) | ||
| 249 | return err; | ||
| 250 | |||
| 251 | return ret; | ||
| 252 | } | ||
| 253 | #endif | ||
| 254 | |||
| 233 | /* | 255 | /* |
| 234 | * Convert jiffies to milliseconds and back. | 256 | * Convert jiffies to milliseconds and back. |
| 235 | * | 257 | * |
