certs: Reference revocation list for all keyrings
authorEric Snowberg <eric.snowberg@oracle.com>
Thu, 17 Aug 2023 14:04:07 +0000 (10:04 -0400)
committerJarkko Sakkinen <jarkko@kernel.org>
Thu, 17 Aug 2023 20:12:41 +0000 (20:12 +0000)
Systems booted with shim have a Forbidden Signature Database called mokx.
During boot, hashes and certs contained within the mokx are loaded into the
blacklist keyring.  When calling verify_pkcs7_message_sig the contents of
the blacklist keyring (or revocation list) are referenced when validating
keys on the platform keyring. Currently, when validating against the
secondary or builtin keyrings, the revocation list is not referenced.  Move
up the check to allow the revocation list to be used with all keyrings,
including the secondary and builtin, allowing the system owner to take
corrective action should a vulnerability be found within keys contained
within either keyring.

Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
certs/system_keyring.c

index 33841c91f12cc88d12080b39636d539e57b1014f..9de610bf1f4b2854e38b8482e16113d0008295f9 100644 (file)
@@ -330,6 +330,12 @@ int verify_pkcs7_message_sig(const void *data, size_t len,
        if (ret < 0)
                goto error;
 
+       ret = is_key_on_revocation_list(pkcs7);
+       if (ret != -ENOKEY) {
+               pr_devel("PKCS#7 key is on revocation list\n");
+               goto error;
+       }
+
        if (!trusted_keys) {
                trusted_keys = builtin_trusted_keys;
        } else if (trusted_keys == VERIFY_USE_SECONDARY_KEYRING) {
@@ -349,12 +355,6 @@ int verify_pkcs7_message_sig(const void *data, size_t len,
                        pr_devel("PKCS#7 platform keyring is not available\n");
                        goto error;
                }
-
-               ret = is_key_on_revocation_list(pkcs7);
-               if (ret != -ENOKEY) {
-                       pr_devel("PKCS#7 platform key is on revocation list\n");
-                       goto error;
-               }
        }
        ret = pkcs7_validate_trust(pkcs7, trusted_keys);
        if (ret < 0) {