All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] key: Use unique key descriptors
@ 2016-04-12 16:42 Mat Martineau
  2016-04-12 16:42 ` [PATCH 2/3] key: Add Diffie-Hellman support using keyctl Mat Martineau
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Mat Martineau @ 2016-04-12 16:42 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 1332 bytes --]

The kernel expects the key descriptor text to be unique. If a key is
added with a descriptor that matches an existing key, the existing key
is overwritten.
---
 ell/key.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/ell/key.c b/ell/key.c
index 6ec8541..f9f8b7e 100644
--- a/ell/key.c
+++ b/ell/key.c
@@ -69,7 +69,7 @@ static long kernel_revoke_key(int32_t serial)
 
 static bool setup_keyring_base(void)
 {
-	keyring_base = kernel_add_key("keyring", "ell", 0, 0,
+	keyring_base = kernel_add_key("keyring", "ell-keyring", 0, 0,
 					KEY_SPEC_THREAD_KEYRING);
 
 	if (keyring_base <= 0) {
@@ -84,6 +84,7 @@ LIB_EXPORT struct l_key *l_key_new(enum l_key_type type, const void *payload,
 					size_t payload_length)
 {
 	struct l_key *key;
+	char *description;
 
 	if (unlikely(!payload))
 		return NULL;
@@ -97,8 +98,10 @@ LIB_EXPORT struct l_key *l_key_new(enum l_key_type type, const void *payload,
 
 	key = l_new(struct l_key, 1);
 	key->type = type;
-	key->serial = kernel_add_key(key_type_names[type], "ell", payload,
+	description = l_strdup_printf("ell-%p", key);
+	key->serial = kernel_add_key(key_type_names[type], description, payload,
 					payload_length, keyring_base);
+	l_free(description);
 
 	if (key->serial < 0) {
 		l_free(key);
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-04-12 21:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-12 16:42 [PATCH 1/3] key: Use unique key descriptors Mat Martineau
2016-04-12 16:42 ` [PATCH 2/3] key: Add Diffie-Hellman support using keyctl Mat Martineau
2016-04-12 16:42 ` [PATCH 3/3] unit: Add Diffie-Hellman tests Mat Martineau
2016-04-12 19:41   ` Mat Martineau
2016-04-12 21:50 ` [PATCH 1/3] key: Use unique key descriptors Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.