Skip to contentSkip to conversation

X.509: if signature is unsupported skip validation

PATCH In review Thore Sommer 3 participants 5 messages Aug 15, 2023 – Aug 25, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 X.509: if signature is unsupported skip validation

When the hash algorithm for the signature is not available the digest size is 0 and the signature in the certificate is marked as unsupported.

When validating a self-signed certificate, this needs to be checked, because otherwise trying to validate the signature will fail with an warning:

Loading compiled-in X.509 certificates

WARNING: CPU: 0 PID: 1 at crypto/rsa-pkcs1pad.c:537 \
pkcs1pad_verify+0x46/0x12c

...
Problem loading in-kernel X.509 certificate (-22)

---
 crypto/asymmetric_keys/x509_public_key.c | 5 +++++
 1 file changed, 5 insertions(+)
crypto/asymmetric_keys/x509_public_key.c +5 -0
index 6fdfc82e23a8..7c71db3ac23d 100644
@@ -130,6 +130,11 @@ int x509_check_for_self_signed(struct x509_certificate *cert)
 			goto out;
 	}
 
+	if (cert->unsupported_sig) {
+		ret = 0;
+		goto out;
+	}
+
 	ret = public_key_verify_signature(cert->pub, cert->sig);
 	if (ret < 0) {
 		if (ret == -ENOPKG) {
Signature · 1 line
2.41.0
maintainer
#1 lore raw
Quoted 36 lines · Thore Sommer

When the hash algorithm for the signature is not available the digest size is 0 and the signature in the certificate is marked as unsupported.

When validating a self-signed certificate, this needs to be checked, because otherwise trying to validate the signature will fail with an warning:

Loading compiled-in X.509 certificates

WARNING: CPU: 0 PID: 1 at crypto/rsa-pkcs1pad.c:537 \
pkcs1pad_verify+0x46/0x12c

...
Problem loading in-kernel X.509 certificate (-22)

---
 crypto/asymmetric_keys/x509_public_key.c | 5 +++++
 1 file changed, 5 insertions(+)
crypto/asymmetric_keys/x509_public_key.c +5 -0
index 6fdfc82e23a8..7c71db3ac23d 100644
@@ -130,6 +130,11 @@ int x509_check_for_self_signed(struct x509_certificate *cert)
 			goto out;
 	}
 
+	if (cert->unsupported_sig) {
+		ret = 0;
+		goto out;
+	}
+
 	ret = public_key_verify_signature(cert->pub, cert->sig);
 	if (ret < 0) {
 		if (ret == -ENOPKG) {
Signature · 1 line
2.41.0

Should have:

Fixes 6c2dc5ae4ab7 ("X.509: Extract signature digest and make self-signed cert checks earlier")

BR, Jarkko

#2 lore raw
Quoted 40 lines · Jarkko Sakkinen
Quoted 36 lines · Thore Sommer

When the hash algorithm for the signature is not available the digest size is 0 and the signature in the certificate is marked as unsupported.

When validating a self-signed certificate, this needs to be checked, because otherwise trying to validate the signature will fail with an warning:

Loading compiled-in X.509 certificates

WARNING: CPU: 0 PID: 1 at crypto/rsa-pkcs1pad.c:537 \
pkcs1pad_verify+0x46/0x12c

...
Problem loading in-kernel X.509 certificate (-22)

---
  crypto/asymmetric_keys/x509_public_key.c | 5 +++++
  1 file changed, 5 insertions(+)
crypto/asymmetric_keys/x509_public_key.c +5 -0
index 6fdfc82e23a8..7c71db3ac23d 100644
@@ -130,6 +130,11 @@ int x509_check_for_self_signed(struct x509_certificate *cert)
  			goto out;
  	}
 
+	if (cert->unsupported_sig) {
+		ret = 0;
+		goto out;
+	}
+
  	ret = public_key_verify_signature(cert->pub, cert->sig);
  	if (ret < 0) {
  		if (ret == -ENOPKG) {
Signature · 1 line
2.41.0

Should have:

Quoted 4 lines
Fixes 6c2dc5ae4ab7 ("X.509: Extract signature digest and make self-signed cert checks earlier")

BR, Jarkko

Hi Jarkko,

should I resend it with the stable mailing list in CC or will it be added when a maintainer includes the change?

Best regards,
Thore

maintainer
#3 lore raw
Quoted 44 lines · Thore Sommer
Quoted 43 lines · Jarkko Sakkinen
Quoted 36 lines · Thore Sommer

When the hash algorithm for the signature is not available the digest size is 0 and the signature in the certificate is marked as unsupported.

When validating a self-signed certificate, this needs to be checked, because otherwise trying to validate the signature will fail with an warning:

Loading compiled-in X.509 certificates

WARNING: CPU: 0 PID: 1 at crypto/rsa-pkcs1pad.c:537 \
pkcs1pad_verify+0x46/0x12c

...
Problem loading in-kernel X.509 certificate (-22)

---
  crypto/asymmetric_keys/x509_public_key.c | 5 +++++
  1 file changed, 5 insertions(+)
crypto/asymmetric_keys/x509_public_key.c +5 -0
index 6fdfc82e23a8..7c71db3ac23d 100644
@@ -130,6 +130,11 @@ int x509_check_for_self_signed(struct x509_certificate *cert)
  			goto out;
  	}
 
+	if (cert->unsupported_sig) {
+		ret = 0;
+		goto out;
+	}
+
  	ret = public_key_verify_signature(cert->pub, cert->sig);
  	if (ret < 0) {
  		if (ret == -ENOPKG) {
Signature · 1 line
2.41.0

Should have:

Fixes 6c2dc5ae4ab7 ("X.509: Extract signature digest and make self-signed cert checks earlier")
Quoted 6 lines
Quoted 1 line

BR, Jarkko

Hi Jarkko,

should I resend it with the stable mailing list in CC or will it be added when a maintainer includes the change?

AFAIK the correct tags, and automation takes care of the rest.

If there is a merge conflict to some stable branch, the bots will call back to you :-)

BR, Jarkko

maintainer
#4 lore raw
In reply to Thore Sommer
Quoted 10 lines · Thore Sommer

When the hash algorithm for the signature is not available the digest size is 0 and the signature in the certificate is marked as unsupported.

When validating a self-signed certificate, this needs to be checked, because otherwise trying to validate the signature will fail with an warning:

Loading compiled-in X.509 certificates

WARNING: CPU: 0 PID: 1 at crypto/rsa-pkcs1pad.c:537 \
pkcs1pad_verify+0x46/0x12c
Quoted 7 lines

...
Problem loading in-kernel X.509 certificate (-22)

---
 crypto/asymmetric_keys/x509_public_key.c | 5 +++++
 1 file changed, 5 insertions(+)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt