diff options
Diffstat (limited to 'security/keys/keyring.c')
-rw-r--r-- | security/keys/keyring.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/security/keys/keyring.c b/security/keys/keyring.c index dd7cd0f8e13c..2fb2bc9712ae 100644 --- a/security/keys/keyring.c +++ b/security/keys/keyring.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/seq_file.h> | 17 | #include <linux/seq_file.h> |
18 | #include <linux/err.h> | 18 | #include <linux/err.h> |
19 | #include <keys/keyring-type.h> | 19 | #include <keys/keyring-type.h> |
20 | #include <asm/uaccess.h> | 20 | #include <linux/uaccess.h> |
21 | #include "internal.h" | 21 | #include "internal.h" |
22 | 22 | ||
23 | /* | 23 | /* |
@@ -39,7 +39,7 @@ static inline unsigned keyring_hash(const char *desc) | |||
39 | unsigned bucket = 0; | 39 | unsigned bucket = 0; |
40 | 40 | ||
41 | for (; *desc; desc++) | 41 | for (; *desc; desc++) |
42 | bucket += (unsigned char) *desc; | 42 | bucket += (unsigned char)*desc; |
43 | 43 | ||
44 | return bucket & (KEYRING_NAME_HASH_SIZE - 1); | 44 | return bucket & (KEYRING_NAME_HASH_SIZE - 1); |
45 | } | 45 | } |
@@ -170,12 +170,10 @@ static void keyring_describe(const struct key *keyring, struct seq_file *m) | |||
170 | { | 170 | { |
171 | struct keyring_list *klist; | 171 | struct keyring_list *klist; |
172 | 172 | ||
173 | if (keyring->description) { | 173 | if (keyring->description) |
174 | seq_puts(m, keyring->description); | 174 | seq_puts(m, keyring->description); |
175 | } | 175 | else |
176 | else { | ||
177 | seq_puts(m, "[anon]"); | 176 | seq_puts(m, "[anon]"); |
178 | } | ||
179 | 177 | ||
180 | rcu_read_lock(); | 178 | rcu_read_lock(); |
181 | klist = rcu_dereference(keyring->payload.subscriptions); | 179 | klist = rcu_dereference(keyring->payload.subscriptions); |
@@ -237,7 +235,7 @@ static long keyring_read(const struct key *keyring, | |||
237 | ret = qty; | 235 | ret = qty; |
238 | } | 236 | } |
239 | 237 | ||
240 | error: | 238 | error: |
241 | return ret; | 239 | return ret; |
242 | 240 | ||
243 | } /* end keyring_read() */ | 241 | } /* end keyring_read() */ |
@@ -306,7 +304,7 @@ key_ref_t keyring_search_aux(key_ref_t keyring_ref, | |||
306 | key_check(keyring); | 304 | key_check(keyring); |
307 | 305 | ||
308 | /* top keyring must have search permission to begin the search */ | 306 | /* top keyring must have search permission to begin the search */ |
309 | err = key_task_permission(keyring_ref, cred, KEY_SEARCH); | 307 | err = key_task_permission(keyring_ref, cred, KEY_SEARCH); |
310 | if (err < 0) { | 308 | if (err < 0) { |
311 | key_ref = ERR_PTR(err); | 309 | key_ref = ERR_PTR(err); |
312 | goto error; | 310 | goto error; |
@@ -508,7 +506,7 @@ key_ref_t __keyring_search_one(key_ref_t keyring_ref, | |||
508 | rcu_read_unlock(); | 506 | rcu_read_unlock(); |
509 | return ERR_PTR(-ENOKEY); | 507 | return ERR_PTR(-ENOKEY); |
510 | 508 | ||
511 | found: | 509 | found: |
512 | atomic_inc(&key->usage); | 510 | atomic_inc(&key->usage); |
513 | rcu_read_unlock(); | 511 | rcu_read_unlock(); |
514 | return make_key_ref(key, possessed); | 512 | return make_key_ref(key, possessed); |
@@ -565,7 +563,7 @@ struct key *find_keyring_by_name(const char *name, bool skip_perm_check) | |||
565 | read_unlock(&keyring_name_lock); | 563 | read_unlock(&keyring_name_lock); |
566 | keyring = ERR_PTR(-ENOKEY); | 564 | keyring = ERR_PTR(-ENOKEY); |
567 | 565 | ||
568 | error: | 566 | error: |
569 | return keyring; | 567 | return keyring; |
570 | 568 | ||
571 | } /* end find_keyring_by_name() */ | 569 | } /* end find_keyring_by_name() */ |
@@ -598,7 +596,7 @@ static int keyring_detect_cycle(struct key *A, struct key *B) | |||
598 | sp = 0; | 596 | sp = 0; |
599 | 597 | ||
600 | /* start processing a new keyring */ | 598 | /* start processing a new keyring */ |
601 | descend: | 599 | descend: |
602 | if (test_bit(KEY_FLAG_REVOKED, &subtree->flags)) | 600 | if (test_bit(KEY_FLAG_REVOKED, &subtree->flags)) |
603 | goto not_this_keyring; | 601 | goto not_this_keyring; |
604 | 602 | ||
@@ -607,7 +605,7 @@ static int keyring_detect_cycle(struct key *A, struct key *B) | |||
607 | goto not_this_keyring; | 605 | goto not_this_keyring; |
608 | kix = 0; | 606 | kix = 0; |
609 | 607 | ||
610 | ascend: | 608 | ascend: |
611 | /* iterate through the remaining keys in this keyring */ | 609 | /* iterate through the remaining keys in this keyring */ |
612 | for (; kix < keylist->nkeys; kix++) { | 610 | for (; kix < keylist->nkeys; kix++) { |
613 | key = keylist->keys[kix]; | 611 | key = keylist->keys[kix]; |
@@ -633,7 +631,7 @@ static int keyring_detect_cycle(struct key *A, struct key *B) | |||
633 | 631 | ||
634 | /* the keyring we're looking at was disqualified or didn't contain a | 632 | /* the keyring we're looking at was disqualified or didn't contain a |
635 | * matching key */ | 633 | * matching key */ |
636 | not_this_keyring: | 634 | not_this_keyring: |
637 | if (sp > 0) { | 635 | if (sp > 0) { |
638 | /* resume the checking of a keyring higher up in the tree */ | 636 | /* resume the checking of a keyring higher up in the tree */ |
639 | sp--; | 637 | sp--; |
@@ -644,15 +642,15 @@ static int keyring_detect_cycle(struct key *A, struct key *B) | |||
644 | 642 | ||
645 | ret = 0; /* no cycles detected */ | 643 | ret = 0; /* no cycles detected */ |
646 | 644 | ||
647 | error: | 645 | error: |
648 | rcu_read_unlock(); | 646 | rcu_read_unlock(); |
649 | return ret; | 647 | return ret; |
650 | 648 | ||
651 | too_deep: | 649 | too_deep: |
652 | ret = -ELOOP; | 650 | ret = -ELOOP; |
653 | goto error; | 651 | goto error; |
654 | 652 | ||
655 | cycle_detected: | 653 | cycle_detected: |
656 | ret = -EDEADLK; | 654 | ret = -EDEADLK; |
657 | goto error; | 655 | goto error; |
658 | 656 | ||
@@ -775,8 +773,7 @@ int __key_link(struct key *keyring, struct key *key) | |||
775 | smp_wmb(); | 773 | smp_wmb(); |
776 | klist->nkeys++; | 774 | klist->nkeys++; |
777 | smp_wmb(); | 775 | smp_wmb(); |
778 | } | 776 | } else { |
779 | else { | ||
780 | /* grow the key list */ | 777 | /* grow the key list */ |
781 | max = 4; | 778 | max = 4; |
782 | if (klist) | 779 | if (klist) |