unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Lukasz Majewski <lukma@denx.de>, Joseph Myers <joseph@codesourcery.com>
Cc: Alistair Francis <alistair23@gmail.com>,
	Alistair Francis <alistair.francis@wdc.com>,
	GNU C Library <libc-alpha@sourceware.org>,
	Adhemerval Zanella <adhemerval.zanella@linaro.org>,
	Florian Weimer <fweimer@redhat.com>,
	Florian Weimer <fw@deneb.enyo.de>,
	Zack Weinberg <zackw@panix.com>,
	Carlos O'Donell <carlos@redhat.com>
Subject: Re: [PATCH 1/2] linux: clock_settime: Remove check for nanoseconds validity
Date: Wed, 27 Nov 2019 11:27:59 -0800	[thread overview]
Message-ID: <06446e8b-0226-1c57-1c7b-a5c7d6b7bd20@cs.ucla.edu> (raw)
In-Reply-To: <20191127180436.0e83a744@jawa>

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.

      reply	other threads:[~2019-11-27 19:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-08 15:33 [PATCH 1/2] linux: clock_settime: Remove check for nanoseconds validity Lukasz Majewski
2019-11-08 15:33 ` [PATCH 2/2] linux: clock_settime: Return proper value when passing NULL pointer Lukasz Majewski
2019-11-08 16:56   ` Alistair Francis
2019-11-08 17:00     ` Joseph Myers
2019-11-08 16:20 ` [PATCH 1/2] linux: clock_settime: Remove check for nanoseconds validity Alistair Francis
2019-11-11 15:45 ` Lukasz Majewski
2019-11-27 17:04   ` Lukasz Majewski
2019-11-27 19:27     ` Paul Eggert [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=06446e8b-0226-1c57-1c7b-a5c7d6b7bd20@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=adhemerval.zanella@linaro.org \
    --cc=alistair.francis@wdc.com \
    --cc=alistair23@gmail.com \
    --cc=carlos@redhat.com \
    --cc=fw@deneb.enyo.de \
    --cc=fweimer@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    --cc=lukma@denx.de \
    --cc=zackw@panix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).