[PATCH] KEYS: Make use of platform keyring for module signature verify
authorRobert Holmes <robeholmes@gmail.com>
Tue, 23 Apr 2019 07:39:29 +0000 (07:39 +0000)
committerSalvatore Bonaccorso <carnil@debian.org>
Sat, 20 Dec 2025 09:15:48 +0000 (10:15 +0100)
Bug-Debian: https://bugs.debian.org/935945
Bug-Debian: https://bugs.debian.org/1030200
Origin: https://src.fedoraproject.org/rpms/kernel/raw/master/f/KEYS-Make-use-of-platform-keyring-for-module-signature.patch
Forwarded: https://lore.kernel.org/linux-modules/qvgp2il2co4iyxkzxvcs4p2bpyilqsbfgcprtpfrsajwae2etc@3z2s2o52i3xg/t/#u

This allows a cert in DB to be used to sign modules,
in addition to certs in the MoK and built-in keyrings.

Signed-off-by: Robert Holmes <robeholmes@gmail.com>
Signed-off-by: Jeremy Cline <jcline@redhat.com>
[bwh: Forward-ported to 5.19: adjust filename]
[наб: reinstate for 6.1, re-write description]

Gbp-Pq: Topic features/all/db-mok-keyring
Gbp-Pq: Name KEYS-Make-use-of-platform-keyring-for-module-signature.patch

kernel/module/signing.c

index a2ff4242e623d5d4e87d2f3d139d8620fb937579..35a667907025b5c471c4eaaf9b6da2adcb55736c 100644 (file)
@@ -61,10 +61,17 @@ int mod_verify_sig(const void *mod, struct load_info *info)
        modlen -= sig_len + sizeof(ms);
        info->len = modlen;
 
-       return verify_pkcs7_signature(mod, modlen, mod + modlen, sig_len,
+       ret = verify_pkcs7_signature(mod, modlen, mod + modlen, sig_len,
                                      VERIFY_USE_SECONDARY_KEYRING,
                                      VERIFYING_MODULE_SIGNATURE,
                                      NULL, NULL);
+       if (ret == -ENOKEY && IS_ENABLED(CONFIG_INTEGRITY_PLATFORM_KEYRING)) {
+               ret = verify_pkcs7_signature(mod, modlen, mod + modlen, sig_len,
+                                             VERIFY_USE_PLATFORM_KEYRING,
+                                             VERIFYING_MODULE_SIGNATURE,
+                                             NULL, NULL);
+       }
+        return ret;
 }
 
 int module_sig_check(struct load_info *info, int flags)