This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/2] linux: clock_settime: Remove check for nanoseconds validity


On 11/27/19 9:04 AM, Lukasz Majewski wrote:

a/sysdeps/unix/sysv/linux/clock_settime.c +++
b/sysdeps/unix/sysv/linux/clock_settime.c @@ -25,13 +25,6 @@
  int
  __clock_settime64 (clockid_t clock_id, const struct __timespec64
*tp) {
-  /* Make sure the time cvalue is OK.  */
-  if (! valid_nanoseconds (tp->tv_nsec))
-    {
-      __set_errno (EINVAL);
-      return -1;
-    }
-
I'm just wondering if this patch is OK, as with other patches, which
convert time to use 64 bit syscalls we do rely on Linux kernel to
check the nanoseconds (and return proper error).

Suppose tp->tv_sec == 1 && tp->tv_nsec == -1 && !defined __ASSUME_TIME64_SYSCALLS && !defined __NR_clock_settime64. Then the current code will fail with errno == EINVAL, but with the proposed patch the code will succeed and set the time to 1 second after the Epoch.

Code should always check for valid nanoseconds before calling valid_timespec64_to_timespec with possibly-invalid input. In this function, the check can be done at about the same time as the in_time_t_range check; that'd be better than what the current code does.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]