]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
X.509: if signature is unsupported skip validation
authorThore Sommer <public@thson.de>
Tue, 15 Aug 2023 11:29:42 +0000 (14:29 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Sep 2023 08:47:01 +0000 (10:47 +0200)
commit ef5b52a631f8c18353e80ccab8408b963305510c upstream.

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)

Signed-off-by: Thore Sommer <public@thson.de>
Cc: stable@vger.kernel.org # v4.7+
Fixes: 6c2dc5ae4ab7 ("X.509: Extract signature digest and make self-signed cert checks earlier")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
crypto/asymmetric_keys/x509_public_key.c

index 1bd0cf71a22d3d6033478dee96ec4f59be6f622b..e1160a7c33bccff97b7af9b28acd559c3d2a310b 100644 (file)
@@ -138,6 +138,11 @@ int x509_check_for_self_signed(struct x509_certificate *cert)
        if (strcmp(cert->pub->pkey_algo, cert->sig->pkey_algo) != 0)
                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) {