summaryrefslogtreecommitdiffstats
path: root/security/selinux/hooks.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r--security/selinux/hooks.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index c61787b15f27..b828401dcb70 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -6481,6 +6481,7 @@ static int selinux_key_permission(key_ref_t key_ref,
6481{ 6481{
6482 struct key *key; 6482 struct key *key;
6483 struct key_security_struct *ksec; 6483 struct key_security_struct *ksec;
6484 unsigned oldstyle_perm;
6484 u32 sid; 6485 u32 sid;
6485 6486
6486 /* if no specific permissions are requested, we skip the 6487 /* if no specific permissions are requested, we skip the
@@ -6489,13 +6490,26 @@ static int selinux_key_permission(key_ref_t key_ref,
6489 if (perm == 0) 6490 if (perm == 0)
6490 return 0; 6491 return 0;
6491 6492
6493 oldstyle_perm = perm & (KEY_NEED_VIEW | KEY_NEED_READ | KEY_NEED_WRITE |
6494 KEY_NEED_SEARCH | KEY_NEED_LINK);
6495 if (perm & KEY_NEED_SETSEC)
6496 oldstyle_perm |= OLD_KEY_NEED_SETATTR;
6497 if (perm & KEY_NEED_INVAL)
6498 oldstyle_perm |= KEY_NEED_SEARCH;
6499 if (perm & KEY_NEED_REVOKE && !(perm & OLD_KEY_NEED_SETATTR))
6500 oldstyle_perm |= KEY_NEED_WRITE;
6501 if (perm & KEY_NEED_JOIN)
6502 oldstyle_perm |= KEY_NEED_SEARCH;
6503 if (perm & KEY_NEED_CLEAR)
6504 oldstyle_perm |= KEY_NEED_WRITE;
6505
6492 sid = cred_sid(cred); 6506 sid = cred_sid(cred);
6493 6507
6494 key = key_ref_to_ptr(key_ref); 6508 key = key_ref_to_ptr(key_ref);
6495 ksec = key->security; 6509 ksec = key->security;
6496 6510
6497 return avc_has_perm(&selinux_state, 6511 return avc_has_perm(&selinux_state,
6498 sid, ksec->sid, SECCLASS_KEY, perm, NULL); 6512 sid, ksec->sid, SECCLASS_KEY, oldstyle_perm, NULL);
6499} 6513}
6500 6514
6501static int selinux_key_getsecurity(struct key *key, char **_buffer) 6515static int selinux_key_getsecurity(struct key *key, char **_buffer)