There are two places where signal_group_exit are set.  In the
fs/exec.c:de_thread() and in fs/coredump.c:zap_threads().

The coredump usage of group_exit_task was explicitly added[1]
so that signal_group_exit() would return true during a
coredump.

When examining the coredump usage it turns out that SIGNAL_GROUP_COREDUMP
is set in all of the same places as group_exit_task.  So signal_group_exit
can test SIGNAL_GROUP_COREDUMP and achieve the same results with
respect to coredumps as testing group_exit_task.

Similarly the exec code sets and clears SIGNAL_GROUP_DETHREAD in all
of the places where group_exit_task is set and cleared.

So test SIGNAL_GROUP_COREDUMP | SIGNAL_GROUP_DETHREAD instead of
group_exit_task.

Cc: Oleg Nesterov <[email protected]>
[1] 6cd8f0acae34 ("coredump: ensure that SIGKILL always kills the dumping 
thread")
Signed-off-by: "Eric W. Biederman" <[email protected]>
---
 include/linux/sched/signal.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h
index 5ff8697b21cd..43822e2b63e6 100644
--- a/include/linux/sched/signal.h
+++ b/include/linux/sched/signal.h
@@ -268,8 +268,9 @@ static inline void signal_set_stop_flags(struct 
signal_struct *sig,
 /* If true, all threads except ->group_exit_task have pending SIGKILL */
 static inline int signal_group_exit(const struct signal_struct *sig)
 {
-       return  (sig->flags & SIGNAL_GROUP_EXIT) ||
-               (sig->group_exit_task != NULL);
+       return  (sig->flags & (SIGNAL_GROUP_EXIT |
+                              SIGNAL_GROUP_COREDUMP |
+                              SIGNAL_GROUP_DETHREAD));
 }
 
 extern void flush_signals(struct task_struct *);
-- 
2.20.1

Reply via email to