]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - certs/system_keyring.c
memory: atmel-ebi: switch to SPDX license identifiers
[linux.git] / certs / system_keyring.c
index 57be78b5fdfc30fd77b76ce29d00d4b63b12cfe4..798291177186c361ffdb6797096bdb0f219228ae 100644 (file)
@@ -99,7 +99,9 @@ static __init int system_trusted_keyring_init(void)
        builtin_trusted_keys =
                keyring_alloc(".builtin_trusted_keys",
                              KUIDT_INIT(0), KGIDT_INIT(0), current_cred(),
-                             &internal_key_acl, KEY_ALLOC_NOT_IN_QUOTA,
+                             ((KEY_POS_ALL & ~KEY_POS_SETATTR) |
+                             KEY_USR_VIEW | KEY_USR_READ | KEY_USR_SEARCH),
+                             KEY_ALLOC_NOT_IN_QUOTA,
                              NULL, NULL);
        if (IS_ERR(builtin_trusted_keys))
                panic("Can't allocate builtin trusted keyring\n");
@@ -108,7 +110,10 @@ static __init int system_trusted_keyring_init(void)
        secondary_trusted_keys =
                keyring_alloc(".secondary_trusted_keys",
                              KUIDT_INIT(0), KGIDT_INIT(0), current_cred(),
-                             &internal_writable_keyring_acl, KEY_ALLOC_NOT_IN_QUOTA,
+                             ((KEY_POS_ALL & ~KEY_POS_SETATTR) |
+                              KEY_USR_VIEW | KEY_USR_READ | KEY_USR_SEARCH |
+                              KEY_USR_WRITE),
+                             KEY_ALLOC_NOT_IN_QUOTA,
                              get_builtin_and_secondary_restriction(),
                              NULL);
        if (IS_ERR(secondary_trusted_keys))
@@ -158,7 +163,8 @@ static __init int load_system_certificate_list(void)
                                           NULL,
                                           p,
                                           plen,
-                                          &internal_key_acl,
+                                          ((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);
@@ -184,33 +190,27 @@ late_initcall(load_system_certificate_list);
 #ifdef CONFIG_SYSTEM_DATA_VERIFICATION
 
 /**
- * verify_pkcs7_signature - Verify a PKCS#7-based signature on system data.
+ * verify_pkcs7_message_sig - Verify a PKCS#7-based signature on system data.
  * @data: The data to be verified (NULL if expecting internal data).
  * @len: Size of @data.
- * @raw_pkcs7: The PKCS#7 message that is the signature.
- * @pkcs7_len: The size of @raw_pkcs7.
+ * @pkcs7: The PKCS#7 message that is the signature.
  * @trusted_keys: Trusted keys to use (NULL for builtin trusted keys only,
  *                                     (void *)1UL for all trusted keys).
  * @usage: The use to which the key is being put.
  * @view_content: Callback to gain access to content.
  * @ctx: Context for callback.
  */
-int verify_pkcs7_signature(const void *data, size_t len,
-                          const void *raw_pkcs7, size_t pkcs7_len,
-                          struct key *trusted_keys,
-                          enum key_being_used_for usage,
-                          int (*view_content)(void *ctx,
-                                              const void *data, size_t len,
-                                              size_t asn1hdrlen),
-                          void *ctx)
+int verify_pkcs7_message_sig(const void *data, size_t len,
+                            struct pkcs7_message *pkcs7,
+                            struct key *trusted_keys,
+                            enum key_being_used_for usage,
+                            int (*view_content)(void *ctx,
+                                                const void *data, size_t len,
+                                                size_t asn1hdrlen),
+                            void *ctx)
 {
-       struct pkcs7_message *pkcs7;
        int ret;
 
-       pkcs7 = pkcs7_parse_message(raw_pkcs7, pkcs7_len);
-       if (IS_ERR(pkcs7))
-               return PTR_ERR(pkcs7);
-
        /* The data should be detached - so we need to supply it. */
        if (data && pkcs7_supply_detached_data(pkcs7, data, len) < 0) {
                pr_err("PKCS#7 signature with non-detached data\n");
@@ -263,6 +263,41 @@ int verify_pkcs7_signature(const void *data, size_t len,
        }
 
 error:
+       pr_devel("<==%s() = %d\n", __func__, ret);
+       return ret;
+}
+
+/**
+ * verify_pkcs7_signature - Verify a PKCS#7-based signature on system data.
+ * @data: The data to be verified (NULL if expecting internal data).
+ * @len: Size of @data.
+ * @raw_pkcs7: The PKCS#7 message that is the signature.
+ * @pkcs7_len: The size of @raw_pkcs7.
+ * @trusted_keys: Trusted keys to use (NULL for builtin trusted keys only,
+ *                                     (void *)1UL for all trusted keys).
+ * @usage: The use to which the key is being put.
+ * @view_content: Callback to gain access to content.
+ * @ctx: Context for callback.
+ */
+int verify_pkcs7_signature(const void *data, size_t len,
+                          const void *raw_pkcs7, size_t pkcs7_len,
+                          struct key *trusted_keys,
+                          enum key_being_used_for usage,
+                          int (*view_content)(void *ctx,
+                                              const void *data, size_t len,
+                                              size_t asn1hdrlen),
+                          void *ctx)
+{
+       struct pkcs7_message *pkcs7;
+       int ret;
+
+       pkcs7 = pkcs7_parse_message(raw_pkcs7, pkcs7_len);
+       if (IS_ERR(pkcs7))
+               return PTR_ERR(pkcs7);
+
+       ret = verify_pkcs7_message_sig(data, len, pkcs7, trusted_keys, usage,
+                                      view_content, ctx);
+
        pkcs7_free_message(pkcs7);
        pr_devel("<==%s() = %d\n", __func__, ret);
        return ret;