diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-01-02 13:56:09 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-01-02 13:56:09 -0500 |
commit | 19f2e267a5d0d26282a64f8f788c482852c95324 (patch) | |
tree | db0923d0693e15f942c05c7d8ffbeda83ad362a4 /security | |
parent | 1ac5cd4978794bd060d448acc0305e9fc996ba92 (diff) | |
parent | 20bb4cb4fb9fb994d757932abc4404cf0f0f56cc (diff) |
Merge branch 'next-smack' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
Pull smack updates from James Morris:
"Two Smack patches for 4.21.
Jose's patch adds missing documentation and Zoran's fleshes out the
access checks on keyrings"
* 'next-smack' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security:
Smack: Improve Documentation
smack: fix access permissions for keyring
Diffstat (limited to 'security')
-rw-r--r-- | security/smack/smack_lsm.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index 81fb4c1631e9..cd720c06b78c 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c | |||
@@ -4333,6 +4333,12 @@ static int smack_key_permission(key_ref_t key_ref, | |||
4333 | int request = 0; | 4333 | int request = 0; |
4334 | int rc; | 4334 | int rc; |
4335 | 4335 | ||
4336 | /* | ||
4337 | * Validate requested permissions | ||
4338 | */ | ||
4339 | if (perm & ~KEY_NEED_ALL) | ||
4340 | return -EINVAL; | ||
4341 | |||
4336 | keyp = key_ref_to_ptr(key_ref); | 4342 | keyp = key_ref_to_ptr(key_ref); |
4337 | if (keyp == NULL) | 4343 | if (keyp == NULL) |
4338 | return -EINVAL; | 4344 | return -EINVAL; |
@@ -4356,10 +4362,10 @@ static int smack_key_permission(key_ref_t key_ref, | |||
4356 | ad.a.u.key_struct.key = keyp->serial; | 4362 | ad.a.u.key_struct.key = keyp->serial; |
4357 | ad.a.u.key_struct.key_desc = keyp->description; | 4363 | ad.a.u.key_struct.key_desc = keyp->description; |
4358 | #endif | 4364 | #endif |
4359 | if (perm & KEY_NEED_READ) | 4365 | if (perm & (KEY_NEED_READ | KEY_NEED_SEARCH | KEY_NEED_VIEW)) |
4360 | request = MAY_READ; | 4366 | request |= MAY_READ; |
4361 | if (perm & (KEY_NEED_WRITE | KEY_NEED_LINK | KEY_NEED_SETATTR)) | 4367 | if (perm & (KEY_NEED_WRITE | KEY_NEED_LINK | KEY_NEED_SETATTR)) |
4362 | request = MAY_WRITE; | 4368 | request |= MAY_WRITE; |
4363 | rc = smk_access(tkp, keyp->security, request, &ad); | 4369 | rc = smk_access(tkp, keyp->security, request, &ad); |
4364 | rc = smk_bu_note("key access", tkp, keyp->security, request, rc); | 4370 | rc = smk_bu_note("key access", tkp, keyp->security, request, rc); |
4365 | return rc; | 4371 | return rc; |