aboutsummaryrefslogtreecommitdiffstats
path: root/security/keys/request_key.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2013-09-24 05:35:15 -0400
committerDavid Howells <dhowells@redhat.com>2013-09-24 05:35:15 -0400
commit16feef4340172b7dbb9cba60850e78fa6388adf1 (patch)
tree192d76bb3ba75b99c4a4746e2d47996b92b46e39 /security/keys/request_key.c
parent7e55ca6dcd07b45619035df343c9614a3ab35034 (diff)
KEYS: Consolidate the concept of an 'index key' for key access
Consolidate the concept of an 'index key' for accessing keys. The index key is the search term needed to find a key directly - basically the key type and the key description. We can add to that the description length. This will be useful when turning a keyring into an associative array rather than just a pointer block. Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'security/keys/request_key.c')
-rw-r--r--security/keys/request_key.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/security/keys/request_key.c b/security/keys/request_key.c
index 172115b38054..586cb79ee82d 100644
--- a/security/keys/request_key.c
+++ b/security/keys/request_key.c
@@ -352,6 +352,11 @@ static int construct_alloc_key(struct key_type *type,
352 struct key_user *user, 352 struct key_user *user,
353 struct key **_key) 353 struct key **_key)
354{ 354{
355 const struct keyring_index_key index_key = {
356 .type = type,
357 .description = description,
358 .desc_len = strlen(description),
359 };
355 const struct cred *cred = current_cred(); 360 const struct cred *cred = current_cred();
356 unsigned long prealloc; 361 unsigned long prealloc;
357 struct key *key; 362 struct key *key;
@@ -379,8 +384,7 @@ static int construct_alloc_key(struct key_type *type,
379 set_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags); 384 set_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags);
380 385
381 if (dest_keyring) { 386 if (dest_keyring) {
382 ret = __key_link_begin(dest_keyring, type, description, 387 ret = __key_link_begin(dest_keyring, &index_key, &prealloc);
383 &prealloc);
384 if (ret < 0) 388 if (ret < 0)
385 goto link_prealloc_failed; 389 goto link_prealloc_failed;
386 } 390 }
@@ -400,7 +404,7 @@ static int construct_alloc_key(struct key_type *type,
400 404
401 mutex_unlock(&key_construction_mutex); 405 mutex_unlock(&key_construction_mutex);
402 if (dest_keyring) 406 if (dest_keyring)
403 __key_link_end(dest_keyring, type, prealloc); 407 __key_link_end(dest_keyring, &index_key, prealloc);
404 mutex_unlock(&user->cons_lock); 408 mutex_unlock(&user->cons_lock);
405 *_key = key; 409 *_key = key;
406 kleave(" = 0 [%d]", key_serial(key)); 410 kleave(" = 0 [%d]", key_serial(key));
@@ -416,7 +420,7 @@ key_already_present:
416 ret = __key_link_check_live_key(dest_keyring, key); 420 ret = __key_link_check_live_key(dest_keyring, key);
417 if (ret == 0) 421 if (ret == 0)
418 __key_link(dest_keyring, key, &prealloc); 422 __key_link(dest_keyring, key, &prealloc);
419 __key_link_end(dest_keyring, type, prealloc); 423 __key_link_end(dest_keyring, &index_key, prealloc);
420 if (ret < 0) 424 if (ret < 0)
421 goto link_check_failed; 425 goto link_check_failed;
422 } 426 }