@@ -433,6 +433,10 @@ extern int restrict_link_reject(struct key *keyring,
extern int keyring_clear(struct key *keyring);
+extern void keyring_gc_custom(struct key *keyring,
+ bool (*iterator)(void *object, void *iterator_data),
+ void *iterator_data);
+
extern key_ref_t keyring_search(key_ref_t keyring,
struct key_type *type,
const char *description,
@@ -1795,3 +1795,14 @@ void keyring_restriction_gc(struct key *keyring, struct key_type *dead_type)
kleave(" [restriction gc]");
}
+
+void keyring_gc_custom(struct key *keyring,
+ bool (*iterator)(void *object, void *iterator_data),
+ void *iterator_data)
+{
+ down_write(&keyring->sem);
+ assoc_array_gc(&keyring->keys, &keyring_assoc_array_ops,
+ iterator, iterator_data);
+ up_write(&keyring->sem);
+}
+EXPORT_SYMBOL_GPL(keyring_gc_custom);
Allow a keyring to be garbage collected using a custom select iterator. This will be used to destroy all the GSS creds for a particular RPC client when that RPC client is shut down. Signed-off-by: Scott Mayhew <smayhew@redhat.com> --- include/linux/key.h | 4 ++++ security/keys/keyring.c | 11 +++++++++++ 2 files changed, 15 insertions(+)