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

keys: Implement update for the big_key type

Implement the ->update op for the big_key type.

Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Jason A. Donenfeld <Jason@zx2c4.com>

+19 -1
+1
include/keys/big_key-type.h
··· 18 18 extern void big_key_destroy(struct key *key); 19 19 extern void big_key_describe(const struct key *big_key, struct seq_file *m); 20 20 extern long big_key_read(const struct key *key, char *buffer, size_t buflen); 21 + extern int big_key_update(struct key *key, struct key_preparsed_payload *prep); 21 22 22 23 #endif /* _KEYS_BIG_KEY_TYPE_H */
+18 -1
security/keys/big_key.c
··· 47 47 .destroy = big_key_destroy, 48 48 .describe = big_key_describe, 49 49 .read = big_key_read, 50 - /* no ->update(); don't add it without changing chacha20poly1305's nonce */ 50 + .update = big_key_update, 51 51 }; 52 52 53 53 /* ··· 189 189 } 190 190 kzfree(key->payload.data[big_key_data]); 191 191 key->payload.data[big_key_data] = NULL; 192 + } 193 + 194 + /* 195 + * Update a big key 196 + */ 197 + int big_key_update(struct key *key, struct key_preparsed_payload *prep) 198 + { 199 + int ret; 200 + 201 + ret = key_payload_reserve(key, prep->datalen); 202 + if (ret < 0) 203 + return ret; 204 + 205 + if (key_is_positive(key)) 206 + big_key_destroy(key); 207 + 208 + return generic_key_instantiate(key, prep); 192 209 } 193 210 194 211 /*