lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87sex9efj1.fsf_-_@email.froward.int.ebiederm.org>
Date: Tue, 18 Jun 2024 23:13:22 -0500
From: "Eric W. Biederman" <ebiederm@...ssion.com>
To: Oleg Nesterov <oleg@...hat.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,  Tejun Heo <tj@...nel.org>,
  linux-kernel@...r.kernel.org
Subject: [PATCH 17/17] signal: Set SIGNAL_GROUP_EXIT when all tasks have
 decided to exit


Move the quick_threads decrement from synchronize_group_exit into
schedule_task_exit_locked allowing quick_threads to be decremented
when the decision is made for a task to exit.

Set SIGNAL_GROUP_EXIT, group_exit_code, and group_stop_code when the
decision is made that the last thread will exit.  This makes the
information available earlier and so the kernel needs to do less work
when a process is exiting.

Signed-off-by: "Eric W. Biederman" <ebiederm@...ssion.com>
---
 kernel/exit.c   |  8 --------
 kernel/signal.c | 10 +++++++---
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/kernel/exit.c b/kernel/exit.c
index 2b4e57ff02a1..ba48124f9bc9 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -798,18 +798,10 @@ static inline void check_stack_usage(void) {}
 static int synchronize_group_exit(struct task_struct *tsk, long code)
 {
 	struct sighand_struct *sighand = tsk->sighand;
-	struct signal_struct *signal = tsk->signal;
 
 	spin_lock_irq(&sighand->siglock);
 	schedule_task_exit_locked(tsk, code);
 	code = tsk->exit_code;
-	signal->quick_threads--;
-	if ((signal->quick_threads == 0) &&
-	    !(signal->flags & SIGNAL_GROUP_EXIT)) {
-		signal->flags = SIGNAL_GROUP_EXIT;
-		signal->group_exit_code = code;
-		signal->group_stop_count = 0;
-	}
 	spin_unlock_irq(&sighand->siglock);
 	return code;
 }
diff --git a/kernel/signal.c b/kernel/signal.c
index c8b896bc84bb..59e0c5505d76 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1009,9 +1009,6 @@ void schedule_group_exit_locked(struct signal_struct *signal, int exit_code)
 	 */
 	struct task_struct *t;
 
-	signal->flags = SIGNAL_GROUP_EXIT;
-	signal->group_exit_code = exit_code;
-	signal->group_stop_count = 0;
 	__for_each_thread(signal, t)
 		schedule_task_exit_locked(t, exit_code);
 }
@@ -1376,10 +1373,17 @@ int force_sig_info(struct kernel_siginfo *info)
 void schedule_task_exit_locked(struct task_struct *task, int exit_code)
 {
 	if (!(task->jobctl & JOBCTL_WILL_EXIT)) {
+		struct signal_struct *signal = task->signal;
 		task_clear_jobctl_pending(task, JOBCTL_PENDING_MASK);
 		task->jobctl |= JOBCTL_WILL_EXIT;
 		task->exit_code = exit_code;
 		signal_wake_up(task, true);
+		signal->quick_threads--;
+		if (signal->quick_threads == 0) {
+			signal->flags = SIGNAL_GROUP_EXIT;
+			signal->group_exit_code = exit_code;
+			signal->group_stop_count = 0;
+		}
 	}
 }
 
-- 
2.41.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ