Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

time: Delete do_sys_setimeofday()

struct timespec is not y2038 safe on 32 bit machines and needs to be
replaced with struct timespec64.

do_sys_timeofday() is just a wrapper function. Replace all calls to this
function with direct calls to do_sys_timeofday64() instead and delete
do_sys_timeofday().

Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
Cc: y2038@lists.linaro.org
Cc: john.stultz@linaro.org
Cc: arnd@arndb.de
Cc: linux-alpha@vger.kernel.org
Link: http://lkml.kernel.org/r/1490555058-4603-2-git-send-email-deepa.kernel@gmail.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

authored by

Deepa Dinamani and committed by
Thomas Gleixner
2ac00f17 5fc63f95

+15 -22
+3 -1
arch/alpha/kernel/osf_sys.c
··· 1016 1016 SYSCALL_DEFINE2(osf_settimeofday, struct timeval32 __user *, tv, 1017 1017 struct timezone __user *, tz) 1018 1018 { 1019 + struct timespec64 kts64; 1019 1020 struct timespec kts; 1020 1021 struct timezone ktz; 1021 1022 ··· 1024 1023 if (get_tv32((struct timeval *)&kts, tv)) 1025 1024 return -EFAULT; 1026 1025 kts.tv_nsec *= 1000; 1026 + kts64 = timespec_to_timespec64(kts); 1027 1027 } 1028 1028 if (tz) { 1029 1029 if (copy_from_user(&ktz, tz, sizeof(*tz))) 1030 1030 return -EFAULT; 1031 1031 } 1032 1032 1033 - return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL); 1033 + return do_sys_settimeofday64(tv ? &kts64 : NULL, tz ? &ktz : NULL); 1034 1034 } 1035 1035 1036 1036 asmlinkage long sys_ni_posix_timers(void);
-15
include/linux/timekeeping.h
··· 19 19 extern int do_settimeofday64(const struct timespec64 *ts); 20 20 extern int do_sys_settimeofday64(const struct timespec64 *tv, 21 21 const struct timezone *tz); 22 - static inline int do_sys_settimeofday(const struct timespec *tv, 23 - const struct timezone *tz) 24 - { 25 - struct timespec64 ts64; 26 - 27 - if (!tv) 28 - return do_sys_settimeofday64(NULL, tz); 29 - 30 - if (!timespec_valid(tv)) 31 - return -EINVAL; 32 - 33 - ts64 = timespec_to_timespec64(*tv); 34 - return do_sys_settimeofday64(&ts64, tz); 35 - } 36 - 37 22 /* 38 23 * Kernel time accessors 39 24 */
+2 -2
kernel/compat.c
··· 108 108 COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval __user *, tv, 109 109 struct timezone __user *, tz) 110 110 { 111 + struct timespec64 new_ts; 111 112 struct timeval user_tv; 112 - struct timespec new_ts; 113 113 struct timezone new_tz; 114 114 115 115 if (tv) { ··· 123 123 return -EFAULT; 124 124 } 125 125 126 - return do_sys_settimeofday(tv ? &new_ts : NULL, tz ? &new_tz : NULL); 126 + return do_sys_settimeofday64(tv ? &new_ts : NULL, tz ? &new_tz : NULL); 127 127 } 128 128 129 129 static int __compat_get_timeval(struct timeval *tv, const struct compat_timeval __user *ctv)
+4 -1
kernel/time/posix-stubs.c
··· 49 49 SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock, 50 50 const struct timespec __user *, tp) 51 51 { 52 + struct timespec64 new_tp64; 52 53 struct timespec new_tp; 53 54 54 55 if (which_clock != CLOCK_REALTIME) 55 56 return -EINVAL; 56 57 if (copy_from_user(&new_tp, tp, sizeof (*tp))) 57 58 return -EFAULT; 58 - return do_sys_settimeofday(&new_tp, NULL); 59 + 60 + new_tp64 = timespec_to_timespec64(new_tp); 61 + return do_sys_settimeofday64(&new_tp64, NULL); 59 62 } 60 63 61 64 SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
+4 -1
kernel/time/posix-timers.c
··· 214 214 static int posix_clock_realtime_set(const clockid_t which_clock, 215 215 const struct timespec *tp) 216 216 { 217 - return do_sys_settimeofday(tp, NULL); 217 + struct timespec64 tp64; 218 + 219 + tp64 = timespec_to_timespec64(*tp); 220 + return do_sys_settimeofday64(&tp64, NULL); 218 221 } 219 222 220 223 static int posix_clock_realtime_adj(const clockid_t which_clock,
+2 -2
kernel/time/time.c
··· 193 193 SYSCALL_DEFINE2(settimeofday, struct timeval __user *, tv, 194 194 struct timezone __user *, tz) 195 195 { 196 + struct timespec64 new_ts; 196 197 struct timeval user_tv; 197 - struct timespec new_ts; 198 198 struct timezone new_tz; 199 199 200 200 if (tv) { ··· 212 212 return -EFAULT; 213 213 } 214 214 215 - return do_sys_settimeofday(tv ? &new_ts : NULL, tz ? &new_tz : NULL); 215 + return do_sys_settimeofday64(tv ? &new_ts : NULL, tz ? &new_tz : NULL); 216 216 } 217 217 218 218 SYSCALL_DEFINE1(adjtimex, struct timex __user *, txc_p)