From: Thomas Gleixner add timespec_valid(ts) [returns false if the timespec is denorm] Signed-off-by: Thomas Gleixner Signed-off-by: Ingo Molnar Signed-off-by: Andrew Morton --- include/linux/time.h | 6 ++++++ kernel/posix-timers.c | 5 ++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff -puN include/linux/time.h~hrtimer-create-and-use-timespec_valid-macro include/linux/time.h --- devel/include/linux/time.h~hrtimer-create-and-use-timespec_valid-macro 2005-12-09 00:01:45.000000000 -0800 +++ devel-akpm/include/linux/time.h 2005-12-09 00:01:45.000000000 -0800 @@ -44,6 +44,12 @@ extern unsigned long mktime(const unsign extern void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec); +/* + * Returns true if the timespec is norm, false if denorm: + */ +#define timespec_valid(ts) \ + (((ts)->tv_sec >= 0) && (((unsigned) (ts)->tv_nsec) < NSEC_PER_SEC)) + extern struct timespec xtime; extern struct timespec wall_to_monotonic; extern seqlock_t xtime_lock; diff -puN kernel/posix-timers.c~hrtimer-create-and-use-timespec_valid-macro kernel/posix-timers.c --- devel/kernel/posix-timers.c~hrtimer-create-and-use-timespec_valid-macro 2005-12-09 00:01:45.000000000 -0800 +++ devel-akpm/kernel/posix-timers.c 2005-12-09 00:01:45.000000000 -0800 @@ -712,8 +712,7 @@ out: */ static int good_timespec(const struct timespec *ts) { - if ((!ts) || (ts->tv_sec < 0) || - ((unsigned) ts->tv_nsec >= NSEC_PER_SEC)) + if ((!ts) || !timespec_valid(ts)) return 0; return 1; } @@ -1406,7 +1405,7 @@ sys_clock_nanosleep(const clockid_t whic if (copy_from_user(&t, rqtp, sizeof (struct timespec))) return -EFAULT; - if ((unsigned) t.tv_nsec >= NSEC_PER_SEC || t.tv_sec < 0) + if (!timespec_valid(&t)) return -EINVAL; /* _