diff options
Diffstat (limited to 'security/keys/keyctl.c')
-rw-r--r-- | security/keys/keyctl.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c index 4c670ee6acf9..b7a468fabdf9 100644 --- a/security/keys/keyctl.c +++ b/security/keys/keyctl.c | |||
@@ -624,8 +624,8 @@ long keyctl_keyring_search(key_serial_t ringid, | |||
624 | 624 | ||
625 | /* link the resulting key to the destination keyring if we can */ | 625 | /* link the resulting key to the destination keyring if we can */ |
626 | if (dest_ref) { | 626 | if (dest_ref) { |
627 | ret = -EACCES; | 627 | ret = key_permission(key_ref, KEY_LINK); |
628 | if (!key_permission(key_ref, KEY_LINK)) | 628 | if (ret < 0) |
629 | goto error6; | 629 | goto error6; |
630 | 630 | ||
631 | ret = key_link(key_ref_to_ptr(dest_ref), key_ref_to_ptr(key_ref)); | 631 | ret = key_link(key_ref_to_ptr(dest_ref), key_ref_to_ptr(key_ref)); |
@@ -676,8 +676,11 @@ long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen) | |||
676 | key = key_ref_to_ptr(key_ref); | 676 | key = key_ref_to_ptr(key_ref); |
677 | 677 | ||
678 | /* see if we can read it directly */ | 678 | /* see if we can read it directly */ |
679 | if (key_permission(key_ref, KEY_READ)) | 679 | ret = key_permission(key_ref, KEY_READ); |
680 | if (ret == 0) | ||
680 | goto can_read_key; | 681 | goto can_read_key; |
682 | if (ret != -EACCES) | ||
683 | goto error; | ||
681 | 684 | ||
682 | /* we can't; see if it's searchable from this process's keyrings | 685 | /* we can't; see if it's searchable from this process's keyrings |
683 | * - we automatically take account of the fact that it may be | 686 | * - we automatically take account of the fact that it may be |
@@ -726,7 +729,7 @@ long keyctl_chown_key(key_serial_t id, uid_t uid, gid_t gid) | |||
726 | if (uid == (uid_t) -1 && gid == (gid_t) -1) | 729 | if (uid == (uid_t) -1 && gid == (gid_t) -1) |
727 | goto error; | 730 | goto error; |
728 | 731 | ||
729 | key_ref = lookup_user_key(NULL, id, 1, 1, 0); | 732 | key_ref = lookup_user_key(NULL, id, 1, 1, KEY_SETATTR); |
730 | if (IS_ERR(key_ref)) { | 733 | if (IS_ERR(key_ref)) { |
731 | ret = PTR_ERR(key_ref); | 734 | ret = PTR_ERR(key_ref); |
732 | goto error; | 735 | goto error; |
@@ -786,7 +789,7 @@ long keyctl_setperm_key(key_serial_t id, key_perm_t perm) | |||
786 | if (perm & ~(KEY_POS_ALL | KEY_USR_ALL | KEY_GRP_ALL | KEY_OTH_ALL)) | 789 | if (perm & ~(KEY_POS_ALL | KEY_USR_ALL | KEY_GRP_ALL | KEY_OTH_ALL)) |
787 | goto error; | 790 | goto error; |
788 | 791 | ||
789 | key_ref = lookup_user_key(NULL, id, 1, 1, 0); | 792 | key_ref = lookup_user_key(NULL, id, 1, 1, KEY_SETATTR); |
790 | if (IS_ERR(key_ref)) { | 793 | if (IS_ERR(key_ref)) { |
791 | ret = PTR_ERR(key_ref); | 794 | ret = PTR_ERR(key_ref); |
792 | goto error; | 795 | goto error; |