diff options
| author | Dmitry Kasatkin <d.kasatkin@samsung.com> | 2014-03-14 13:44:49 -0400 |
|---|---|---|
| committer | David Howells <dhowells@redhat.com> | 2014-03-14 13:44:49 -0400 |
| commit | fffea214abf66a8672cfd6697fae65e743e22f11 (patch) | |
| tree | a1e7c6d02c070bf0a92c9650aee2fd7d292f4623 | |
| parent | f5895943d91b41b0368830cdb6eaffb8eda0f4c8 (diff) | |
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.
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>
| -rw-r--r-- | security/smack/smack_lsm.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index c47dd8ca019c..8177e7df8c2d 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c | |||
| @@ -3511,6 +3511,7 @@ static int smack_key_permission(key_ref_t key_ref, | |||
| 3511 | struct key *keyp; | 3511 | struct key *keyp; |
| 3512 | struct smk_audit_info ad; | 3512 | struct smk_audit_info ad; |
| 3513 | struct smack_known *tkp = smk_of_task(cred->security); | 3513 | struct smack_known *tkp = smk_of_task(cred->security); |
| 3514 | int request = 0; | ||
| 3514 | 3515 | ||
| 3515 | keyp = key_ref_to_ptr(key_ref); | 3516 | keyp = key_ref_to_ptr(key_ref); |
| 3516 | if (keyp == NULL) | 3517 | if (keyp == NULL) |
| @@ -3531,7 +3532,11 @@ static int smack_key_permission(key_ref_t key_ref, | |||
| 3531 | ad.a.u.key_struct.key = keyp->serial; | 3532 | ad.a.u.key_struct.key = keyp->serial; |
| 3532 | ad.a.u.key_struct.key_desc = keyp->description; | 3533 | ad.a.u.key_struct.key_desc = keyp->description; |
| 3533 | #endif | 3534 | #endif |
| 3534 | return smk_access(tkp, keyp->security, MAY_READWRITE, &ad); | 3535 | if (perm & KEY_NEED_READ) |
| 3536 | request = MAY_READ; | ||
| 3537 | if (perm & (KEY_NEED_WRITE | KEY_NEED_LINK | KEY_NEED_SETATTR)) | ||
| 3538 | request = MAY_WRITE; | ||
| 3539 | return smk_access(tkp, keyp->security, request, &ad); | ||
| 3535 | } | 3540 | } |
| 3536 | #endif /* CONFIG_KEYS */ | 3541 | #endif /* CONFIG_KEYS */ |
| 3537 | 3542 | ||
