summaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorCasey Schaufler <casey@schaufler-ca.com>2020-12-22 15:34:24 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-12-30 11:54:02 +0100
commit8f939abd8119564c1df3d9d16534879796f063c1 (patch)
tree89fd42d69b44376e19dca748b4b6e0897b5d7c46 /security
parentb2ec2b12a45009e1801ea7b60bc644628d4ddee2 (diff)
downloadlinux-stable-8f939abd8119564c1df3d9d16534879796f063c1.tar.gz
linux-stable-8f939abd8119564c1df3d9d16534879796f063c1.tar.bz2
linux-stable-8f939abd8119564c1df3d9d16534879796f063c1.zip
Smack: Handle io_uring kernel thread privileges
[ Upstream commit 942cb357ae7d9249088e3687ee6a00ed2745a0c7 ] Smack assumes that kernel threads are privileged for smackfs operations. This was necessary because the credential of the kernel thread was not related to a user operation. With io_uring the credential does reflect a user's rights and can be used. Suggested-by: Jens Axboe <axboe@kernel.dk> Acked-by: Jens Axboe <axboe@kernel.dk> Acked-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Casey Schaufler <casey@schaufler-ca.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'security')
-rw-r--r--security/smack/smack_access.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/security/smack/smack_access.c b/security/smack/smack_access.c
index efe2406a3960..7eabb448acab 100644
--- a/security/smack/smack_access.c
+++ b/security/smack/smack_access.c
@@ -688,9 +688,10 @@ bool smack_privileged_cred(int cap, const struct cred *cred)
bool smack_privileged(int cap)
{
/*
- * All kernel tasks are privileged
+ * Kernel threads may not have credentials we can use.
+ * The io_uring kernel threads do have reliable credentials.
*/
- if (unlikely(current->flags & PF_KTHREAD))
+ if ((current->flags & (PF_KTHREAD | PF_IO_WORKER)) == PF_KTHREAD)
return true;
return smack_privileged_cred(cap, current_cred());