From: Thomas Gleixner Move the timespec validation from do_sys_settimeofday into do_settimeofday. The tv timespec pointer can be NULL, so dereferencing tv can result in an oops. do_settimeofday is only called, when tv != NULL. Signed-off-by: Thomas Gleixner Signed-off-by: Andrew Morton --- kernel/time.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diff -puN kernel/time.c~move-timespec-validation-into-do_settimeofday kernel/time.c --- devel/kernel/time.c~move-timespec-validation-into-do_settimeofday 2006-01-23 02:37:11.000000000 -0800 +++ devel-akpm/kernel/time.c 2006-01-23 02:37:11.000000000 -0800 @@ -148,6 +148,8 @@ static inline void warp_clock(void) * timezones. This should be done at boot time in the /etc/rc script, * as soon as possible, so that the clock can be set right. Otherwise, * various programs will get confused when the clock gets warped. + * + * Note, either one or both pointers can be NULL !!! */ int do_sys_settimeofday(struct timespec *tv, struct timezone *tz) @@ -155,9 +157,6 @@ int do_sys_settimeofday(struct timespec static int firsttime = 1; int error = 0; - if (!timespec_valid(tv)) - return -EINVAL; - error = security_settime(tv, tz); if (error) return error; @@ -502,7 +501,7 @@ int do_settimeofday (struct timespec *tv time_t wtm_sec, sec = tv->tv_sec; long wtm_nsec, nsec = tv->tv_nsec; - if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC) + if (!timespec_valid(tv)) return -EINVAL; write_seqlock_irq(&xtime_lock); _