Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

keys: Provide the original description to the key preparser

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

+3
+1
include/linux/key-type.h
··· 29 29 * clear the contents. 30 30 */ 31 31 struct key_preparsed_payload { 32 + const char *orig_description; /* Actual or proposed description (maybe NULL) */ 32 33 char *description; /* Proposed key description (or NULL) */ 33 34 union key_payload payload; /* Proposed payload */ 34 35 const void *data; /* Raw data */
+2
security/keys/key.c
··· 504 504 int ret; 505 505 506 506 memset(&prep, 0, sizeof(prep)); 507 + prep.orig_description = key->description; 507 508 prep.data = data; 508 509 prep.datalen = datalen; 509 510 prep.quotalen = key->type->def_datalen; ··· 855 854 goto error_put_type; 856 855 857 856 memset(&prep, 0, sizeof(prep)); 857 + prep.orig_description = description; 858 858 prep.data = payload; 859 859 prep.datalen = plen; 860 860 prep.quotalen = index_key.type->def_datalen;