[Ksummit-discuss] Leap second handling

David Howells dhowells at redhat.com
Tue Dec 15 11:33:58 UTC 2015


I know it's a bit late for the KS, but should we alter the interpretation of
the time-as-seconds-since-1970 in the kernel to include leap seconds?

The reason I ask is that we have to deal with X.509 certificates in the kernel,
and the certificate can have dates encoded using GeneralizedTime ASN.1 objects.
These are formatted as per ISO 8601.  ISO 8601 encodes leap seconds as hh:mm:60
- so it's possible that I can see this in cert I have to deal with, and as such
I must permit it.  I turn the date and time components into a time64_t with
mktime64() - but that doesn't know about leap seconds, however.

So the question is how to deal with it.  I can see three obvious ways:

 (1) Treat it the same as hh:mm:59.

 (2) Treat it the same as hh:mm+1:00, rolling over the carry through to the
     year if necessary.

 (3) Assign specific time_t values to leap seconds in mktime64().  There's a
     table of them here:

	https://en.wikipedia.org/wiki/Leap_second

     It wouldn't be hard to do within just the kernel, but this would put the
     kernel at odds with userspace to the tune of nearly half a minute at the
     current time.  It might be sufficient to just fix the libc's in userspace
     - but you can bet there's someone somewhere who checks that seconds
     doesn't exceed 59.

     The kernel would also need to tell libc whether or not the time value it
     gets includes leap seconds.

Any thoughts?

David


More information about the Ksummit-discuss mailing list