Clock setting bug on current/i386 (patch available)

Ted Faber faber at ISI.EDU
Mon Apr 2 15:43:27 UTC 2007


I had a sort of wierd bug with the code in sys/i386/isa/clock.c that
sets the kernel clock from the realtime clock.  The short story is in

The longer story is that my EPIA ME6000 clock seems to have the day of
the week wrong in its real time clock (RTC) and no way to adjust that
value.  This shouldn't be a big deal, but the code that converts from
the RTC to seconds (clock_ct_to_ts() in sys/kern/subr_clock.c) checks
the day of the week value - unless it's set to -1 - though it isn't
used in the conversion.  That code fails with an error if the day of the
week is wrong.  The i386 clock-setting code doesn't check this return
value and the kernel time is set to whatever lucky value was on the
stack when the function was called.

There is much odd behavior on a box that thinks that the year is 1937.
newsyslog fails to parse configuration files, for example...

The PR has a few line patch to call clock_ct_to_ts() again with the day
of the week set to -1 if the function fails and the day of the week
wasn't -1.  It prints some diagnostics to let a user know their clock
isn't set should none of that work.  Feel free to clip the diagnostics,
but they would have saved me some time. :-)

It's a short patch.  I'm sending this mail in the hope that some
committer will pop it in as an easy Monday morning thing.


Ted Faber           PGP:
Unexpected attachment on this mail? See
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url :

More information about the freebsd-current mailing list