linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: keyrings@vger.kernel.org
Cc: David Woodhouse <David.Woodhouse@intel.com>,
	Arnd Bergmann <arnd@arndb.de>,
	linux-kernel@vger.kernel.org, dhowells@redhat.com,
	linux-security-module@vger.kernel.org,
	Rudolf Polzer <rpolzer@google.com>,
	John Stultz <john.stultz@linaro.org>
Subject: [RFC PATCH 3/4] X.509: Support leap seconds
Date: Mon, 04 Jan 2016 22:17:19 +0000	[thread overview]
Message-ID: <20160104221719.19818.33763.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <20160104221658.19818.56223.stgit@warthog.procyon.org.uk>

The format of ASN.1 GeneralizedTime seems to be specified by ISO 8601
[X.680 46.3] and this apparently supports leap seconds (ie. the seconds
field is 60).  It's not entirely clear that ASN.1 expects it, but we can
relax the seconds check slightly for GeneralizedTime.

This results in us passing a time with sec as 60 to mktime64(), which
handles it as being a duplicate of the 0th second of the next minute.

We can't really do otherwise without giving the kernel much greater
knowledge of where all the leap seconds are.  Unfortunately, this would
require change the mapping of the kernel's current-time-in-seconds.

UTCTime, however, only supports a seconds value in the range 00-59, but for
the sake of simplicity allow this with UTCTime also.

Without this patch, certain X.509 certificates will be rejected,
potentially making a kernel unbootable.

Reported-by: Rudolf Polzer <rpolzer@google.com>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Arnd Bergmann <arnd@arndb.de>
cc: David Woodhouse <David.Woodhouse@intel.com>
cc: John Stultz <john.stultz@linaro.org>
---

 crypto/asymmetric_keys/x509_cert_parser.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c
index 13c4e5a5fe8c..3379c0ba3988 100644
--- a/crypto/asymmetric_keys/x509_cert_parser.c
+++ b/crypto/asymmetric_keys/x509_cert_parser.c
@@ -550,7 +550,7 @@ int x509_decode_time(time64_t *_t,  size_t hdrlen,
 	if (day < 1 || day > mon_len ||
 	    hour > 23 ||
 	    min > 59 ||
-	    sec > 59)
+	    sec > 60) /* ISO 8601 permits leap seconds [X.680 46.3] */
 		goto invalid_time;
 
 	*_t = mktime64(year, mon, day, hour, min, sec);


  parent reply	other threads:[~2016-01-04 22:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-04 22:16 [PATCH 0/4] X.509: Fix time handling David Howells
2016-01-04 22:17 ` [RFC PATCH 1/4] X.509: Fix leap year handling again David Howells
2016-01-20 15:12   ` Rudolf Polzer
2016-01-20 15:18   ` David Howells
2016-01-04 22:17 ` [RFC PATCH 2/4] Handle ISO 8601 leap seconds and encodings of midnight in mktime64() David Howells
2016-01-04 22:17 ` David Howells [this message]
2016-01-20 15:08   ` [RFC PATCH 3/4] X.509: Support leap seconds Rudolf Polzer
2016-01-04 22:17 ` [RFC PATCH 4/4] X.509: Handle midnight alternative notation in GeneralizedTime David Howells
2016-01-20 15:08   ` Rudolf Polzer
2016-01-20 15:20   ` David Howells
2016-01-20 15:30     ` One Thousand Gnomes
2016-02-03 16:25     ` David Howells
2016-02-03 16:28     ` David Howells
2016-02-04 17:38       ` One Thousand Gnomes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160104221719.19818.33763.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=David.Woodhouse@intel.com \
    --cc=arnd@arndb.de \
    --cc=john.stultz@linaro.org \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=rpolzer@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).