Skip to content

Commit

Permalink
Merge branch 'signal-for-v5.17' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/ebiederm/user-namespace

Pull signal/exit/ptrace updates from Eric Biederman:
 "This set of changes deletes some dead code, makes a lot of cleanups
  which hopefully make the code easier to follow, and fixes bugs found
  along the way.

  The end-game which I have not yet reached yet is for fatal signals
  that generate coredumps to be short-circuit deliverable from
  complete_signal, for force_siginfo_to_task not to require changing
  userspace configured signal delivery state, and for the ptrace stops
  to always happen in locations where we can guarantee on all
  architectures that the all of the registers are saved and available on
  the stack.

  Removal of profile_task_ext, profile_munmap, and profile_handoff_task
  are the big successes for dead code removal this round.

  A bunch of small bug fixes are included, as most of the issues
  reported were small enough that they would not affect bisection so I
  simply added the fixes and did not fold the fixes into the changes
  they were fixing.

  There was a bug that broke coredumps piped to systemd-coredump. I
  dropped the change that caused that bug and replaced it entirely with
  something much more restrained. Unfortunately that required some
  rebasing.

  Some successes after this set of changes: There are few enough calls
  to do_exit to audit in a reasonable amount of time. The lifetime of
  struct kthread now matches the lifetime of struct task, and the
  pointer to struct kthread is no longer stored in set_child_tid. The
  flag SIGNAL_GROUP_COREDUMP is removed. The field group_exit_task is
  removed. Issues where task->exit_code was examined with
  signal->group_exit_code should been examined were fixed.

  There are several loosely related changes included because I am
  cleaning up and if I don't include them they will probably get lost.

  The original postings of these changes can be found at:
     https://lkml.kernel.org/r/[email protected]
     https://lkml.kernel.org/r/[email protected]
     https://lkml.kernel.org/r/[email protected]

  I trimmed back the last set of changes to only the obviously correct
  once. Simply because there was less time for review than I had hoped"

* 'signal-for-v5.17' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace: (44 commits)
  ptrace/m68k: Stop open coding ptrace_report_syscall
  ptrace: Remove unused regs argument from ptrace_report_syscall
  ptrace: Remove second setting of PT_SEIZED in ptrace_attach
  taskstats: Cleanup the use of task->exit_code
  exit: Use the correct exit_code in /proc/<pid>/stat
  exit: Fix the exit_code for wait_task_zombie
  exit: Coredumps reach do_group_exit
  exit: Remove profile_handoff_task
  exit: Remove profile_task_exit & profile_munmap
  signal: clean up kernel-doc comments
  signal: Remove the helper signal_group_exit
  signal: Rename group_exit_task group_exec_task
  coredump: Stop setting signal->group_exit_task
  signal: Remove SIGNAL_GROUP_COREDUMP
  signal: During coredumps set SIGNAL_GROUP_EXIT in zap_process
  signal: Make coredump handling explicit in complete_signal
  signal: Have prepare_signal detect coredumps using signal->core_state
  signal: Have the oom killer detect coredumps using signal->core_state
  exit: Move force_uaccess back into do_exit
  exit: Guarantee make_task_dead leaks the tsk when calling do_task_exit
  ...
  • Loading branch information
torvalds committed Jan 17, 2022
2 parents 6661224 + a403df2 commit 35ce8ae
Show file tree
Hide file tree
Showing 86 changed files with 308 additions and 400 deletions.
6 changes: 3 additions & 3 deletions arch/alpha/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ die_if_kernel(char * str, struct pt_regs *regs, long err, unsigned long *r9_15)
local_irq_enable();
while (1);
}
do_exit(SIGSEGV);
make_task_dead(SIGSEGV);
}

#ifndef CONFIG_MATHEMU
Expand Down Expand Up @@ -575,7 +575,7 @@ do_entUna(void * va, unsigned long opcode, unsigned long reg,

printk("Bad unaligned kernel access at %016lx: %p %lx %lu\n",
pc, va, opcode, reg);
do_exit(SIGSEGV);
make_task_dead(SIGSEGV);

got_exception:
/* Ok, we caught the exception, but we don't want it. Is there
Expand Down Expand Up @@ -630,7 +630,7 @@ do_entUna(void * va, unsigned long opcode, unsigned long reg,
local_irq_enable();
while (1);
}
do_exit(SIGSEGV);
make_task_dead(SIGSEGV);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion arch/alpha/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ do_page_fault(unsigned long address, unsigned long mmcsr,
printk(KERN_ALERT "Unable to handle kernel paging request at "
"virtual address %016lx\n", address);
die_if_kernel("Oops", regs, cause, (unsigned long*)regs - 16);
do_exit(SIGKILL);
make_task_dead(SIGKILL);

/* We ran out of memory, or some other thing happened to us that
made us unable to handle the page fault gracefully. */
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
if (panic_on_oops)
panic("Fatal exception");
if (signr)
do_exit(signr);
make_task_dead(signr);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static void die_kernel_fault(const char *msg, struct mm_struct *mm,
show_pte(KERN_ALERT, mm, addr);
die("Oops", regs, fsr);
bust_spinlocks(0);
do_exit(SIGKILL);
make_task_dead(SIGKILL);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void die(const char *str, struct pt_regs *regs, int err)
raw_spin_unlock_irqrestore(&die_lock, flags);

if (ret != NOTIFY_STOP)
do_exit(SIGSEGV);
make_task_dead(SIGSEGV);
}

static void arm64_show_signal(int signo, const char *str)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ static void die_kernel_fault(const char *msg, unsigned long addr,
show_pte(addr);
die("Oops", regs, esr);
bust_spinlocks(0);
do_exit(SIGKILL);
make_task_dead(SIGKILL);
}

#ifdef CONFIG_KASAN_HW_TAGS
Expand Down
2 changes: 1 addition & 1 deletion arch/csky/abiv1/alignment.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ void csky_alignment(struct pt_regs *regs)
__func__, opcode, rz, rx, imm, addr);
show_regs(regs);
bust_spinlocks(0);
do_exit(SIGKILL);
make_task_dead(SIGKILL);
}

force_sig_fault(SIGBUS, BUS_ADRALN, (void __user *)addr);
Expand Down
2 changes: 1 addition & 1 deletion arch/csky/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void die(struct pt_regs *regs, const char *str)
if (panic_on_oops)
panic("Fatal exception");
if (ret != NOTIFY_STOP)
do_exit(SIGSEGV);
make_task_dead(SIGSEGV);
}

void do_trap(struct pt_regs *regs, int signo, int code, unsigned long addr)
Expand Down
2 changes: 1 addition & 1 deletion arch/csky/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static inline void no_context(struct pt_regs *regs, unsigned long addr)
pr_alert("Unable to handle kernel paging request at virtual "
"addr 0x%08lx, pc: 0x%08lx\n", addr, regs->pc);
die(regs, "Oops");
do_exit(SIGKILL);
make_task_dead(SIGKILL);
}

static inline void mm_fault_error(struct pt_regs *regs, unsigned long addr, vm_fault_t fault)
Expand Down
3 changes: 2 additions & 1 deletion arch/h8300/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/types.h>
#include <linux/sched.h>
#include <linux/sched/debug.h>
#include <linux/sched/task.h>
#include <linux/mm_types.h>
#include <linux/kernel.h>
#include <linux/errno.h>
Expand Down Expand Up @@ -106,7 +107,7 @@ void die(const char *str, struct pt_regs *fp, unsigned long err)
dump(fp);

spin_unlock_irq(&die_lock);
do_exit(SIGSEGV);
make_task_dead(SIGSEGV);
}

static int kstack_depth_to_print = 24;
Expand Down
2 changes: 1 addition & 1 deletion arch/h8300/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ asmlinkage int do_page_fault(struct pt_regs *regs, unsigned long address,
printk(" at virtual address %08lx\n", address);
if (!user_mode(regs))
die("Oops", regs, error_code);
do_exit(SIGKILL);
make_task_dead(SIGKILL);

return 1;
}
2 changes: 1 addition & 1 deletion arch/hexagon/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ int die(const char *str, struct pt_regs *regs, long err)
panic("Fatal exception");

oops_exit();
do_exit(err);
make_task_dead(err);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion arch/ia64/kernel/mca_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ mca_handler_bh(unsigned long paddr, void *iip, unsigned long ipsr)
spin_unlock(&mca_bh_lock);

/* This process is about to be killed itself */
do_exit(SIGKILL);
make_task_dead(SIGKILL);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion arch/ia64/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ die (const char *str, struct pt_regs *regs, long err)
if (panic_on_oops)
panic("Fatal exception");

do_exit(SIGSEGV);
make_task_dead(SIGSEGV);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion arch/ia64/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
regs = NULL;
bust_spinlocks(0);
if (regs)
do_exit(SIGKILL);
make_task_dead(SIGKILL);
return;

out_of_memory:
Expand Down
12 changes: 1 addition & 11 deletions arch/m68k/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,17 +273,7 @@ long arch_ptrace(struct task_struct *child, long request,

asmlinkage void syscall_trace(void)
{
ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
? 0x80 : 0));
/*
* this isn't the same as continuing with a signal, but it will do
* for normal use. strace only continues with a signal if the
* stopping signal is not SIGTRAP. -brl
*/
if (current->exit_code) {
send_sig(current->exit_code, current, 1);
current->exit_code = 0;
}
ptrace_report_syscall(0);
}

#if defined(CONFIG_COLDFIRE) || !defined(CONFIG_MMU)
Expand Down
2 changes: 1 addition & 1 deletion arch/m68k/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ void die_if_kernel (char *str, struct pt_regs *fp, int nr)
pr_crit("%s: %08x\n", str, nr);
show_registers(fp);
add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
do_exit(SIGSEGV);
make_task_dead(SIGSEGV);
}

asmlinkage void set_esp0(unsigned long ssp)
Expand Down
2 changes: 1 addition & 1 deletion arch/m68k/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int send_fault_sig(struct pt_regs *regs)
pr_alert("Unable to handle kernel access");
pr_cont(" at virtual address %p\n", addr);
die_if_kernel("Oops", regs, 0 /*error_code*/);
do_exit(SIGKILL);
make_task_dead(SIGKILL);
}

return 1;
Expand Down
4 changes: 2 additions & 2 deletions arch/microblaze/kernel/exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ void die(const char *str, struct pt_regs *fp, long err)
pr_warn("Oops: %s, sig: %ld\n", str, err);
show_regs(fp);
spin_unlock_irq(&die_lock);
/* do_exit() should take care of panic'ing from an interrupt
/* make_task_dead() should take care of panic'ing from an interrupt
* context so we don't handle it here
*/
do_exit(err);
make_task_dead(err);
}

/* for user application debugging */
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ void __noreturn die(const char *str, struct pt_regs *regs)
if (regs && kexec_should_crash(current))
crash_kexec(regs);

do_exit(sig);
make_task_dead(sig);
}

extern struct exception_table_entry __start___dbe_table[];
Expand Down
2 changes: 1 addition & 1 deletion arch/nds32/kernel/fpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ inline void handle_fpu_exception(struct pt_regs *regs)
}
} else if (fpcsr & FPCSR_mskRIT) {
if (!user_mode(regs))
do_exit(SIGILL);
make_task_dead(SIGILL);
si_signo = SIGILL;
}

Expand Down
8 changes: 4 additions & 4 deletions arch/nds32/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void __noreturn die(const char *str, struct pt_regs *regs, int err)

bust_spinlocks(0);
spin_unlock_irq(&die_lock);
do_exit(SIGSEGV);
make_task_dead(SIGSEGV);
}

EXPORT_SYMBOL(die);
Expand Down Expand Up @@ -240,7 +240,7 @@ void unhandled_interruption(struct pt_regs *regs)
pr_emerg("unhandled_interruption\n");
show_regs(regs);
if (!user_mode(regs))
do_exit(SIGKILL);
make_task_dead(SIGKILL);
force_sig(SIGKILL);
}

Expand All @@ -251,7 +251,7 @@ void unhandled_exceptions(unsigned long entry, unsigned long addr,
addr, type);
show_regs(regs);
if (!user_mode(regs))
do_exit(SIGKILL);
make_task_dead(SIGKILL);
force_sig(SIGKILL);
}

Expand All @@ -278,7 +278,7 @@ void do_revinsn(struct pt_regs *regs)
pr_emerg("Reserved Instruction\n");
show_regs(regs);
if (!user_mode(regs))
do_exit(SIGILL);
make_task_dead(SIGILL);
force_sig(SIGILL);
}

Expand Down
4 changes: 2 additions & 2 deletions arch/nios2/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ void die(const char *str, struct pt_regs *regs, long err)
show_regs(regs);
spin_unlock_irq(&die_lock);
/*
* do_exit() should take care of panic'ing from an interrupt
* make_task_dead() should take care of panic'ing from an interrupt
* context so we don't handle it here
*/
do_exit(err);
make_task_dead(err);
}

void _exception(int signo, struct pt_regs *regs, int code, unsigned long addr)
Expand Down
2 changes: 1 addition & 1 deletion arch/openrisc/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void __noreturn die(const char *str, struct pt_regs *regs, long err)
__asm__ __volatile__("l.nop 1");
do {} while (1);
#endif
do_exit(SIGSEGV);
make_task_dead(SIGSEGV);
}

/* This is normally the 'Oops' routine */
Expand Down
2 changes: 1 addition & 1 deletion arch/parisc/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ void die_if_kernel(char *str, struct pt_regs *regs, long err)
panic("Fatal exception");

oops_exit();
do_exit(SIGSEGV);
make_task_dead(SIGSEGV);
}

/* gdb uses break 4,8 */
Expand Down
8 changes: 4 additions & 4 deletions arch/powerpc/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ static void oops_end(unsigned long flags, struct pt_regs *regs,

if (panic_on_oops)
panic("Fatal exception");
do_exit(signr);
make_task_dead(signr);
}
NOKPROBE_SYMBOL(oops_end);

Expand Down Expand Up @@ -792,9 +792,9 @@ int machine_check_generic(struct pt_regs *regs)
void die_mce(const char *str, struct pt_regs *regs, long err)
{
/*
* The machine check wants to kill the interrupted context, but
* do_exit() checks for in_interrupt() and panics in that case, so
* exit the irq/nmi before calling die.
* The machine check wants to kill the interrupted context,
* but make_task_dead() checks for in_interrupt() and panics
* in that case, so exit the irq/nmi before calling die.
*/
if (in_nmi())
nmi_exit();
Expand Down
2 changes: 1 addition & 1 deletion arch/riscv/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void die(struct pt_regs *regs, const char *str)
if (panic_on_oops)
panic("Fatal exception");
if (ret != NOTIFY_STOP)
do_exit(SIGSEGV);
make_task_dead(SIGSEGV);
}

void do_trap(struct pt_regs *regs, int signo, int code, unsigned long addr)
Expand Down
2 changes: 1 addition & 1 deletion arch/riscv/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static void die_kernel_fault(const char *msg, unsigned long addr,

bust_spinlocks(0);
die(regs, "Oops");
do_exit(SIGKILL);
make_task_dead(SIGKILL);
}

static inline void no_context(struct pt_regs *regs, unsigned long addr)
Expand Down
2 changes: 1 addition & 1 deletion arch/s390/kernel/dumpstack.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,5 +224,5 @@ void __noreturn die(struct pt_regs *regs, const char *str)
if (panic_on_oops)
panic("Fatal exception: panic_on_oops");
oops_exit();
do_exit(SIGSEGV);
make_task_dead(SIGSEGV);
}
2 changes: 1 addition & 1 deletion arch/s390/kernel/nmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void __s390_handle_mcck(void)
"malfunction (code 0x%016lx).\n", mcck.mcck_code);
printk(KERN_EMERG "mcck: task: %s, pid: %d.\n",
current->comm, current->pid);
do_exit(SIGSEGV);
make_task_dead(SIGSEGV);
}
}

Expand Down
2 changes: 1 addition & 1 deletion arch/sh/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void __noreturn die(const char *str, struct pt_regs *regs, long err)
if (panic_on_oops)
panic("Fatal exception");

do_exit(SIGSEGV);
make_task_dead(SIGSEGV);
}

void die_if_kernel(const char *str, struct pt_regs *regs, long err)
Expand Down
4 changes: 1 addition & 3 deletions arch/sparc/kernel/traps_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ void __noreturn die_if_kernel(char *str, struct pt_regs *regs)
}
printk("Instruction DUMP:");
instruction_dump ((unsigned long *) regs->pc);
if(regs->psr & PSR_PS)
do_exit(SIGKILL);
do_exit(SIGSEGV);
make_task_dead((regs->psr & PSR_PS) ? SIGKILL : SIGSEGV);
}

void do_hw_interrupt(struct pt_regs *regs, unsigned long type)
Expand Down
4 changes: 1 addition & 3 deletions arch/sparc/kernel/traps_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -2559,9 +2559,7 @@ void __noreturn die_if_kernel(char *str, struct pt_regs *regs)
}
if (panic_on_oops)
panic("Fatal exception");
if (regs->tstate & TSTATE_PRIV)
do_exit(SIGKILL);
do_exit(SIGSEGV);
make_task_dead((regs->tstate & TSTATE_PRIV)? SIGKILL : SIGSEGV);
}
EXPORT_SYMBOL(die_if_kernel);

Expand Down
Loading

0 comments on commit 35ce8ae

Please sign in to comment.