From: Scott Mayhew <smayhew@redhat.com>
To: linux-nfs@vger.kernel.org, keyrings@vger.kernel.org
Subject: [RFC PATCH 2/5] keys: add keyring_gc_custom()
Date: Thu, 20 Apr 2023 16:20:01 -0400 [thread overview]
Message-ID: <20230420202004.239116-3-smayhew@redhat.com> (raw)
In-Reply-To: <20230420202004.239116-1-smayhew@redhat.com>
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(+)
diff --git a/include/linux/key.h b/include/linux/key.h
index 3f4c6d6df921..6cfc60aca505 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -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,
diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index c57f3cef32fa..8e93f1bbd7f1 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -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);
--
2.39.2
next prev parent reply other threads:[~2023-04-20 20:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-20 20:19 [RFC PATCH 0/5] SUNRPC: Add option to store GSS credentials in Scott Mayhew
2023-04-20 20:20 ` [RFC PATCH 1/5] keys: export keyring_ptr_to_key() Scott Mayhew
2023-04-20 20:20 ` Scott Mayhew [this message]
2023-04-20 20:20 ` [RFC PATCH 3/5] keys: add dest_keyring parameter to request_key_with_auxdata() Scott Mayhew
2023-04-20 20:20 ` [RFC PATCH 4/5] keys: add the ability to search user keyrings in search_cred_keyrings_rcu() Scott Mayhew
2023-04-20 20:20 ` [RFC PATCH 5/5] SUNRPC: store GSS creds in keyrings Scott Mayhew
2023-04-22 21:27 ` Ben Boeckel
2023-04-24 14:02 ` Scott Mayhew
2023-04-24 14:23 ` Ben Boeckel
2023-04-24 15:01 ` Scott Mayhew
2023-04-24 18:28 ` Ben Boeckel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230420202004.239116-3-smayhew@redhat.com \
--to=smayhew@redhat.com \
--cc=keyrings@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox