Patch "X.509: fix BUG_ON() when hash algorithm is unsupported" has been added to the 4.15-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
X.509: fix BUG_ON() when hash algorithm is unsupported
to the 4.15-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
x.509-fix-bug_on-when-hash-algorithm-is-unsupported.patch
and it can be found in the queue-4.15 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
437499eea4291ae9621e8763a41df027c110a1efMon Sep 17 00:00:00 2001
From: Eric Biggers <[email protected]>
Date: Thu, 22 Feb 2018 14:38:33 +0000
Subject: X.509: fix BUG_ON() when hash algorithm is unsupported
From: Eric Biggers <[email protected]>
commit 437499eea4291ae9621e8763a41df027c110a1ef upstream.
The X.509 parser mishandles the case where the certificate's signature's hash algorithm is not available in the crypto API. In this case, x509_get_sig_params() doesn't allocate the cert->sig->digest buffer; this part seems to be intentional. However, public_key_verify_signature() is still called via x509_check_for_self_signed(), which triggers the 'BUG_ON(!sig->digest)'.
Fix this by making public_key_verify_signature() return -ENOPKG if the hash buffer has not been allocated.
Reproducer when all the CONFIG_CRYPTO_SHA512* options are disabled:
openssl req -new -sha512 -x509 -batch -nodes -outform der \
| keyctl padd asymmetric desc @s
--- crypto/asymmetric_keys/public_key.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
crypto/asymmetric_keys/public_key.c +3 -1
@@ -79,9 +79,11 @@ int public_key_verify_signature(const stBUG_ON (!pkey);BUG_ON (!sig); -BUG_ON (!sig->digest);BUG_ON (!sig->s); +if (!sig->digest) +return -ENOPKG ; + alg_name = sig->pkey_algo;if (strcmp (sig->pkey_algo,"rsa" ) ==0 ) {/* The data wangled by the RSA algorithm is typically padded
Patches currently in stable-queue which might be from [email protected] are
queue-4.15/pkcs-7-fix-certificate-blacklisting.patch queue-4.15/x.509-fix-null-dereference-when-restricting-key-with-unsupported_sig.patch queue-4.15/x.509-fix-bug_on-when-hash-algorithm-is-unsupported.patch queue-4.15/pkcs-7-fix-certificate-chain-verification.patch