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@xxxxxxxxxx> --- include/linux/key.h | 2 ++ security/keys/keyring.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) 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) -- 2.39.2