[PATCH 00/17] exit: Making task exiting a first class concept

Eric W. Biederman
2022-01-03T21:30:35Z

The changes below contain some cleanups and the work to make implement
first class asynchronous task exit. Most of the cleanups are necessary
for this work but a couple of them (removing profile_task_exit and the
extra setting of PT_SEIZED in ptrace_attach) are included because I
stumbled over them and they are worth applying but they aren't
interesting enough to me to make be in their own patchset.

The core of this set of changes is the addition of
schedule_task_exit_locked. Ptrace is cleaned up to avoid a conflict in
task->exit_code. Then the existing task exit code is gradually moved
into the final shape of schedule_task_exit_locked.

This is the fundamental building block I need to fix alpha, m68k,
nios2 and any other architecture that does not always save all of
their registers except when entering into a ptrace context.

This is about half the work to allow coredump signals to use
short-circuit delivery.

With coredumps signals available for short-circuit delivery the
SA_IMMUTABLE hack can be replace by something clean.

The counting of the number of threads that have not been killed to
always set SIGNAL_GROUP_EXIT when a process exits and the coredump
signal short-circuit delivery is a foundation for updating the
SECCOMP_RET_KILL_THREAD implementation such that it can decide if it
should coredump without races.

I have most of those changes pretty much ready I just need to get these
changes finalized reviewed first. At this point they are looking at
v5.18 material.

These patches are on top of:
https://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git/ signal-for-v5.17

After these patches have been reviewed it is my plan to apply them to my
signal-for-v5.17 branch. Any and all feedback is welcome.

Eric W. Biederman (17):
exit: Remove profile_task_exit & profile_munmap
exit: Coredumps reach do_group_exit
exit: Fix the exit_code for wait_task_zombie
exit: Use the correct exit_code in /proc/<pid>/stat
taskstats: Cleanup the use of task->exit_code
ptrace: Remove second setting of PT_SEIZED in ptrace_attach
ptrace: Remove unused regs argument from ptrace_report_syscall
ptrace/m68k: Stop open coding ptrace_report_syscall
ptrace: Move setting/clearing ptrace_message into prace_stop
ptrace: Return the signal to continue with from ptrace_stop
ptrace: Separate task->ptrace_code out from task->exit_code
signal: Compute the process exit_code in get_signal
signal: Make individual tasks exiting a first class concept
signal: Remove zap_other_threads
signal: Add JOBCTL_WILL_EXIT to mark exiting tasks
signal: Record the exit_code when an exit is scheduled
signal: Always set SIGNAL_GROUP_EXIT on process exit

arch/m68k/kernel/ptrace.c | 12 +----
fs/coredump.c | 17 +++---
fs/exec.c | 12 +++--
fs/proc/array.c | 9 +++-
include/linux/profile.h | 26 ---------
include/linux/ptrace.h | 5 +-
include/linux/sched.h | 1 +
include/linux/sched/jobctl.h | 2 +
include/linux/sched/signal.h | 6 ++-
include/linux/tracehook.h | 21 ++++----
kernel/exit.c | 29 +++++-----
kernel/fork.c | 2 +
kernel/profile.c | 50 ------------------
kernel/ptrace.c | 14 +++--
kernel/signal.c | 122 +++++++++++++++++++++++--------------------
kernel/tsacct.c | 7 ++-
mm/mmap.c | 1 -
17 files changed, 134 insertions(+), 202 deletions(-)