[pkg-ntp-maintainers] Bug#794054: ntpd inserts a leap second regardless of the step threshold

Flos Lonicerae lonicerae at gmail.com
Sun Nov 6 13:58:08 UTC 2016


Any update on this? Please let us know if there's any concern about this patch.

2016-10-29 23:49 GMT+08:00 Flos Lonicerae <lonicerae at gmail.com>:
> Package: ntp
> Version: 1:4.2.6.p5+dfsg-7+deb8u2
> Followup-For: Bug #794054
>
> Hi all,
>
> Kazuhiro's finding is true and this issue has been fixed in upstream:
>
> ** ntpd -x steps clock on leap second
> http://bugs.ntp.org/show_bug.cgi?id=2745
>
> I can confirm this bug with adding debugging code to ntp code and also monitor
> the kernel's internal state with systemtap.
>
> Below is the patch I ported from RH's source code:
> ~~~
> $ cat ntp-4.2.6p5-xleap.patch
> diff -uNr ntp-4.2.6.p5+dfsg.orig/html/miscopt.html
> ntp-4.2.6.p5+dfsg/html/miscopt.html
> --- ntp-4.2.6.p5+dfsg.orig/html/miscopt.html    2009-12-09 07:36:36.000000000
> +0000
> +++ ntp-4.2.6.p5+dfsg/html/miscopt.html 2016-10-23 13:44:44.822000703 +0000
> @@ -88,7 +88,7 @@
>                                                 is 0.128 s. If set to zero,
> step adjustments will never
>                                                 occur. Note: The kernel time
> discipline is disabled if
>                                                 the step threshold is set to
> zero or greater than 0.5
> -                                               s.</dd>
> +                                               s and the threshold is applied
> also to leap second corrections.</dd>
>                                         <dt><tt>stepout
> <i>stepout</i></tt></dt>
>                                         <dd>Specifies the stepout threshold in
> seconds. The default without this
>                                                 command is 900 s.  If set to
> zero, popcorn spikes will
> diff -uNr ntp-4.2.6.p5+dfsg.orig/html/ntpd.html
> ntp-4.2.6.p5+dfsg/html/ntpd.html
> --- ntp-4.2.6.p5+dfsg.orig/html/ntpd.html       2011-07-11 02:18:26.000000000
> +0000
> +++ ntp-4.2.6.p5+dfsg/html/ntpd.html    2016-10-23 13:46:28.386001420 +0000
> @@ -147,7 +147,7 @@
>                         <dt><tt>-V <i>variable</i></tt></dt>
>                         <dd>Add a system variable listed by default.</dd>
>                         <dt><tt>-x</tt></dt>
> -                       <dd>Normally, the time is slewed if the offset is less
> than the step threshold, which is 128 ms by default, and stepped if above the
> threshold. This option sets the threshold to 600 s, which is well within the
> accuracy window to set the clock manually. Note: Since the slew rate of typical
> Unix kernels is limited to 0.5 ms/s, each second of adjustment requires an
> amortization interval of 2000 s. Thus, an adjustment as much as 600 s will take
> almost 14 days to complete. This option can be used with the <tt>-g</tt> and
> <tt>-q</tt> options. See the <tt>tinker</tt> command for other options. Note:
> The kernel time discipline is disabled with this option.</dd>
> +                       <dd>Normally, the time is slewed if the offset is less
> than the step threshold, which is 128 ms by default, and stepped if above the
> threshold. This option sets the threshold to 600 s, which is well within the
> accuracy window to set the clock manually. Note: Since the slew rate of typical
> Unix kernels is limited to 0.5 ms/s, each second of adjustment requires an
> amortization interval of 2000 s. Thus, an adjustment as much as 600 s will take
> almost 14 days to complete. This option can be used with the <tt>-g</tt> and
> <tt>-q</tt> options. See the <tt>tinker</tt> command for other options. Note:
> The kernel time discipline is disabled with this option and the step threshold
> is applied also to leap second corrections.</dd>
>                         <dt><tt>--pccfreq <i>frequency</i></tt></dt>
>                         <dd>Substitute processor cycle counter for
> QueryPerformanceCounter unconditionally
>                                 using the given frequency (in Hz).
> <tt>--pccfreq</tt> can be used on systems
> diff -uNr ntp-4.2.6.p5+dfsg.orig/ntpd/ntp_timer.c
> ntp-4.2.6.p5+dfsg/ntpd/ntp_timer.c
> --- ntp-4.2.6.p5+dfsg.orig/ntpd/ntp_timer.c     2011-12-01 02:55:17.000000000
> +0000
> +++ ntp-4.2.6.p5+dfsg/ntpd/ntp_timer.c  2016-10-23 13:48:15.578002161 +0000
> @@ -338,7 +338,8 @@
>                         sys_leap = LEAP_NOWARNING;
>                         sys_tai = leap_tai;
>  #ifdef KERNEL_PLL
> -                       if (!(pll_control && kern_enable))
> +                       if (clock_max < 1.0 && clock_max > 0.0 &&
> +                                       !(pll_control && kern_enable))
>                                 step_systime(-1.0);
>  #else /* KERNEL_PLL */
>  #ifndef SYS_WINNT /* WinNT port has its own leap second handling */
> ~~~
>
> This behaviour of this patch should be the same as Kazuhiro's except for the
> log printing part.
>
> If the ntp 4.2.6.p5 version will be used during jessie's lifecycle, this issue
> should be escalated to IMPORTANT level as the leap second is coming.
>
> Best Regards,
> Flos
>
>
>
> -- System Information:
> Debian Release: 8.6
>   APT prefers stable-updates
>   APT policy: (500, 'stable-updates'), (500, 'stable')
> Architecture: amd64 (x86_64)
> Foreign Architectures: i386
>
> Kernel: Linux 3.16.0-4-amd64 (SMP w/2 CPU cores)
> Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
> Shell: /bin/sh linked to /bin/dash
> Init: systemd (via /run/systemd/system)
>
> Versions of packages ntp depends on:
> ii  adduser      3.113+nmu3
> ii  dpkg         1.17.27
> ii  libc6        2.19-18+deb8u6
> ii  libcap2      1:2.24-8
> ii  libedit2     3.1-20140620-2
> ii  libopts25    1:5.18.4-3
> ii  libssl1.0.0  1.0.1t-1+deb8u5
> ii  lsb-base     4.1+Debian13+nmu1
> ii  netbase      5.3
>
> Versions of packages ntp recommends:
> ii  perl  5.20.2-3+deb8u6
>
> Versions of packages ntp suggests:
> pn  ntp-doc  <none>
>
> -- Configuration Files:
> /etc/ntp.conf changed [not included]
>
> -- no debconf information



More information about the pkg-ntp-maintainers mailing list