Skip to contentSkip to conversation

KEYS: reuse keyring_index_key::desc_len in lookup_user_key()

PATCH RESEND In review Eric Biggers 2 participants 2 messages May 29, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 KEYS: reuse keyring_index_key::desc_len in lookup_user_key()

From: Eric Biggers <[email protected]>

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.

---
 security/keys/process_keys.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
security/keys/process_keys.c +1 -3
index f05f7125a7d5d..5492677c20b73 100644
@@ -690,9 +690,7 @@ key_ref_t lookup_user_key(key_serial_t id, unsigned long lflags,
 		key_ref = make_key_ref(key, 0);
 
 		/* check to see if we possess the key */
-		ctx.index_key.type		= key->type;
-		ctx.index_key.description	= key->description;
-		ctx.index_key.desc_len		= strlen(key->description);
+		ctx.index_key			= key->index_key;
 		ctx.match_data.raw_data		= key;
 		kdebug("check possessed");
 		skey_ref = search_process_keyrings(&ctx);
Signature · 1 line
2.22.0.rc1.257.g3120a18244-goog
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Eric Biggers

From: Eric Biggers <[email protected]>

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.

Signature · 2 lines
James Morris
<[email protected]>