Skip to content

Commit 29f4a67

Browse files
ebiggersdhowells
authored andcommitted
PKCS#7: fix certificate blacklisting
If there is a blacklisted certificate in a SignerInfo's certificate chain, then pkcs7_verify_sig_chain() sets sinfo->blacklisted and returns 0. But, pkcs7_verify() fails to handle this case appropriately, as it actually continues on to the line 'actual_ret = 0;', indicating that the SignerInfo has passed verification. Consequently, PKCS#7 signature verification ignores the certificate blacklist. Fix this by not considering blacklisted SignerInfos to have passed verification. Also fix the function comment with regards to when 0 is returned. Fixes: 03bb793 ("PKCS#7: Handle blacklisted certificates") Cc: <stable@vger.kernel.org> # v4.12+ Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: David Howells <dhowells@redhat.com>
1 parent 971b42c commit 29f4a67

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

crypto/asymmetric_keys/pkcs7_verify.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,7 @@ static int pkcs7_verify_one(struct pkcs7_message *pkcs7,
366366
*
367367
* (*) -EBADMSG if some part of the message was invalid, or:
368368
*
369-
* (*) 0 if no signature chains were found to be blacklisted or to contain
370-
* unsupported crypto, or:
369+
* (*) 0 if a signature chain passed verification, or:
371370
*
372371
* (*) -EKEYREJECTED if a blacklisted key was encountered, or:
373372
*
@@ -423,8 +422,11 @@ int pkcs7_verify(struct pkcs7_message *pkcs7,
423422

424423
for (sinfo = pkcs7->signed_infos; sinfo; sinfo = sinfo->next) {
425424
ret = pkcs7_verify_one(pkcs7, sinfo);
426-
if (sinfo->blacklisted && actual_ret == -ENOPKG)
427-
actual_ret = -EKEYREJECTED;
425+
if (sinfo->blacklisted) {
426+
if (actual_ret == -ENOPKG)
427+
actual_ret = -EKEYREJECTED;
428+
continue;
429+
}
428430
if (ret < 0) {
429431
if (ret == -ENOPKG) {
430432
sinfo->unsupported_crypto = true;

0 commit comments

Comments
 (0)