time:Introduce the do_sys_settimeofday64() function with timespec64 type
PATCH v3 14/22 time:Introduce the do_sys_settimeofday64() function with timespec64 type
This patch introduces the do_sys_settimeofday64() function with timespec64 type, that makes this function ready for 2038 issue when setting the time of day. And moves the do_sys_settimeofday() function to the timekeeping.h file.
--- include/linux/timekeeping.h | 12 ++++++++++-- kernel/time/time.c | 10 ++++++---- 2 files changed, 16 insertions(+), 6 deletions(-)
include/linux/timekeeping.h +10 -2
@@ -11,8 +11,16 @@ extern int timekeeping_suspended;*/ extern void do_gettimeofday (struct timeval *tv);extern int do_settimeofday64 (const struct timespec64 *ts); -extern int do_sys_settimeofday (const struct timespec *tv, -const struct timezone *tz); +extern int do_sys_settimeofday64 (const struct timespec64 *tv, +const struct timezone *tz); +static inline int do_sys_settimeofday (const struct timespec *tv, +const struct timezone *tz) +{ +struct timespec64 ts64; + + ts64 =timespec_to_timespec64 (*tv); +return do_sys_settimeofday64 (&ts64, tz); +}/* * Kernel time accessors
kernel/time/time.c +6 -4
@@ -160,15 +160,17 @@ static inline void warp_clock(void)* various programs will get confused when the clock gets warped. */ -int do_sys_settimeofday (const struct timespec *tv,const struct timezone *tz) +int do_sys_settimeofday64 (const struct timespec64 *tv,const struct timezone *tz) {static int firsttime =1 ;int error =0 ; +struct timespec ts; -if (tv && !timespec_valid (tv)) +if (tv && !timespec64_valid (tv))return -EINVAL ; - error =security_settime (tv, tz); + ts =timespec64_to_timespec (*tv); + error =security_settime (&ts, tz);if (error)return error;
@@ -182,7 +184,7 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz) } }if (tv) -return do_settimeofday (tv); +return do_settimeofday64 (tv);return 0 ; }
Signature · 1 line
1.7.9.5
Quoted 2 lines · Baolin Wang
This patch introduces the
do_sys_settimeofday64()function with timespec64 type, that makes this function ready for 2038 issue when setting the time of day.
Copy and paste is your favourite work method, right?
Quoted 4 lines
kernel/time/time.c +1
-1-int do_sys_settimeofday (const struct timespec *tv,const struct timezone *tz) +int do_sys_settimeofday64 (const struct timespec64 *tv,const struct timezone *tz) {static int firsttime =1 ;
kernel/time/time.c static inline void warp_clock(void) · line 173
Quoted 10 lines
kernel/time/time.c +4
-2int error =0 ; +struct timespec ts; -if (tv && !timespec_valid (tv)) +if (tv && !timespec64_valid (tv))return -EINVAL ; - error =security_settime (tv, tz); + ts =timespec64_to_timespec (*tv); + error =security_settime (&ts, tz);
How is that 2038 safe? Not at all.
I told you before that we fix the underlying functions before we add such bogosities.
Thanks,
tglx
A message that is not in the archive (sent off-list or not yet received): CAMz4kuKY3fu6B-36OGQKnAr-r8LcCrO-NhTDYzBdYF6JPiKyFg@mail.gmail.com
Quoted 19 lines · On Wednesday 13 May 2015 10:43:25 Baolin Wang wrote:
Quoted 19 lines
Quoted 1 line
-int do_sys_settimeofday(const struct timespec *tv, const struct
timezone *tz)
Quoted 1 line
+int do_sys_settimeofday64(const struct timespec64 *tv, const struct
timezone *tz)
kernel/time/time.c static inline void warp_clock(void) · line 173
Quoted 12 lines
{ static int firsttime = 1; int error = 0;kernel/time/time.c +4
-2+struct timespec ts; -if (tv && !timespec_valid (tv)) +if (tv && !timespec64_valid (tv))return -EINVAL ; - error =security_settime (tv, tz); + ts =timespec64_to_timespec (*tv); + error =security_settime (&ts, tz);How is that 2038 safe? Not at all.
Quoted 7 lines
Quoted 4 lines
I told you before that we fix the underlying functions before we add such bogosities.
Thanks for your comments, and i'll continue to repair my patch. But could you explain what the defects in
do_sys_settimeofday64function? Thanks.
What Thomas meant here is that you should first fix security_settime to take a timespec64 argument. I guess you could introduce a security_settime64() function first, using another inline wrapper to provide the existing security_settime() API. security_settime() does not actually use the time argument, so this is a fairly easy thing to do.
Arnd