Skip to content

Commit 2ac00f1

Browse files
deepa-hubKAGA-KOKO
authored andcommitted
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>
1 parent 5fc63f9 commit 2ac00f1

6 files changed

Lines changed: 15 additions & 22 deletions

File tree

‎arch/alpha/kernel/osf_sys.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,20 +1016,22 @@ SYSCALL_DEFINE2(osf_gettimeofday, struct timeval32 __user *, tv,
10161016
SYSCALL_DEFINE2(osf_settimeofday, struct timeval32 __user *, tv,
10171017
struct timezone __user *, tz)
10181018
{
1019+
struct timespec64 kts64;
10191020
struct timespec kts;
10201021
struct timezone ktz;
10211022

10221023
if (tv) {
10231024
if (get_tv32((struct timeval *)&kts, tv))
10241025
return -EFAULT;
10251026
kts.tv_nsec *= 1000;
1027+
kts64 = timespec_to_timespec64(kts);
10261028
}
10271029
if (tz) {
10281030
if (copy_from_user(&ktz, tz, sizeof(*tz)))
10291031
return -EFAULT;
10301032
}
10311033

1032-
return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
1034+
return do_sys_settimeofday64(tv ? &kts64 : NULL, tz ? &ktz : NULL);
10331035
}
10341036

10351037
asmlinkage long sys_ni_posix_timers(void);

‎include/linux/timekeeping.h‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,6 @@ extern void do_gettimeofday(struct timeval *tv);
1919
extern int do_settimeofday64(const struct timespec64 *ts);
2020
extern int do_sys_settimeofday64(const struct timespec64 *tv,
2121
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-
3722
/*
3823
* Kernel time accessors
3924
*/

‎kernel/compat.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ COMPAT_SYSCALL_DEFINE2(gettimeofday, struct compat_timeval __user *, tv,
108108
COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval __user *, tv,
109109
struct timezone __user *, tz)
110110
{
111+
struct timespec64 new_ts;
111112
struct timeval user_tv;
112-
struct timespec new_ts;
113113
struct timezone new_tz;
114114

115115
if (tv) {
@@ -123,7 +123,7 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval __user *, tv,
123123
return -EFAULT;
124124
}
125125

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);
127127
}
128128

129129
static int __compat_get_timeval(struct timeval *tv, const struct compat_timeval __user *ctv)

‎kernel/time/posix-stubs.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,16 @@ SYS_NI(alarm);
4949
SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
5050
const struct timespec __user *, tp)
5151
{
52+
struct timespec64 new_tp64;
5253
struct timespec new_tp;
5354

5455
if (which_clock != CLOCK_REALTIME)
5556
return -EINVAL;
5657
if (copy_from_user(&new_tp, tp, sizeof (*tp)))
5758
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);
5962
}
6063

6164
SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,

‎kernel/time/posix-timers.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,10 @@ static int posix_clock_realtime_get(clockid_t which_clock, struct timespec *tp)
214214
static int posix_clock_realtime_set(const clockid_t which_clock,
215215
const struct timespec *tp)
216216
{
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);
218221
}
219222

220223
static int posix_clock_realtime_adj(const clockid_t which_clock,

‎kernel/time/time.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ int do_sys_settimeofday64(const struct timespec64 *tv, const struct timezone *tz
193193
SYSCALL_DEFINE2(settimeofday, struct timeval __user *, tv,
194194
struct timezone __user *, tz)
195195
{
196+
struct timespec64 new_ts;
196197
struct timeval user_tv;
197-
struct timespec new_ts;
198198
struct timezone new_tz;
199199

200200
if (tv) {
@@ -212,7 +212,7 @@ SYSCALL_DEFINE2(settimeofday, struct timeval __user *, tv,
212212
return -EFAULT;
213213
}
214214

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);
216216
}
217217

218218
SYSCALL_DEFINE1(adjtimex, struct timex __user *, txc_p)

0 commit comments

Comments
 (0)