Skip to content

Refactoring exit

Eric W. Biederman linux-alpha linux-api linux-arch linux-m68k lkml oe-kbuild-all oe-lkp 1 version In review

Get series with b4
b4 am 875yy3850g.fsf_-_@disp2133

Versions newest first

  1. v1 Latest9 patches 22 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9signal/sh: Use force_sig(SIGKILL) instead of do_group_exit(SIGKILL)arch/sh/kernel/cpu/fpu.c+6 -40 replies
2/9signal/seccomp: Refactor seccomp signal and coredump generationinclude/linux/sched/signal.h kernel/seccomp.c kernel/signal.c+36 -382 replies
3/9signal/seccomp: Dump core when there is only one live threadkernel/seccomp.c+1 -11 reply
4/9signal: Factor start_group_exit out of complete_signalinclude/linux/sched/signal.h kernel/signal.c+39 -152 replies
5/9signal/group_exit: Use start_group_exit in place of do_group_exitkernel/exit.c kernel/seccomp.c+3 -31 reply
6/9signal: Fold do_group_exit into get_signal fixing io_uring threadsinclude/linux/sched/task.h kernel/exit.c kernel/signal.c+25 -422 replies
7/9signal: Make individual tasks exiting a first class concept.fs/exec.c include/linux/sched/jobctl.h include/linux/sched/signal.h +1 more+28 -222 replies
8/9signal/task_exit: Use start_task_exit in place of do_exitinclude/linux/sched/signal.h kernel/exit.c kernel/seccomp.c +1 more+17 -21 reply
9/9signal: Move PTRACE_EVENT_EXIT into get_signalkernel/exit.c kernel/signal.c+2 -20 replies

Reviews trailers per patch

None of the 9 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchMichael SchmitzGeert UytterhoevenArnd BergmannCyril Hrubis
SeriesT-b A-b R-b A-b
1/9
2/9
3/9
4/9
5/9
6/9
7/9
8/9
9/9

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v1 thread

Cover letter [PATCH 0/9] Refactoring exit

I dug into exit because PTRACE_EVENT_EXIT not being guaranteed to be called with a stack where ptrace read and write all of the userspace registers can lead to unfiltered reads and writes of kernel stack contents.

While looking into it I realized that there are a lot of little races between all of the ways an exit can be initiated. I don't know of a way those races are harmful, but they make the code difficult to reason about.

The solution this set of changes adopts is to implement good primitives for asynchronous exit and exit_group requests and modifies exit(2) and exit_group(2) to use those primitives.

The result should be more consistent determination of the reason for an exit, as well as PTRACE_EVENT_EXIT always being called from a context (get_signal) where ptrace is guaranteed to be able to read and write all of the registers.

I believe the set of changes could be justified for the cleanups alone even if PTRACE_EVENT_EXIT did not need to be moved. Which makes me feel good about this approach.

If a way can be found that coredumps can be started from complete_signal (needed for timely handling of fatal signals) instead of needing to start in do_coredump for proper synchronization force_siginfo_to_task and get_signal can be significantly simplified. As it is a lot of checks are duplicated to ensure that everything works properly in the presence of do_coredump.

So far the code has been lightly tested, and the descriptions of some of the patches are a bit light, but I think this shows the direction I am aiming to travel for sorting out exit(2) and exit_group(2).

Eric W. Biederman (9):
signal/sh: Use force_sig(SIGKILL) instead of do_group_exit(SIGKILL) signal/seccomp: Refactor seccomp signal and coredump generation signal/seccomp: Dump core when there is only one live thread
signal: Factor start_group_exit out of complete_signal signal/group_exit: Use start_group_exit in place of do_group_exit
signal: Fold do_group_exit into get_signal fixing io_uring threads
signal: Make individual tasks exiting a first class concept. signal/task_exit: Use start_task_exit in place of do_exit
signal: Move PTRACE_EVENT_EXIT into get_signal

 arch/sh/kernel/cpu/fpu.c     |  10 +--
 fs/exec.c                    |  10 ++-
 include/linux/sched/jobctl.h |   2 +
 include/linux/sched/signal.h |   5 ++
 include/linux/sched/task.h   |   1 -
 kernel/exit.c                |  41 ++---------
 kernel/seccomp.c             |  45 +++---------
 kernel/signal.c              | 166 ++++++++++++++++++++++++++++++-------------
 8 files changed, 154 insertions(+), 126 deletions(-)