lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8ae32d2f-e4a8-240f-c7bd-580c26bba2d0@gmail.com>
Date:   Thu, 2 Apr 2020 15:16:01 +0200
From:   "Michael Kerrisk (man-pages)" <mtk.manpages@...il.com>
To:     Thomas Gleixner <tglx@...utronix.de>
Cc:     mtk.manpages@...il.com, linux-man <linux-man@...r.kernel.org>,
        lkml <linux-kernel@...r.kernel.org>, arul.jeniston@...il.com,
        "devi R.K" <devi.feb27@...il.com>,
        Marc Lehmann <debian-reportbug@...n9.de>,
        John Stultz <john.stultz@...aro.org>,
        Andrei Vagin <avagin@...il.com>,
        Cyrill Gorcunov <gorcunov@...il.com>
Subject: Re: timer_settime() and ECANCELED

On 4/2/20 10:49 AM, Thomas Gleixner wrote:
> Michael,
> 
> "Michael Kerrisk (man-pages)" <mtk.manpages@...il.com> writes:
>> On 4/1/20 7:42 PM, Thomas Gleixner wrote:
>>> (b): Arming the timer in that case is indeed very questionable, but it
>>>      could be argued that because the clock was set event happened with
>>>      the old expiry value that the new expiry value is not affected.
>>>      
>>>      I'd be happy to change that and not arm the timer in the case of a
>>>      pending cancel, but I fear that some user space already depends on
>>>      that behaviour.
>>
>> Yes, that's the risk, of course. So, shall we just document all 
>> this in the manual page?
> 
> I think so.
> 
> Thanks,

Okay. How is the following?

NOTES
       Suppose  the  following scenario for CLOCK_REALTIME or CLOCK_REAL‐
       TIME_ALARM timer that was created with timerfd_create():

       (a) The  timer  has  been  started  (timerfd_settime())  with  the
           TFD_TIMER_ABSTIME and TFD_TIMER_CANCEL_ON_SET flags;

       (b) A discontinuous change (e.g.  settimeofday(2)) is subsequently
           made to the CLOCK_REALTIME clock; and

       (c) the caller once more  calls  timerfd_settime()  to  rearm  the
           timer (without first doing a read(2) on the file descriptor).

       In this case the following occurs:

       · The  timerfd_settime()  returns  -1 with errno set to ECANCELED.
         (This enables the caller to know that  the  previous  timer  was
         affected by a discontinuous change to the clock.)

       · The  timer is successfully rearmed with the settings provided in
         the second timerfd_settime() call.  (This was probably an imple‐
         mentation  accident,  but  won't be fixed now, in case there are
         applications that depend on this behaviour.)

Thanks,

Michael

diff --git a/man2/timerfd_create.2 b/man2/timerfd_create.2
index ec137fbfe..98225dcad 100644
--- a/man2/timerfd_create.2
+++ b/man2/timerfd_create.2
@@ -477,6 +477,9 @@ is not a valid timerfd file descriptor.
 .BR timerfd_settime ()
 can also fail with the following errors:
 .TP
+.B ECANCELED
+See NOTES.
+.TP
 .B EINVAL
 .I new_value
 is not properly initialized (one of the
@@ -493,6 +496,52 @@ These system calls are available on Linux since kernel 2.6.
25.
 Library support is provided by glibc since version 2.8.
 .SH CONFORMING TO
 These system calls are Linux-specific.
+.SH NOTES
+Suppose the following scenario for
+.BR CLOCK_REALTIME
+or
+.BR CLOCK_REALTIME_ALARM
+timer that was created with
+.BR timerfd_create ():
+.IP (a) 4
+The timer has been started
+.RB ( timerfd_settime ())
+with the
+.BR TFD_TIMER_ABSTIME
+and
+.BR TFD_TIMER_CANCEL_ON_SET
+flags;
+.IP (b)
+A discontinuous change (e.g.
+.BR settimeofday (2))
+is subsequently made to the
+.BR CLOCK_REALTIME
+clock; and
+.IP (c)
+the caller once more calls
+.BR timerfd_settime ()
+to rearm the timer (without first doing a
+.BR read (2)
+on the file descriptor).
+.PP
+In this case the following occurs:
+.IP \(bu 2
+The
+.BR timerfd_settime ()
+returns \-1 with
+.I errno
+set to
+.BR ECANCELED .
+(This enables the caller to know that the previous timer was affected
+by a discontinuous change to the clock.)
+.IP \(bu
+The timer
+.I "is successfully rearmed"
+with the settings provided in the second
+.BR timerfd_settime ()
+call.
+(This was probably an implementation accident, but won't be fixed now,
+in case there are applications that depend on this behaviour.)
 .SH BUGS
 Currently,
 .\" 2.6.29


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ