public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Günther Noack" <gnoack3000@gmail.com>
To: "Mickaël Salaün" <mic@digikod.net>
Cc: "Günther Noack" <gnoack@google.com>,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"Christian Brauner" <brauner@kernel.org>,
	"Paul Moore" <paul@paul-moore.com>
Subject: Re: [PATCH v1 1/3] landlock: Log the TGID of the domain creator
Date: Fri, 11 Apr 2025 10:35:31 +0200	[thread overview]
Message-ID: <20250411.3c94c5c9e6bb@gnoack.org> (raw)
In-Reply-To: <20250410171725.1265860-1-mic@digikod.net>

On Thu, Apr 10, 2025 at 07:17:21PM +0200, Mickaël Salaün wrote:
> As for other Audit's "pid" fields, Landlock should use the task's TGID
> instead of its TID.  Fix this issue by keeping a reference to the TGID
> of the domain creator.
> 
> Existing tests already check for the PID but only with the thread group
> leader, so always the TGID.  A following patch adds dedicated tests for
> non-leader thread.
> 
> Remove the current_real_cred() check which does not make sense because
> we only reference a struct pid, whereas a previous version did reference
> a struct cred instead.
> 
> Cc: Christian Brauner <brauner@kernel.org>
> Cc: Günther Noack <gnoack@google.com>
> Cc: Paul Moore <paul@paul-moore.com>
> Signed-off-by: Mickaël Salaün <mic@digikod.net>
> ---
>  security/landlock/domain.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/security/landlock/domain.c b/security/landlock/domain.c
> index bae2e9909013..a647b68e8d06 100644
> --- a/security/landlock/domain.c
> +++ b/security/landlock/domain.c
> @@ -16,6 +16,7 @@
>  #include <linux/path.h>
>  #include <linux/pid.h>
>  #include <linux/sched.h>
> +#include <linux/signal.h>
>  #include <linux/uidgid.h>
>  
>  #include "access.h"
> @@ -99,8 +100,7 @@ static struct landlock_details *get_current_details(void)
>  		return ERR_PTR(-ENOMEM);
>  
>  	memcpy(details->exe_path, path_str, path_size);
> -	WARN_ON_ONCE(current_cred() != current_real_cred());
> -	details->pid = get_pid(task_pid(current));
> +	details->pid = get_pid(task_tgid(current));
>  	details->uid = from_kuid(&init_user_ns, current_uid());
>  	get_task_comm(details->comm, current);
>  	return details;
> -- 
> 2.49.0
> 

Ah, a classic! Good catch finding this early enough for 6.15!

Reviewed-by: Günther Noack <gnoack3000@gmail.com>

      parent reply	other threads:[~2025-04-11  8:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-10 17:17 [PATCH v1 1/3] landlock: Log the TGID of the domain creator Mickaël Salaün
2025-04-10 17:17 ` [PATCH v1 2/3] selftests/landlock: Factor out audit fixture in audit_test Mickaël Salaün
2025-04-10 17:17 ` [PATCH v1 3/3] selftests/landlock: Add PID tests for audit records Mickaël Salaün
2025-04-11  8:35 ` Günther Noack [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250411.3c94c5c9e6bb@gnoack.org \
    --to=gnoack3000@gmail.com \
    --cc=brauner@kernel.org \
    --cc=gnoack@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=mic@digikod.net \
    --cc=paul@paul-moore.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox