[PATCH 08/17] signal: Don't target tasks that are exiting

Eric W. Biederman posted 17 patches 1 year, 7 months ago
[PATCH 08/17] signal: Don't target tasks that are exiting
Posted by Eric W. Biederman 1 year, 7 months ago

Teach wants_signal and retarget_shared_pending to use
JOBCTL_TASK_EXITING to detect threads that have an exit pending and so
will not be processing any more signals.

Teach task_set_jobctl_pending to directly examine JOBCTL_WILL_EXIT
rather than looking at PF_EXITING and fatal_signal_pending as those
are redundant.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
 kernel/signal.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index d169b47775b0..5e67c00b9b30 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -281,7 +281,7 @@ bool task_set_jobctl_pending(struct task_struct *task, unsigned long mask)
 			JOBCTL_STOP_SIGMASK | JOBCTL_TRAPPING));
 	BUG_ON((mask & JOBCTL_TRAPPING) && !(mask & JOBCTL_PENDING_MASK));
 
-	if (unlikely(fatal_signal_pending(task) || (task->flags & PF_EXITING)))
+	if (unlikely(task->jobctl & JOBCTL_WILL_EXIT))
 		return false;
 
 	if (mask & JOBCTL_STOP_SIGMASK)
@@ -985,7 +985,7 @@ static inline bool wants_signal(int sig, struct task_struct *p)
 	if (sigismember(&p->blocked, sig))
 		return false;
 
-	if (p->flags & PF_EXITING)
+	if (p->jobctl & JOBCTL_WILL_EXIT)
 		return false;
 
 	if (sig == SIGKILL)
@@ -2998,7 +2998,7 @@ static void retarget_shared_pending(struct task_struct *tsk, sigset_t *which)
 		return;
 
 	for_other_threads(tsk, t) {
-		if (t->flags & PF_EXITING)
+		if (t->jobctl & JOBCTL_WILL_EXIT)
 			continue;
 
 		if (!has_pending_signals(&retarget, &t->blocked))
-- 
2.41.0