X-Git-Url: http://git.samba.org/samba.git/?a=blobdiff_plain;f=certs%2Fsystem_keyring.c;h=692365dee2bd44c50a095c4e97c2df15510eee83;hb=e6f0bf09f0669b3c2cd77fa906830123279a0a21;hp=2b3ad375ecc1df5d8f10c2d4c3db209df6d362db;hpb=781a5739489949fd0f32432a9da17f7ddbccf1cc;p=sfrench%2Fcifs-2.6.git diff --git a/certs/system_keyring.c b/certs/system_keyring.c index 2b3ad375ecc1..692365dee2bd 100644 --- a/certs/system_keyring.c +++ b/certs/system_keyring.c @@ -16,6 +16,7 @@ #include #include #include +#include "common.h" static struct key *builtin_trusted_keys; #ifdef CONFIG_SECONDARY_TRUSTED_KEYRING @@ -133,66 +134,14 @@ static __init int system_trusted_keyring_init(void) */ device_initcall(system_trusted_keyring_init); -static __init int load_cert(const u8 *p, const u8 *end, struct key *keyring) -{ - key_ref_t key; - size_t plen; - - while (p < end) { - /* Each cert begins with an ASN.1 SEQUENCE tag and must be more - * than 256 bytes in size. - */ - if (end - p < 4) - goto dodgy_cert; - if (p[0] != 0x30 && - p[1] != 0x82) - goto dodgy_cert; - plen = (p[2] << 8) | p[3]; - plen += 4; - if (plen > end - p) - goto dodgy_cert; - - key = key_create_or_update(make_key_ref(keyring, 1), - "asymmetric", - NULL, - p, - plen, - ((KEY_POS_ALL & ~KEY_POS_SETATTR) | - KEY_USR_VIEW | KEY_USR_READ), - KEY_ALLOC_NOT_IN_QUOTA | - KEY_ALLOC_BUILT_IN | - KEY_ALLOC_BYPASS_RESTRICTION); - if (IS_ERR(key)) { - pr_err("Problem loading in-kernel X.509 certificate (%ld)\n", - PTR_ERR(key)); - } else { - pr_notice("Loaded X.509 cert '%s'\n", - key_ref_to_ptr(key)->description); - key_ref_put(key); - } - p += plen; - } - - return 0; - -dodgy_cert: - pr_err("Problem parsing in-kernel X.509 certificate list\n"); - return 0; -} - __init int load_module_cert(struct key *keyring) { - const u8 *p, *end; - if (!IS_ENABLED(CONFIG_IMA_APPRAISE_MODSIG)) return 0; pr_notice("Loading compiled-in module X.509 certificates\n"); - p = system_certificate_list; - end = p + module_cert_size; - - return load_cert(p, end, keyring); + return load_certificate_list(system_certificate_list, module_cert_size, keyring); } /* @@ -200,7 +149,7 @@ __init int load_module_cert(struct key *keyring) */ static __init int load_system_certificate_list(void) { - const u8 *p, *end; + const u8 *p; unsigned long size; pr_notice("Loading compiled-in X.509 certificates\n"); @@ -213,8 +162,7 @@ static __init int load_system_certificate_list(void) size = system_certificate_list_size - module_cert_size; #endif - end = p + size; - return load_cert(p, end, builtin_trusted_keys); + return load_certificate_list(p, size, builtin_trusted_keys); } late_initcall(load_system_certificate_list); @@ -272,6 +220,12 @@ 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) {