diff options
author | David Howells <dhowells@redhat.com> | 2013-09-24 05:35:18 -0400 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2013-09-24 05:35:18 -0400 |
commit | b2a4df200d570b2c33a57e1ebfa5896e4bc81b69 (patch) | |
tree | 7fa48ae3c5ecff90d6d1f662fd91af5ddf74d56d /security/keys/request_key.c | |
parent | 3cb989501c2688cacbb7dc4b0d353faf838f53a1 (diff) |
KEYS: Expand the capacity of a keyring
Expand the capacity of a keyring to be able to hold a lot more keys by using
the previously added associative array implementation. Currently the maximum
capacity is:
(PAGE_SIZE - sizeof(header)) / sizeof(struct key *)
which, on a 64-bit system, is a little more 500. However, since this is being
used for the NFS uid mapper, we need more than that. The new implementation
gives us effectively unlimited capacity.
With some alterations, the keyutils testsuite runs successfully to completion
after this patch is applied. The alterations are because (a) keyrings that
are simply added to no longer appear ordered and (b) some of the errors have
changed a bit.
Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'security/keys/request_key.c')
-rw-r--r-- | security/keys/request_key.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/security/keys/request_key.c b/security/keys/request_key.c index ab75df4745af..df94827103d0 100644 --- a/security/keys/request_key.c +++ b/security/keys/request_key.c | |||
@@ -351,7 +351,7 @@ static int construct_alloc_key(struct keyring_search_context *ctx, | |||
351 | struct key_user *user, | 351 | struct key_user *user, |
352 | struct key **_key) | 352 | struct key **_key) |
353 | { | 353 | { |
354 | unsigned long prealloc; | 354 | struct assoc_array_edit *edit; |
355 | struct key *key; | 355 | struct key *key; |
356 | key_perm_t perm; | 356 | key_perm_t perm; |
357 | key_ref_t key_ref; | 357 | key_ref_t key_ref; |
@@ -380,7 +380,7 @@ static int construct_alloc_key(struct keyring_search_context *ctx, | |||
380 | set_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags); | 380 | set_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags); |
381 | 381 | ||
382 | if (dest_keyring) { | 382 | if (dest_keyring) { |
383 | ret = __key_link_begin(dest_keyring, &ctx->index_key, &prealloc); | 383 | ret = __key_link_begin(dest_keyring, &ctx->index_key, &edit); |
384 | if (ret < 0) | 384 | if (ret < 0) |
385 | goto link_prealloc_failed; | 385 | goto link_prealloc_failed; |
386 | } | 386 | } |
@@ -395,11 +395,11 @@ static int construct_alloc_key(struct keyring_search_context *ctx, | |||
395 | goto key_already_present; | 395 | goto key_already_present; |
396 | 396 | ||
397 | if (dest_keyring) | 397 | if (dest_keyring) |
398 | __key_link(dest_keyring, key, &prealloc); | 398 | __key_link(key, &edit); |
399 | 399 | ||
400 | mutex_unlock(&key_construction_mutex); | 400 | mutex_unlock(&key_construction_mutex); |
401 | if (dest_keyring) | 401 | if (dest_keyring) |
402 | __key_link_end(dest_keyring, &ctx->index_key, prealloc); | 402 | __key_link_end(dest_keyring, &ctx->index_key, edit); |
403 | mutex_unlock(&user->cons_lock); | 403 | mutex_unlock(&user->cons_lock); |
404 | *_key = key; | 404 | *_key = key; |
405 | kleave(" = 0 [%d]", key_serial(key)); | 405 | kleave(" = 0 [%d]", key_serial(key)); |
@@ -414,8 +414,8 @@ key_already_present: | |||
414 | if (dest_keyring) { | 414 | if (dest_keyring) { |
415 | ret = __key_link_check_live_key(dest_keyring, key); | 415 | ret = __key_link_check_live_key(dest_keyring, key); |
416 | if (ret == 0) | 416 | if (ret == 0) |
417 | __key_link(dest_keyring, key, &prealloc); | 417 | __key_link(key, &edit); |
418 | __key_link_end(dest_keyring, &ctx->index_key, prealloc); | 418 | __key_link_end(dest_keyring, &ctx->index_key, edit); |
419 | if (ret < 0) | 419 | if (ret < 0) |
420 | goto link_check_failed; | 420 | goto link_check_failed; |
421 | } | 421 | } |