aboutsummaryrefslogtreecommitdiffstats
path: root/security/keys/key.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/keys/key.c')
-rw-r--r--security/keys/key.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/security/keys/key.c b/security/keys/key.c
index 654d23baf352..d98c61953be6 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -757,11 +757,11 @@ key_ref_t key_create_or_update(key_ref_t keyring_ref,
757 const char *description, 757 const char *description,
758 const void *payload, 758 const void *payload,
759 size_t plen, 759 size_t plen,
760 key_perm_t perm,
760 unsigned long flags) 761 unsigned long flags)
761{ 762{
762 struct key_type *ktype; 763 struct key_type *ktype;
763 struct key *keyring, *key = NULL; 764 struct key *keyring, *key = NULL;
764 key_perm_t perm;
765 key_ref_t key_ref; 765 key_ref_t key_ref;
766 int ret; 766 int ret;
767 767
@@ -806,15 +806,17 @@ key_ref_t key_create_or_update(key_ref_t keyring_ref,
806 goto found_matching_key; 806 goto found_matching_key;
807 } 807 }
808 808
809 /* decide on the permissions we want */ 809 /* if the client doesn't provide, decide on the permissions we want */
810 perm = KEY_POS_VIEW | KEY_POS_SEARCH | KEY_POS_LINK | KEY_POS_SETATTR; 810 if (perm == KEY_PERM_UNDEF) {
811 perm |= KEY_USR_VIEW | KEY_USR_SEARCH | KEY_USR_LINK | KEY_USR_SETATTR; 811 perm = KEY_POS_VIEW | KEY_POS_SEARCH | KEY_POS_LINK | KEY_POS_SETATTR;
812 perm |= KEY_USR_VIEW | KEY_USR_SEARCH | KEY_USR_LINK | KEY_USR_SETATTR;
812 813
813 if (ktype->read) 814 if (ktype->read)
814 perm |= KEY_POS_READ | KEY_USR_READ; 815 perm |= KEY_POS_READ | KEY_USR_READ;
815 816
816 if (ktype == &key_type_keyring || ktype->update) 817 if (ktype == &key_type_keyring || ktype->update)
817 perm |= KEY_USR_WRITE; 818 perm |= KEY_USR_WRITE;
819 }
818 820
819 /* allocate a new key */ 821 /* allocate a new key */
820 key = key_alloc(ktype, description, current->fsuid, current->fsgid, 822 key = key_alloc(ktype, description, current->fsuid, current->fsgid,