]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
keys: Provide the original description to the key preparser
authorDavid Howells <dhowells@redhat.com>
Wed, 16 Sep 2020 10:12:03 +0000 (11:12 +0100)
committerDavid Howells <dhowells@redhat.com>
Mon, 23 Nov 2020 18:09:29 +0000 (18:09 +0000)
Provide the proposed description (add key) or the original description
(update/instantiate key) when preparsing a key so that the key type can
validate it against the data.

This is important for rxrpc server keys as we need to check that they have
the right amount of key material present - and it's better to do that when
the key is loaded rather than deep in trying to process a response packet.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
cc: keyrings@vger.kernel.org

include/linux/key-type.h
security/keys/key.c

index 2ab2d6d6aeab857a5e6175bd413a473d2e21515f..7d985a1dfe4af9e4fa38122260f44cfe336b206e 100644 (file)
@@ -29,6 +29,7 @@ struct kernel_pkey_params;
  * clear the contents.
  */
 struct key_preparsed_payload {
+       const char      *orig_description; /* Actual or proposed description (maybe NULL) */
        char            *description;   /* Proposed key description (or NULL) */
        union key_payload payload;      /* Proposed payload */
        const void      *data;          /* Raw data */
index e282c6179b21d5753a289dee2509a140558e9b98..ebe752b137aa1149615a0395b31f769d6ff59eac 100644 (file)
@@ -504,6 +504,7 @@ int key_instantiate_and_link(struct key *key,
        int ret;
 
        memset(&prep, 0, sizeof(prep));
+       prep.orig_description = key->description;
        prep.data = data;
        prep.datalen = datalen;
        prep.quotalen = key->type->def_datalen;
@@ -854,6 +855,7 @@ key_ref_t key_create_or_update(key_ref_t keyring_ref,
                goto error_put_type;
 
        memset(&prep, 0, sizeof(prep));
+       prep.orig_description = description;
        prep.data = payload;
        prep.datalen = plen;
        prep.quotalen = index_key.type->def_datalen;