[pkg-ntp-maintainers] Bug#396937: Backgrounded ntpdate from ifup races with hwclock

beck beck at ibh.de
Fri Nov 3 20:51:03 CET 2006


Package: ntpdate
Version: 1:4.2.2.p4+dfsg-1
Severity: normal


Hi,

it appears that the new way ntpdate-debian is called from if-up.d (starting
it as a background process to prevent delays during boot) can lead to a
race with hwclock.sh which is called later from rcS. In my case, ntpdate
was seemingly started after the interface went up and ran a while in the
background. In the meantime, hwclock.sh corrected the clock according to
CMOS clock information. At this point, the clock is correct, but ntpdate
is still not completed. When it finally completes, it corrects the clock
by another hour, resulting in a wrong clock. The unsatisfactory result is
that though I have a correct CMOS clock, working NTP servers and I am
running both ntpdate and a local NTP server, I end up with the wrong
time. Due to the large offset, ntpd will not fix the clock, either.

My CMOS clock is running in local time (intentionally) which is CET.

I don't see a perfect solution for this issue, as backgrounding ntpdate
was requested in a lot of bug reports and should probably stay. Either
ntpdate itself is broken and assumes that nothing else could change the
system clock during the long seconds it might need from start to the
actual correction, or it interferes in another unexpected way with
hwclock (which delays a bit for itself due to the CMOS clock specifics).
Of course there is a general problem anyway, as there is AFAIK no
atomic method of getting and setting the system clock in POSIX. But it
depends on the actual coding whether this race condition will be exposed
with significant probability - I could repeat it over and over again and
get the wrong time on every reboot...

Is there any decent reason why hwclock.sh is S50 in rcS.d? Having it
run significantly earlier would get rid of the problem quite nicely and
the system would have correct time earlier in the boot process as well.

TIA,
Andre.

-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.17.13
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages ntpdate depends on:
ii  libc6                        2.3.6.ds1-4 GNU C Library: Shared libraries
ii  libcap1                      1:1.10-14   support for getting/setting POSIX.
ii  libssl0.9.8                  0.9.8c-3    SSL shared libraries
ii  netbase                      4.27        Basic TCP/IP networking system

ntpdate recommends no packages.

-- no debconf information




More information about the pkg-ntp-maintainers mailing list