We have a lot of calls to do_exit that really don't want the semantics of userspace calling pthread_exit, aka exit(2). Instead the interesting semantics are those of the current task exiting. This set of changes removes a dead reference to do_exit on s390, adds a function make_task_dead and changes all of the oops implementations to use it, and adds function kthread_exit and changes all of the kthread exits to use it. The short term win of this set of changes is being able to move many sanity checks out of do_exit that are only really interesting during an oops. Making it easier to see what do_exit is actually doing. After this set of changes the number there are only about a big screen full of do_exit calls left. Making future changes much easier to review. s390 folks. Can you please verify I read the s390 code correctly when observing the reference to do_exit really is dead? I would really appreciate it. I am not very familiar with s390. This is on top of: https://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git/ signal-for-v5.17 It is my plan that after these changes are reviewed to apply these changes into my signal-for-v5.17 branch. After that I can get to cleaning up where signals, coredumps and the exit code meets. Eric W. Biederman (10): exit/s390: Remove dead reference to do_exit from copy_thread exit: Add and use make_task_dead. exit: Move oops specific logic from do_exit into make_task_dead exit: Stop poorly open coding do_task_dead in make_task_dead exit: Stop exporting do_exit exit: Implement kthread_exit exit: Rename module_put_and_exit to module_put_and_kthread_exit exit: Rename complete_and_exit to kthread_complete_and_exit kthread: Ensure struct kthread is present for all kthreads exit/kthread: Move the exit code for kernel threads into struct kthread arch/alpha/kernel/traps.c | 6 +- arch/alpha/mm/fault.c | 2 +- arch/arm/kernel/traps.c | 2 +- arch/arm/mm/fault.c | 2 +- arch/arm64/kernel/traps.c | 2 +- arch/arm64/mm/fault.c | 2 +- arch/csky/abiv1/alignment.c | 2 +- arch/csky/kernel/traps.c | 2 +- arch/csky/mm/fault.c | 2 +- arch/h8300/kernel/traps.c | 2 +- arch/h8300/mm/fault.c | 2 +- arch/hexagon/kernel/traps.c | 2 +- arch/ia64/kernel/mca_drv.c | 2 +- arch/ia64/kernel/traps.c | 2 +- arch/ia64/mm/fault.c | 2 +- arch/m68k/kernel/traps.c | 2 +- arch/m68k/mm/fault.c | 2 +- arch/microblaze/kernel/exceptions.c | 4 +- arch/mips/kernel/traps.c | 2 +- arch/nds32/kernel/fpu.c | 2 +- arch/nds32/kernel/traps.c | 8 +-- arch/nios2/kernel/traps.c | 4 +- arch/openrisc/kernel/traps.c | 2 +- arch/parisc/kernel/traps.c | 2 +- arch/powerpc/kernel/traps.c | 8 +-- arch/riscv/kernel/traps.c | 2 +- arch/riscv/mm/fault.c | 2 +- arch/s390/kernel/dumpstack.c | 2 +- arch/s390/kernel/nmi.c | 2 +- arch/s390/kernel/process.c | 1 - arch/sh/kernel/traps.c | 2 +- arch/sparc/kernel/traps_32.c | 4 +- arch/sparc/kernel/traps_64.c | 4 +- arch/x86/entry/entry_32.S | 6 +- arch/x86/entry/entry_64.S | 6 +- arch/x86/kernel/dumpstack.c | 4 +- arch/xtensa/kernel/traps.c | 2 +- crypto/algboss.c | 4 +- drivers/net/wireless/rsi/rsi_91x_coex.c | 2 +- drivers/net/wireless/rsi/rsi_91x_main.c | 2 +- drivers/net/wireless/rsi/rsi_91x_sdio_ops.c | 2 +- drivers/net/wireless/rsi/rsi_91x_usb_ops.c | 2 +- drivers/pnp/pnpbios/core.c | 6 +- drivers/staging/rts5208/rtsx.c | 16 ++--- drivers/usb/atm/usbatm.c | 2 +- drivers/usb/gadget/function/f_mass_storage.c | 2 +- fs/cifs/connect.c | 2 +- fs/exec.c | 2 + fs/jffs2/background.c | 2 +- fs/nfs/callback.c | 4 +- fs/nfs/nfs4state.c | 2 +- fs/nfsd/nfssvc.c | 2 +- include/linux/kernel.h | 1 - include/linux/kthread.h | 4 +- include/linux/module.h | 6 +- include/linux/sched/task.h | 1 + kernel/exit.c | 88 ++++++++++++++-------------- kernel/fork.c | 4 ++ kernel/futex/core.c | 2 +- kernel/kexec_core.c | 2 +- kernel/kthread.c | 78 +++++++++++++++++------- kernel/module.c | 6 +- kernel/sched/core.c | 16 ++--- lib/kunit/try-catch.c | 4 +- net/bluetooth/bnep/core.c | 2 +- net/bluetooth/cmtp/core.c | 2 +- net/bluetooth/hidp/core.c | 2 +- tools/objtool/check.c | 8 ++- 68 files changed, 212 insertions(+), 173 deletions(-) Eric