Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Frederic Weisbecker <frederic@kernel.org>
Cc: Thomas Gleixner <tglx@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"Cc: Hyunwoo Kim" <imv4bel@gmail.com>,
	Christian Brauner <brauner@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	John Stultz <jstultz@google.com>, Ingo Molnar <mingo@kernel.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	stable@vger.kernel.org
Subject: Re: [patch V2 1/8] signal: Prevent exec() race
Date: Wed, 9 Sep 2026 02:03:42 +0200	[thread overview]
Message-ID: <aqCiXo-h1F5jsp_N@redhat.com> (raw)
In-Reply-To: <ap_gOSWtPNjwWS1e@localhost.localdomain>

On 09/08, Frederic Weisbecker wrote:
>
> Old leader                           Exec'ing New leader     CPU 2
> -----                                -----                   -----
>
> WRITE q->next = q
> WRITE q->prev = q

Damn ;) I am shy to suggest this again, but if we have _any_
concerns about the races with list_del_init()...

The lockless flush_sigqueue_list() doesn't need to it, right?
So perhaps something like below (on top of this series) to avoid
the (potential) race explicitly?

Most probably this change is wrong. And in any case we can do better.
Just to explain what I mean.

In short, I mean that exit_signals() -> flush path can do
__sigqueue_free(q) without list_del_init(&q->list).

Yes! I agree in advance that if this change can fix something,
then it fixes the symptom.

But at the same time, why does flush_sigqueue_list(head) need
list_del_init() before __sigqueue_free() ? AFAICS only to make
list_empty(head) == true. This looks confusing to me.

Oh, I am sure I missed something again ;)

Oleg.
---

diff --git a/kernel/signal.c b/kernel/signal.c
index f93d8f77ec1a..32c344ee4769 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -457,14 +457,19 @@ static void __sigqueue_free(struct sigqueue *q)
 	kmem_cache_free(sigqueue_cachep, q);
 }
 
-static void flush_sigqueue_list(struct list_head *head)
+static void __flush_sigqueue_list(struct list_head *head)
 {
 	struct sigqueue *q, *tmp;
 
-	list_for_each_entry_safe(q, tmp, head, list) {
-		list_del_init(&q->list);
+	list_for_each_entry_safe(q, tmp, head, list)
 		__sigqueue_free(q);
-	}
+}
+
+static void flush_sigqueue_list(struct list_head *head)
+{
+	LIST_HEAD(flush);
+	list_splice_init(head, &flush);
+	__flush_sigqueue_list(&flush);
 }
 
 void flush_sigqueue(struct sigpending *queue)
@@ -3196,7 +3201,7 @@ void exit_signals(struct task_struct *tsk)
 
 	cgroup_threadgroup_change_end(tsk);
 
-	flush_sigqueue_list(&sigq_list);
+	__flush_sigqueue_list(&sigq_list);
 
 	/*
 	 * If group stop has completed, deliver the notification.  This


  reply	other threads:[~2026-09-09  0:03 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260905181551.738186850@kernel.org>
2026-09-05 18:59 ` [patch V2 1/8] signal: Prevent exec() race Thomas Gleixner
2026-09-06 13:17   ` Oleg Nesterov
2026-09-06 22:39   ` Eric W. Biederman
2026-09-06 23:28     ` Oleg Nesterov
2026-09-07 11:26     ` Thomas Gleixner
2026-09-07 12:31   ` Frederic Weisbecker
2026-09-07 15:26     ` Thomas Gleixner
2026-09-07 20:15       ` Frederic Weisbecker
2026-09-07 22:28         ` Thomas Gleixner
2026-09-08 10:15           ` Frederic Weisbecker
2026-09-09  0:03             ` Oleg Nesterov [this message]
2026-09-09  9:17               ` Frederic Weisbecker
2026-09-09  8:04             ` Peter Zijlstra
2026-09-09  9:08               ` Thomas Gleixner
2026-09-09  9:55                 ` Peter Zijlstra
2026-09-09 10:20                   ` Peter Zijlstra
2026-09-09 11:31                   ` Thomas Gleixner
2026-09-09 12:13                   ` Frederic Weisbecker
2026-09-09 12:45                     ` Peter Zijlstra
2026-09-09 12:51                       ` Peter Zijlstra
2026-09-09 13:45                         ` Thomas Gleixner
2026-09-09 15:48                           ` Frederic Weisbecker
2026-09-09 16:00                           ` Frederic Weisbecker
2026-09-09 14:33                       ` Alan Stern
2026-09-09 14:45                       ` Frederic Weisbecker
2026-09-09 19:28                         ` Alan Stern
2026-09-09 20:49                           ` Thomas Gleixner
2026-09-09 21:11                             ` Alan Stern
2026-09-10 13:21                               ` Frederic Weisbecker
2026-09-10 13:28                                 ` Peter Zijlstra
2026-09-11  9:58                                   ` Frederic Weisbecker
2026-09-11 10:22                                     ` Peter Zijlstra
2026-09-11 12:36                                       ` Frederic Weisbecker
2026-09-11 14:52                                       ` Alan Stern
2026-09-10 15:26                                 ` Alan Stern
2026-09-11 12:27                                   ` Frederic Weisbecker
2026-09-11 19:05                                     ` Alan Stern
2026-09-16 13:25                                       ` Frederic Weisbecker
2026-09-09 10:18                 ` Frederic Weisbecker
2026-09-09  9:11               ` Frederic Weisbecker
2026-09-05 18:59 ` [patch V2 2/8] exec: Cleanup POSIX timers right after de_thread() Thomas Gleixner
2026-09-06 13:21   ` Oleg Nesterov
2026-09-07 22:13   ` Frederic Weisbecker

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=aqCiXo-h1F5jsp_N@redhat.com \
    --to=oleg@redhat.com \
    --cc=brauner@kernel.org \
    --cc=ebiederm@xmission.com \
    --cc=frederic@kernel.org \
    --cc=imv4bel@gmail.com \
    --cc=jstultz@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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