public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Josh Law <objecting@objecting.org>
Cc: Christian Brauner <brauner@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] signal: use task parameter instead of current in task_join_group_stop()
Date: Sun, 15 Mar 2026 20:29:06 +0100	[thread overview]
Message-ID: <abcIgph93itV2rFB@redhat.com> (raw)
In-Reply-To: <20260315151847.214634-1-objecting@objecting.org>

Hi Josh,

Well, this is subjective, but I don't like your patch in any case...
In fact I think it is wrong. See below.

On 03/15, Josh Law wrote:
>
> task_join_group_stop() takes a task_struct parameter but reads jobctl
> and signal from current instead.

And in my opinion this is what it should actually do.

Because task_join_group_stop(p) asks 'p' to join the current's group-stop
if it is active.

And to me this logic looks very clear. but may be task_join_group_stop()
should be renamed to make it even more clear, I dunno.

> This works today because the sole
> caller (copy_process) always passes a new thread in the same thread
> group as current, so task->signal == current->signal and
> task->jobctl is a copy of current->jobctl from dup_task_struct().

I see it differently.

Your change assumes that task->jobctl was correctly copied by dup_task_struct().
We should not rely on that.

And at first glance we can't rely on that. current->jobctl can change between between
dup_task_struct() and copy_process() -> spin_lock(&current->sighand->siglock);

Oleg.

> Use the task parameter directly so the function is self-consistent
> with its API and will not silently break if a future caller passes a
> task from a different thread group.
> 
> Signed-off-by: Josh Law <objecting@objecting.org>
> ---
>  kernel/signal.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/signal.c b/kernel/signal.c
> index 116cf678c4a3..cb417e3674ed 100644
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -386,8 +386,8 @@ static bool task_participate_group_stop(struct task_struct *task)
>  
>  void task_join_group_stop(struct task_struct *task)
>  {
> -	unsigned long mask = current->jobctl & JOBCTL_STOP_SIGMASK;
> -	struct signal_struct *sig = current->signal;
> +	unsigned long mask = task->jobctl & JOBCTL_STOP_SIGMASK;
> +	struct signal_struct *sig = task->signal;
>  
>  	if (sig->group_stop_count) {
>  		sig->group_stop_count++;
> -- 
> 2.34.1
> 


  reply	other threads:[~2026-03-15 19:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-15 15:18 [PATCH] signal: use task parameter instead of current in task_join_group_stop() Josh Law
2026-03-15 19:29 ` Oleg Nesterov [this message]
2026-03-15 19:50   ` Josh Law

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=abcIgph93itV2rFB@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=brauner@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=objecting@objecting.org \
    --cc=peterz@infradead.org \
    --cc=tglx@kernel.org \
    /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