2013-09-25 06:40:57

by Chun-Yi Lee

[permalink] [raw]
Subject: [PATCH] X.509: Remove validity check of certificate date

The check of valid_from and valid_to fields on X.509 certificate is a
time bomb to MODSIGN function, It causes kernel module could not be
load because the RTC on system may messed by user action (e.g. refresh
BIOS) that should not be trusted.

Base on the discussion of David Howells's "[PATCH] X.509: Remove
certificate date checks":
https://lkml.org/lkml/2013/3/14/257

This patch removed the validity check of certificate date but still keep
the valid_from and valid_to fields for future usage.

Signed-off-by: Lee, Chun-Yi <[email protected]>
cc: David Howells <[email protected]>
cc: David Woodhouse <[email protected]>
cc: Rusty Russell <[email protected]>
cc: Josh Boyer <[email protected]>
cc: Alexander Holler <[email protected]>
cc: Matthew Garrett <[email protected]>
cc: Peter Jones <[email protected]>
---
crypto/asymmetric_keys/x509_public_key.c | 38 ------------------------------
1 files changed, 0 insertions(+), 38 deletions(-)

diff --git a/crypto/asymmetric_keys/x509_public_key.c b/crypto/asymmetric_keys/x509_public_key.c
index 06007f0..52222a2 100644
--- a/crypto/asymmetric_keys/x509_public_key.c
+++ b/crypto/asymmetric_keys/x509_public_key.c
@@ -106,7 +106,6 @@ error_no_sig:
static int x509_key_preparse(struct key_preparsed_payload *prep)
{
struct x509_certificate *cert;
- struct tm now;
size_t srlen, sulen;
char *desc = NULL;
int ret;
@@ -137,43 +136,6 @@ static int x509_key_preparse(struct key_preparsed_payload *prep)
goto error_free_cert;
}

- time_to_tm(CURRENT_TIME.tv_sec, 0, &now);
- pr_devel("Now: %04ld-%02d-%02d %02d:%02d:%02d\n",
- now.tm_year + 1900, now.tm_mon + 1, now.tm_mday,
- now.tm_hour, now.tm_min, now.tm_sec);
- if (now.tm_year < cert->valid_from.tm_year ||
- (now.tm_year == cert->valid_from.tm_year &&
- (now.tm_mon < cert->valid_from.tm_mon ||
- (now.tm_mon == cert->valid_from.tm_mon &&
- (now.tm_mday < cert->valid_from.tm_mday ||
- (now.tm_mday == cert->valid_from.tm_mday &&
- (now.tm_hour < cert->valid_from.tm_hour ||
- (now.tm_hour == cert->valid_from.tm_hour &&
- (now.tm_min < cert->valid_from.tm_min ||
- (now.tm_min == cert->valid_from.tm_min &&
- (now.tm_sec < cert->valid_from.tm_sec
- ))))))))))) {
- pr_warn("Cert %s is not yet valid\n", cert->fingerprint);
- ret = -EKEYREJECTED;
- goto error_free_cert;
- }
- if (now.tm_year > cert->valid_to.tm_year ||
- (now.tm_year == cert->valid_to.tm_year &&
- (now.tm_mon > cert->valid_to.tm_mon ||
- (now.tm_mon == cert->valid_to.tm_mon &&
- (now.tm_mday > cert->valid_to.tm_mday ||
- (now.tm_mday == cert->valid_to.tm_mday &&
- (now.tm_hour > cert->valid_to.tm_hour ||
- (now.tm_hour == cert->valid_to.tm_hour &&
- (now.tm_min > cert->valid_to.tm_min ||
- (now.tm_min == cert->valid_to.tm_min &&
- (now.tm_sec > cert->valid_to.tm_sec
- ))))))))))) {
- pr_warn("Cert %s has expired\n", cert->fingerprint);
- ret = -EKEYEXPIRED;
- goto error_free_cert;
- }
-
cert->pub->algo = x509_public_key_algorithms[cert->pkey_algo];
cert->pub->id_type = PKEY_ID_X509;

--
1.6.4.2


2013-09-25 09:09:00

by Alexander Holler

[permalink] [raw]
Subject: Re: [PATCH] X.509: Remove validity check of certificate date

(I've resend this message, because the one I've replied to contained
contained kernel@vger... and not linux-kernel@vger... as addressee)

I've already sent exactly the same patch here:

http://lkml.org/lkml/2013/3/27/449

and here:

https://lkml.org/lkml/2013/6/6/207

but for some unspoken reason it always got ignored.

It would make wonder if it would be accepted this time, just because of
another author name.

Regards,

Alexander Holler


Am 25.09.2013 08:20, schrieb Lee, Chun-Yi:
> The check of valid_from and valid_to fields on X.509 certificate is a
> time bomb to MODSIGN function, It causes kernel module could not be
> load because the RTC on system may messed by user action (e.g. refresh
> BIOS) that should not be trusted.
>
> Base on the discussion of David Howells's "[PATCH] X.509: Remove
> certificate date checks":
> https://lkml.org/lkml/2013/3/14/257
>
> This patch removed the validity check of certificate date but still keep
> the valid_from and valid_to fields for future usage.
>
> Signed-off-by: Lee, Chun-Yi <[email protected]>
> cc: David Howells <[email protected]>
> cc: David Woodhouse <[email protected]>
> cc: Rusty Russell <[email protected]>
> cc: Josh Boyer <[email protected]>
> cc: Alexander Holler <[email protected]>
> cc: Matthew Garrett <[email protected]>
> cc: Peter Jones <[email protected]>
> ---
> crypto/asymmetric_keys/x509_public_key.c | 38 ------------------------------
> 1 files changed, 0 insertions(+), 38 deletions(-)
>
> diff --git a/crypto/asymmetric_keys/x509_public_key.c b/crypto/asymmetric_keys/x509_public_key.c
> index 06007f0..52222a2 100644
> --- a/crypto/asymmetric_keys/x509_public_key.c
> +++ b/crypto/asymmetric_keys/x509_public_key.c
> @@ -106,7 +106,6 @@ error_no_sig:
> static int x509_key_preparse(struct key_preparsed_payload *prep)
> {
> struct x509_certificate *cert;
> - struct tm now;
> size_t srlen, sulen;
> char *desc = NULL;
> int ret;
> @@ -137,43 +136,6 @@ static int x509_key_preparse(struct key_preparsed_payload *prep)
> goto error_free_cert;
> }
>
> - time_to_tm(CURRENT_TIME.tv_sec, 0, &now);
> - pr_devel("Now: %04ld-%02d-%02d %02d:%02d:%02d\n",
> - now.tm_year + 1900, now.tm_mon + 1, now.tm_mday,
> - now.tm_hour, now.tm_min, now.tm_sec);
> - if (now.tm_year < cert->valid_from.tm_year ||
> - (now.tm_year == cert->valid_from.tm_year &&
> - (now.tm_mon < cert->valid_from.tm_mon ||
> - (now.tm_mon == cert->valid_from.tm_mon &&
> - (now.tm_mday < cert->valid_from.tm_mday ||
> - (now.tm_mday == cert->valid_from.tm_mday &&
> - (now.tm_hour < cert->valid_from.tm_hour ||
> - (now.tm_hour == cert->valid_from.tm_hour &&
> - (now.tm_min < cert->valid_from.tm_min ||
> - (now.tm_min == cert->valid_from.tm_min &&
> - (now.tm_sec < cert->valid_from.tm_sec
> - ))))))))))) {
> - pr_warn("Cert %s is not yet valid\n", cert->fingerprint);
> - ret = -EKEYREJECTED;
> - goto error_free_cert;
> - }
> - if (now.tm_year > cert->valid_to.tm_year ||
> - (now.tm_year == cert->valid_to.tm_year &&
> - (now.tm_mon > cert->valid_to.tm_mon ||
> - (now.tm_mon == cert->valid_to.tm_mon &&
> - (now.tm_mday > cert->valid_to.tm_mday ||
> - (now.tm_mday == cert->valid_to.tm_mday &&
> - (now.tm_hour > cert->valid_to.tm_hour ||
> - (now.tm_hour == cert->valid_to.tm_hour &&
> - (now.tm_min > cert->valid_to.tm_min ||
> - (now.tm_min == cert->valid_to.tm_min &&
> - (now.tm_sec > cert->valid_to.tm_sec
> - ))))))))))) {
> - pr_warn("Cert %s has expired\n", cert->fingerprint);
> - ret = -EKEYEXPIRED;
> - goto error_free_cert;
> - }
> -
> cert->pub->algo = x509_public_key_algorithms[cert->pkey_algo];
> cert->pub->id_type = PKEY_ID_X509;
>
>

2013-09-25 10:17:43

by joeyli

[permalink] [raw]
Subject: Re: [PATCH] X.509: Remove validity check of certificate date

於 三,2013-09-25 於 11:03 +0200,Alexander Holler 提到:
> (I've resend this message, because the one I've replied to contained
> contained kernel@vger... and not linux-kernel@vger... as addressee)
>
> I've already sent exactly the same patch here:
>
> http://lkml.org/lkml/2013/3/27/449
>
> and here:
>
> https://lkml.org/lkml/2013/6/6/207

Ah! Thanks for your point out, I didn't search out it!

>
> but for some unspoken reason it always got ignored.

Yes, looks your patch is waiting for merge...

>
> It would make wonder if it would be accepted this time, just because of
> another author name.

I think just ignore my patch.

>
> Regards,
>
> Alexander Holler

Thanks a lot!
Joey Lee