Skip to content

Commit 4754620

Browse files
ebiggersdhowells
authored andcommitted
keys: Reuse keyring_index_key::desc_len in lookup_user_key()
When lookup_user_key() checks whether the key is possessed, it should use the key's existing index_key including the 'desc_len' field, rather than recomputing the 'desc_len'. This doesn't change the behavior; this way is just simpler and faster. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: James Morris <jamorris@linux.microsoft.com>
1 parent f7f1394 commit 4754620

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

‎security/keys/process_keys.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -688,9 +688,7 @@ key_ref_t lookup_user_key(key_serial_t id, unsigned long lflags,
688688
key_ref = make_key_ref(key, 0);
689689

690690
/* check to see if we possess the key */
691-
ctx.index_key.type = key->type;
692-
ctx.index_key.description = key->description;
693-
ctx.index_key.desc_len = strlen(key->description);
691+
ctx.index_key = key->index_key;
694692
ctx.match_data.raw_data = key;
695693
kdebug("check possessed");
696694
skey_ref = search_process_keyrings(&ctx);

0 commit comments

Comments
 (0)