From: Oleg Nesterov <oleg@redhat.com>
To: Nickolai Zeldovich <nickolai@csail.mit.edu>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Christian Brauner <brauner@kernel.org>,
Thomas Gleixner <tglx@kernel.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] signal: fix endless loop in complete_signal() during a non-leader exec
Date: Wed, 28 Oct 2026 15:29:19 +0100 [thread overview]
Message-ID: <auIGv1WkQnEw6VRd@redhat.com> (raw)
In-Reply-To: <20261027025055.842038-1-nickolai@csail.mit.edu>
On 10/26, Nickolai Zeldovich wrote:
>
> The curr_target walk uses next_thread(), which wraps from the last
> thread to ->group_leader on the assumption that the leader is first on
> signal->thread_head. de_thread() makes the exec'ing thread, the last
> one, the leader before release_task() unlinks the old leader, so a walk
> that starts at the old leader stays on the new one if that thread
> blocks the signal, and never gets back to curr_target.
...
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -990,7 +990,10 @@ static void complete_signal(int sig, struct task_struct *p, enum pid_type type)
> */
> t = signal->curr_target;
> while (!wants_signal(sig, t)) {
> - t = next_thread(t);
> + /* during de_thread() the leader may not be first */
> + t = __next_thread(t) ?:
> + list_first_entry(&signal->thread_head,
> + struct task_struct, thread_node);
I think we should fix (and simplify) next_thread() instead. How about
--- a/include/linux/sched/signal.h
+++ b/include/linux/sched/signal.h
@@ -764,7 +764,7 @@ static inline struct task_struct *__next_thread(struct task_struct *p)
static inline struct task_struct *next_thread(struct task_struct *p)
{
- return __next_thread(p) ?: p->group_leader;
+ return list_next_entry_circular(p, &p->thread_node, thread_node);
}
?
Oleg.
next prev parent reply other threads:[~2026-10-28 14:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 2:50 [PATCH v1] signal: fix endless loop in complete_signal() during a non-leader exec Nickolai Zeldovich
2026-10-27 11:17 ` Oleg Nesterov
2026-10-28 14:29 ` Oleg Nesterov [this message]
2026-10-28 17:46 ` Nickolai Zeldovich
2026-10-29 12:28 ` Oleg Nesterov
2026-10-30 16:29 ` Christian Brauner
2026-10-31 13:46 ` [PATCH] signal: fix lockup in complete_signal() racing with mt exec Oleg Nesterov
2026-10-31 15:37 ` Nickolai Zeldovich
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=auIGv1WkQnEw6VRd@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nickolai@csail.mit.edu \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.