linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Revert "Smack: Handle io_uring kernel thread privileges"
@ 2021-03-26  0:42 Jens Axboe
  2021-03-26 16:00 ` Casey Schaufler
  2021-05-18 17:40 ` Casey Schaufler
  0 siblings, 2 replies; 4+ messages in thread
From: Jens Axboe @ 2021-03-26  0:42 UTC (permalink / raw)
  To: Casey Schaufler; +Cc: linux-security-module, LKML

This reverts commit 942cb357ae7d9249088e3687ee6a00ed2745a0c7.

The io_uring PF_IO_WORKER threads no longer have PF_KTHREAD set, so no
need to special case them for credential checks.

Cc: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 security/smack/smack_access.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/security/smack/smack_access.c b/security/smack/smack_access.c
index 7eabb448acab..efe2406a3960 100644
--- a/security/smack/smack_access.c
+++ b/security/smack/smack_access.c
@@ -688,10 +688,9 @@ bool smack_privileged_cred(int cap, const struct cred *cred)
 bool smack_privileged(int cap)
 {
 	/*
-	 * Kernel threads may not have credentials we can use.
-	 * The io_uring kernel threads do have reliable credentials.
+	 * All kernel tasks are privileged
 	 */
-	if ((current->flags & (PF_KTHREAD | PF_IO_WORKER)) == PF_KTHREAD)
+	if (unlikely(current->flags & PF_KTHREAD))
 		return true;
 
 	return smack_privileged_cred(cap, current_cred());
-- 
2.31.0

-- 
Jens Axboe


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Revert "Smack: Handle io_uring kernel thread privileges"
  2021-03-26  0:42 [PATCH] Revert "Smack: Handle io_uring kernel thread privileges" Jens Axboe
@ 2021-03-26 16:00 ` Casey Schaufler
  2021-03-26 16:05   ` Jens Axboe
  2021-05-18 17:40 ` Casey Schaufler
  1 sibling, 1 reply; 4+ messages in thread
From: Casey Schaufler @ 2021-03-26 16:00 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-security-module, LKML, Casey Schaufler

On 3/25/2021 5:42 PM, Jens Axboe wrote:
> This reverts commit 942cb357ae7d9249088e3687ee6a00ed2745a0c7.
>
> The io_uring PF_IO_WORKER threads no longer have PF_KTHREAD set, so no
> need to special case them for credential checks.

Could you cite the commit making that change?
I wouldn't want to see this change back-ported to a kernel
that doesn't have that change as well.

>
> Cc: Casey Schaufler <casey@schaufler-ca.com>
> Signed-off-by: Jens Axboe <axboe@kernel.dk>
> ---
>  security/smack/smack_access.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/security/smack/smack_access.c b/security/smack/smack_access.c
> index 7eabb448acab..efe2406a3960 100644
> --- a/security/smack/smack_access.c
> +++ b/security/smack/smack_access.c
> @@ -688,10 +688,9 @@ bool smack_privileged_cred(int cap, const struct cred *cred)
>  bool smack_privileged(int cap)
>  {
>  	/*
> -	 * Kernel threads may not have credentials we can use.
> -	 * The io_uring kernel threads do have reliable credentials.
> +	 * All kernel tasks are privileged
>  	 */
> -	if ((current->flags & (PF_KTHREAD | PF_IO_WORKER)) == PF_KTHREAD)
> +	if (unlikely(current->flags & PF_KTHREAD))
>  		return true;
>  
>  	return smack_privileged_cred(cap, current_cred());

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Revert "Smack: Handle io_uring kernel thread privileges"
  2021-03-26 16:00 ` Casey Schaufler
@ 2021-03-26 16:05   ` Jens Axboe
  0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2021-03-26 16:05 UTC (permalink / raw)
  To: Casey Schaufler; +Cc: linux-security-module, LKML

On 3/26/21 10:00 AM, Casey Schaufler wrote:
> On 3/25/2021 5:42 PM, Jens Axboe wrote:
>> This reverts commit 942cb357ae7d9249088e3687ee6a00ed2745a0c7.
>>
>> The io_uring PF_IO_WORKER threads no longer have PF_KTHREAD set, so no
>> need to special case them for credential checks.
> 
> Could you cite the commit making that change?
> I wouldn't want to see this change back-ported to a kernel
> that doesn't have that change as well.

This is strictly 5.12+. The change came about from:

commit 3bfe6106693b6b4ba175ad1f929c4660b8f59ca8
Author: Jens Axboe <axboe@kernel.dk>
Date:   Tue Feb 16 14:15:30 2021 -0700

    io-wq: fork worker threads from original task

So don't backport it.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Revert "Smack: Handle io_uring kernel thread privileges"
  2021-03-26  0:42 [PATCH] Revert "Smack: Handle io_uring kernel thread privileges" Jens Axboe
  2021-03-26 16:00 ` Casey Schaufler
@ 2021-05-18 17:40 ` Casey Schaufler
  1 sibling, 0 replies; 4+ messages in thread
From: Casey Schaufler @ 2021-05-18 17:40 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-security-module, LKML, Casey Schaufler

On 3/25/2021 5:42 PM, Jens Axboe wrote:
> This reverts commit 942cb357ae7d9249088e3687ee6a00ed2745a0c7.
>
> The io_uring PF_IO_WORKER threads no longer have PF_KTHREAD set, so no
> need to special case them for credential checks.
>
> Cc: Casey Schaufler <casey@schaufler-ca.com>
> Signed-off-by: Jens Axboe <axboe@kernel.dk>

I have added this to smack-next. Thank you.

> ---
>  security/smack/smack_access.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/security/smack/smack_access.c b/security/smack/smack_access.c
> index 7eabb448acab..efe2406a3960 100644
> --- a/security/smack/smack_access.c
> +++ b/security/smack/smack_access.c
> @@ -688,10 +688,9 @@ bool smack_privileged_cred(int cap, const struct cred *cred)
>  bool smack_privileged(int cap)
>  {
>  	/*
> -	 * Kernel threads may not have credentials we can use.
> -	 * The io_uring kernel threads do have reliable credentials.
> +	 * All kernel tasks are privileged
>  	 */
> -	if ((current->flags & (PF_KTHREAD | PF_IO_WORKER)) == PF_KTHREAD)
> +	if (unlikely(current->flags & PF_KTHREAD))
>  		return true;
>  
>  	return smack_privileged_cred(cap, current_cred());

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-18 17:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-26  0:42 [PATCH] Revert "Smack: Handle io_uring kernel thread privileges" Jens Axboe
2021-03-26 16:00 ` Casey Schaufler
2021-03-26 16:05   ` Jens Axboe
2021-05-18 17:40 ` Casey Schaufler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).