diff mbox series

[RFC,1/5] keys: export keyring_ptr_to_key()

Message ID 20230420202004.239116-2-smayhew@redhat.com (mailing list archive)
State New
Headers show
Series SUNRPC: Add option to store GSS credentials in | expand

Commit Message

Scott Mayhew April 20, 2023, 8:20 p.m. UTC
We want to be able to garbage collect keyrings using a custom select
iterator, which will need to use keyring_ptr_to_key().

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
---
 include/linux/key.h     | 2 ++
 security/keys/keyring.c | 5 ++++-
 2 files changed, 6 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/include/linux/key.h b/include/linux/key.h
index 8dc7f7c3088b..3f4c6d6df921 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -417,6 +417,8 @@  extern int key_move(struct key *key,
 extern int key_unlink(struct key *keyring,
 		      struct key *key);
 
+extern inline struct key *keyring_ptr_to_key(const struct assoc_array_ptr *x);
+
 extern struct key *keyring_alloc(const char *description, kuid_t uid, kgid_t gid,
 				 const struct cred *cred,
 				 key_perm_t perm,
diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index 4448758f643a..c57f3cef32fa 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -37,11 +37,14 @@  static inline bool keyring_ptr_is_keyring(const struct assoc_array_ptr *x)
 {
 	return (unsigned long)x & KEYRING_PTR_SUBTYPE;
 }
-static inline struct key *keyring_ptr_to_key(const struct assoc_array_ptr *x)
+
+inline struct key *keyring_ptr_to_key(const struct assoc_array_ptr *x)
 {
 	void *object = assoc_array_ptr_to_leaf(x);
 	return (struct key *)((unsigned long)object & ~KEYRING_PTR_SUBTYPE);
 }
+EXPORT_SYMBOL_GPL(keyring_ptr_to_key);
+
 static inline void *keyring_key_to_ptr(struct key *key)
 {
 	if (key->type == &key_type_keyring)