aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2025-02-07 11:21:02 +0100
committerChristian Brauner <brauner@kernel.org>2025-02-07 11:21:41 +0100
commit33be3ffd30b3ae67c7a1a405f98b963fd915d61a (patch)
tree6c2e2e172482647770c3577b3164260f46e60a15
parentLinux 6.14-rc1 (diff)
parentexit: kill the pointless __exit_signal()->clear_tsk_thread_flag(TIF_SIGPENDING) (diff)
downloadwireguard-linux-33be3ffd30b3ae67c7a1a405f98b963fd915d61a.tar.xz
wireguard-linux-33be3ffd30b3ae67c7a1a405f98b963fd915d61a.zip
Merge patch series "exit: change the release_task() paths to call flush_sigqueue() lockless"
Oleg Nesterov <oleg@redhat.com> says: Change the release_task() paths to call flush_sigqueue() lockless. * patches from https://lore.kernel.org/r/20250206152244.GA14609@redhat.com: exit: kill the pointless __exit_signal()->clear_tsk_thread_flag(TIF_SIGPENDING) exit: change the release_task() paths to call flush_sigqueue() lockless Link: https://lore.kernel.org/r/20250206152244.GA14609@redhat.com Signed-off-by: Christian Brauner <brauner@kernel.org>
-rw-r--r--kernel/exit.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index 3485e5fc499e..0acb94b17caa 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -200,20 +200,12 @@ static void __exit_signal(struct task_struct *tsk)
__unhash_process(tsk, group_dead);
write_sequnlock(&sig->stats_lock);
- /*
- * Do this under ->siglock, we can race with another thread
- * doing sigqueue_free() if we have SIGQUEUE_PREALLOC signals.
- */
- flush_sigqueue(&tsk->pending);
tsk->sighand = NULL;
spin_unlock(&sighand->siglock);
__cleanup_sighand(sighand);
- clear_tsk_thread_flag(tsk, TIF_SIGPENDING);
- if (group_dead) {
- flush_sigqueue(&sig->shared_pending);
+ if (group_dead)
tty_kref_put(tty);
- }
}
static void delayed_put_task_struct(struct rcu_head *rhp)
@@ -279,6 +271,16 @@ repeat:
proc_flush_pid(thread_pid);
put_pid(thread_pid);
release_thread(p);
+ /*
+ * This task was already removed from the process/thread/pid lists
+ * and lock_task_sighand(p) can't succeed. Nobody else can touch
+ * ->pending or, if group dead, signal->shared_pending. We can call
+ * flush_sigqueue() lockless.
+ */
+ flush_sigqueue(&p->pending);
+ if (thread_group_leader(p))
+ flush_sigqueue(&p->signal->shared_pending);
+
put_task_struct_rcu_user(p);
p = leader;