summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Kasatkin <d.kasatkin@samsung.com>2014-03-14 17:44:49 +0000
committerStephane Desneux <stephane.desneux@open.eurogiciel.org>2015-02-04 11:23:18 +0100
commit4077bbc2c5ee873a67f808b4a0ca06213e4ed570 (patch)
tree21f5ac086e733d5d118256d7d691856b1c1292c6
parent6612de0cca37ebc4dfd7a30bbec75d4bc9bf2765 (diff)
downloadkernel-common-4077bbc2c5ee873a67f808b4a0ca06213e4ed570.tar.gz
kernel-common-4077bbc2c5ee873a67f808b4a0ca06213e4ed570.tar.bz2
kernel-common-4077bbc2c5ee873a67f808b4a0ca06213e4ed570.zip
smack: fix key permission verification
For any keyring access type SMACK always used MAY_READWRITE access check. It prevents reading the key with label "_", which should be allowed for anyone. This patch changes default access check to MAY_READ and use MAY_READWRITE in only appropriate cases. Change-Id: Ie357956730df93058198e2df13ef307ce4e8f675 Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com> Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Casey Schaufler <casey@schaufler-ca.com> Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
-rw-r--r--security/smack/smack_lsm.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index eabb97ff6c61..c972a71c8d7f 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -3519,6 +3519,7 @@ static int smack_key_permission(key_ref_t key_ref,
struct key *keyp;
struct smk_audit_info ad;
struct smack_known *tkp = smk_of_task(cred->security);
+ int request = 0;
keyp = key_ref_to_ptr(key_ref);
if (keyp == NULL)
@@ -3539,7 +3540,11 @@ static int smack_key_permission(key_ref_t key_ref,
ad.a.u.key_struct.key = keyp->serial;
ad.a.u.key_struct.key_desc = keyp->description;
#endif
- return smk_access(tkp, keyp->security, MAY_READWRITE, &ad);
+ if (perm & KEY_NEED_READ)
+ request = MAY_READ;
+ if (perm & (KEY_NEED_WRITE | KEY_NEED_LINK | KEY_NEED_SETATTR))
+ request = MAY_WRITE;
+ return smk_access(tkp, keyp->security, request, &ad);
}
#endif /* CONFIG_KEYS */