aboutsummaryrefslogtreecommitdiffstats
path: root/security/keys/keyring.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/keys/keyring.c')
-rw-r--r--security/keys/keyring.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index 37a7f3b28852..d605f75292e4 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -319,7 +319,7 @@ key_ref_t keyring_search_aux(key_ref_t keyring_ref,
319 struct key *keyring, *key; 319 struct key *keyring, *key;
320 key_ref_t key_ref; 320 key_ref_t key_ref;
321 long err; 321 long err;
322 int sp, kix; 322 int sp, nkeys, kix;
323 323
324 keyring = key_ref_to_ptr(keyring_ref); 324 keyring = key_ref_to_ptr(keyring_ref);
325 possessed = is_key_possessed(keyring_ref); 325 possessed = is_key_possessed(keyring_ref);
@@ -380,7 +380,9 @@ descend:
380 goto not_this_keyring; 380 goto not_this_keyring;
381 381
382 /* iterate through the keys in this keyring first */ 382 /* iterate through the keys in this keyring first */
383 for (kix = 0; kix < keylist->nkeys; kix++) { 383 nkeys = keylist->nkeys;
384 smp_rmb();
385 for (kix = 0; kix < nkeys; kix++) {
384 key = keylist->keys[kix]; 386 key = keylist->keys[kix];
385 kflags = key->flags; 387 kflags = key->flags;
386 388
@@ -421,7 +423,9 @@ descend:
421 /* search through the keyrings nested in this one */ 423 /* search through the keyrings nested in this one */
422 kix = 0; 424 kix = 0;
423ascend: 425ascend:
424 for (; kix < keylist->nkeys; kix++) { 426 nkeys = keylist->nkeys;
427 smp_rmb();
428 for (; kix < nkeys; kix++) {
425 key = keylist->keys[kix]; 429 key = keylist->keys[kix];
426 if (key->type != &key_type_keyring) 430 if (key->type != &key_type_keyring)
427 continue; 431 continue;
@@ -515,7 +519,7 @@ key_ref_t __keyring_search_one(key_ref_t keyring_ref,
515 struct keyring_list *klist; 519 struct keyring_list *klist;
516 unsigned long possessed; 520 unsigned long possessed;
517 struct key *keyring, *key; 521 struct key *keyring, *key;
518 int loop; 522 int nkeys, loop;
519 523
520 keyring = key_ref_to_ptr(keyring_ref); 524 keyring = key_ref_to_ptr(keyring_ref);
521 possessed = is_key_possessed(keyring_ref); 525 possessed = is_key_possessed(keyring_ref);
@@ -524,7 +528,9 @@ key_ref_t __keyring_search_one(key_ref_t keyring_ref,
524 528
525 klist = rcu_dereference(keyring->payload.subscriptions); 529 klist = rcu_dereference(keyring->payload.subscriptions);
526 if (klist) { 530 if (klist) {
527 for (loop = 0; loop < klist->nkeys; loop++) { 531 nkeys = klist->nkeys;
532 smp_rmb();
533 for (loop = 0; loop < nkeys ; loop++) {
528 key = klist->keys[loop]; 534 key = klist->keys[loop];
529 535
530 if (key->type == ktype && 536 if (key->type == ktype &&
@@ -622,7 +628,7 @@ static int keyring_detect_cycle(struct key *A, struct key *B)
622 628
623 struct keyring_list *keylist; 629 struct keyring_list *keylist;
624 struct key *subtree, *key; 630 struct key *subtree, *key;
625 int sp, kix, ret; 631 int sp, nkeys, kix, ret;
626 632
627 rcu_read_lock(); 633 rcu_read_lock();
628 634
@@ -645,7 +651,9 @@ descend:
645 651
646ascend: 652ascend:
647 /* iterate through the remaining keys in this keyring */ 653 /* iterate through the remaining keys in this keyring */
648 for (; kix < keylist->nkeys; kix++) { 654 nkeys = keylist->nkeys;
655 smp_rmb();
656 for (; kix < nkeys; kix++) {
649 key = keylist->keys[kix]; 657 key = keylist->keys[kix];
650 658
651 if (key == A) 659 if (key == A)