Skip to content

Commit

Permalink
Smack: Handle io_uring kernel thread privileges
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Jens Axboe <[email protected]>
Acked-by: Eric W. Biederman <[email protected]>
Signed-off-by: Casey Schaufler <[email protected]>
  • Loading branch information
cschaufler committed Dec 22, 2020
1 parent 9b0072e commit 942cb35
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions security/smack/smack_access.c
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 942cb35

Please sign in to comment.