[PATCH 4/7] keys: Add a key_ref_get() wrapper

David Howells dhowells at redhat.com
Wed Aug 21 12:36:12 UTC 2024


Add a key_ref_get() wrapper function to go with key_ref_put() and use it
for the place that needs it.

Signed-off-by: David Howells <dhowells at redhat.com>
cc: Jarkko Sakkinen <jarkko at kernel.org>
cc: keyrings at vger.kernel.org
cc: linux-security-module at vger.kernel.org
---
 include/linux/key.h     | 5 +++++
 security/keys/keyring.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/linux/key.h b/include/linux/key.h
index 08062b4f807c..50a19e5f9e45 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -315,6 +315,11 @@ static inline void key_ref_put(key_ref_t key_ref)
 	key_put(key_ref_to_ptr(key_ref));
 }
 
+static inline void key_ref_get(key_ref_t key_ref)
+{
+	key_get(key_ref_to_ptr(key_ref));
+}
+
 extern struct key *request_key_tag(struct key_type *type,
 				   const char *description,
 				   struct key_tag *domain_tag,
diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index 0eed018448cb..7f02b913c560 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -920,7 +920,7 @@ key_ref_t keyring_search_rcu(key_ref_t keyring_ref,
 
 	ctx->now = ktime_get_real_seconds();
 	if (search_nested_keyrings(keyring, ctx))
-		__key_get(key_ref_to_ptr(ctx->result));
+		key_ref_get(ctx->result);
 	return ctx->result;
 }
 




More information about the Linux-security-module-archive mailing list