Clock setting bug on current/i386 (patch available)

From: Ted Faber <faber_at_ISI.EDU>
Date: Mon, 2 Apr 2007 08:33:21 -0700
Hi.

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 
http://www.freebsd.org/cgi/query-pr.cgi?pr=111117

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.

Thanks!

-- 
Ted Faber
http://www.isi.edu/~faber           PGP: http://www.isi.edu/~faber/pubkeys.asc
Unexpected attachment on this mail? See http://www.isi.edu/~faber/FAQ.html#SIG

Received on Mon Apr 02 2007 - 13:43:27 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:07 UTC