Skip to content

Commit

Permalink
Merge branch 'siginfo-linus' of git://git.kernel.org/pub/scm/linux/ke…
Browse files Browse the repository at this point in the history
…rnel/git/ebiederm/user-namespace

Pull force_sig() argument change from Eric Biederman:
 "A source of error over the years has been that force_sig has taken a
  task parameter when it is only safe to use force_sig with the current
  task.

  The force_sig function is built for delivering synchronous signals
  such as SIGSEGV where the userspace application caused a synchronous
  fault (such as a page fault) and the kernel responded with a signal.

  Because the name force_sig does not make this clear, and because the
  force_sig takes a task parameter the function force_sig has been
  abused for sending other kinds of signals over the years. Slowly those
  have been fixed when the oopses have been tracked down.

  This set of changes fixes the remaining abusers of force_sig and
  carefully rips out the task parameter from force_sig and friends
  making this kind of error almost impossible in the future"

* 'siginfo-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace: (27 commits)
  signal/x86: Move tsk inside of CONFIG_MEMORY_FAILURE in do_sigbus
  signal: Remove the signal number and task parameters from force_sig_info
  signal: Factor force_sig_info_to_task out of force_sig_info
  signal: Generate the siginfo in force_sig
  signal: Move the computation of force into send_signal and correct it.
  signal: Properly set TRACE_SIGNAL_LOSE_INFO in __send_signal
  signal: Remove the task parameter from force_sig_fault
  signal: Use force_sig_fault_to_task for the two calls that don't deliver to current
  signal: Explicitly call force_sig_fault on current
  signal/unicore32: Remove tsk parameter from __do_user_fault
  signal/arm: Remove tsk parameter from __do_user_fault
  signal/arm: Remove tsk parameter from ptrace_break
  signal/nds32: Remove tsk parameter from send_sigtrap
  signal/riscv: Remove tsk parameter from do_trap
  signal/sh: Remove tsk parameter from force_sig_info_fault
  signal/um: Remove task parameter from send_sigtrap
  signal/x86: Remove task parameter from send_sigtrap
  signal: Remove task parameter from force_sig_mceerr
  signal: Remove task parameter from force_sig
  signal: Remove task parameter from force_sigsegv
  ...
  • Loading branch information
torvalds committed Jul 9, 2019
2 parents 92c1d65 + 318759b commit 5ad18b2
Show file tree
Hide file tree
Showing 143 changed files with 567 additions and 484 deletions.
4 changes: 2 additions & 2 deletions arch/alpha/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ do_sigreturn(struct sigcontext __user *sc)
return;

give_sigsegv:
force_sig(SIGSEGV, current);
force_sig(SIGSEGV);
}

asmlinkage void
Expand Down Expand Up @@ -253,7 +253,7 @@ do_rt_sigreturn(struct rt_sigframe __user *frame)
return;

give_sigsegv:
force_sig(SIGSEGV, current);
force_sig(SIGSEGV);
}


Expand Down
2 changes: 1 addition & 1 deletion arch/alpha/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ do_entDbg(struct pt_regs *regs)
{
die_if_kernel("Instruction fault", regs, 0, NULL);

force_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)regs->pc, 0, current);
force_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)regs->pc, 0);
}


Expand Down
4 changes: 2 additions & 2 deletions arch/alpha/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,13 @@ do_page_fault(unsigned long address, unsigned long mmcsr,
up_read(&mm->mmap_sem);
/* Send a sigbus, regardless of whether we were in kernel
or user mode. */
force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *) address, 0, current);
force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *) address, 0);
if (!user_mode(regs))
goto no_context;
return;

do_sigsegv:
force_sig_fault(SIGSEGV, si_code, (void __user *) address, 0, current);
force_sig_fault(SIGSEGV, si_code, (void __user *) address, 0);
return;

#ifdef CONFIG_ALPHA_LARGE_VMALLOC
Expand Down
4 changes: 2 additions & 2 deletions arch/arc/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, expected, int, new)
goto again;

fail:
force_sig(SIGSEGV, current);
force_sig(SIGSEGV);
return ret;
}

Expand Down Expand Up @@ -310,7 +310,7 @@ int elf_check_arch(const struct elf32_hdr *x)
eflags = x->e_flags;
if ((eflags & EF_ARC_OSABI_MSK) != EF_ARC_OSABI_CURRENT) {
pr_err("ABI mismatch - you need newer toolchain\n");
force_sigsegv(SIGSEGV, current);
force_sigsegv(SIGSEGV);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion arch/arc/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ SYSCALL_DEFINE0(rt_sigreturn)
return regs->r0;

badframe:
force_sig(SIGSEGV, current);
force_sig(SIGSEGV);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion arch/arc/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ unhandled_exception(const char *str, struct pt_regs *regs,

tsk->thread.fault_address = (__force unsigned int)addr;

force_sig_fault(signo, si_code, addr, tsk);
force_sig_fault(signo, si_code, addr);

} else {
/* If not due to copy_(to|from)_user, we are doomed */
Expand Down
4 changes: 2 additions & 2 deletions arch/arc/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void do_page_fault(unsigned long address, struct pt_regs *regs)
/* User mode accesses just cause a SIGSEGV */
if (user_mode(regs)) {
tsk->thread.fault_address = address;
force_sig_fault(SIGSEGV, si_code, (void __user *)address, tsk);
force_sig_fault(SIGSEGV, si_code, (void __user *)address);
return;
}

Expand Down Expand Up @@ -231,5 +231,5 @@ void do_page_fault(unsigned long address, struct pt_regs *regs)
goto no_context;

tsk->thread.fault_address = address;
force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *)address, tsk);
force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *)address);
}
2 changes: 1 addition & 1 deletion arch/arm/include/asm/traps.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static inline int __in_irqentry_text(unsigned long ptr)

extern void __init early_trap_init(void *);
extern void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame);
extern void ptrace_break(struct task_struct *tsk, struct pt_regs *regs);
extern void ptrace_break(struct pt_regs *regs);

extern void *vectors_page;

Expand Down
6 changes: 3 additions & 3 deletions arch/arm/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ void ptrace_disable(struct task_struct *child)
/*
* Handle hitting a breakpoint.
*/
void ptrace_break(struct task_struct *tsk, struct pt_regs *regs)
void ptrace_break(struct pt_regs *regs)
{
force_sig_fault(SIGTRAP, TRAP_BRKPT,
(void __user *)instruction_pointer(regs), tsk);
(void __user *)instruction_pointer(regs));
}

static int break_trap(struct pt_regs *regs, unsigned int instr)
{
ptrace_break(current, regs);
ptrace_break(regs);
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions arch/arm/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ asmlinkage int sys_sigreturn(struct pt_regs *regs)
return regs->ARM_r0;

badframe:
force_sig(SIGSEGV, current);
force_sig(SIGSEGV);
return 0;
}

Expand Down Expand Up @@ -280,7 +280,7 @@ asmlinkage int sys_rt_sigreturn(struct pt_regs *regs)
return regs->ARM_r0;

badframe:
force_sig(SIGSEGV, current);
force_sig(SIGSEGV);
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions arch/arm/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ void arm_notify_die(const char *str, struct pt_regs *regs,
current->thread.error_code = err;
current->thread.trap_no = trap;

force_sig_fault(signo, si_code, addr, current);
force_sig_fault(signo, si_code, addr);
} else {
die(str, regs, err);
}
Expand Down Expand Up @@ -603,7 +603,7 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)

case NR(breakpoint): /* SWI BREAK_POINT */
regs->ARM_pc -= thumb_mode(regs) ? 2 : 4;
ptrace_break(current, regs);
ptrace_break(regs);
return regs->ARM_r0;

/*
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mm/alignment.c
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
goto fixup;

if (ai_usermode & UM_SIGNAL) {
force_sig_fault(SIGBUS, BUS_ADRALN, (void __user *)addr, current);
force_sig_fault(SIGBUS, BUS_ADRALN, (void __user *)addr);
} else {
/*
* We're about to disable the alignment trap and return to
Expand Down
13 changes: 7 additions & 6 deletions arch/arm/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,11 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
* User mode accesses just cause a SIGSEGV
*/
static void
__do_user_fault(struct task_struct *tsk, unsigned long addr,
unsigned int fsr, unsigned int sig, int code,
struct pt_regs *regs)
__do_user_fault(unsigned long addr, unsigned int fsr, unsigned int sig,
int code, struct pt_regs *regs)
{
struct task_struct *tsk = current;

if (addr > TASK_SIZE)
harden_branch_predictor();

Expand All @@ -181,7 +182,7 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
tsk->thread.address = addr;
tsk->thread.error_code = fsr;
tsk->thread.trap_no = 14;
force_sig_fault(sig, code, (void __user *)addr, tsk);
force_sig_fault(sig, code, (void __user *)addr);
}

void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
Expand All @@ -194,7 +195,7 @@ void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
* have no context to handle this fault with.
*/
if (user_mode(regs))
__do_user_fault(tsk, addr, fsr, SIGSEGV, SEGV_MAPERR, regs);
__do_user_fault(addr, fsr, SIGSEGV, SEGV_MAPERR, regs);
else
__do_kernel_fault(mm, addr, fsr, regs);
}
Expand Down Expand Up @@ -390,7 +391,7 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
SEGV_ACCERR : SEGV_MAPERR;
}

__do_user_fault(tsk, addr, fsr, sig, code, regs);
__do_user_fault(addr, fsr, sig, code, regs);
return 0;

no_context:
Expand Down
6 changes: 3 additions & 3 deletions arch/arm64/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,16 @@ void arm64_force_sig_fault(int signo, int code, void __user *addr,
{
arm64_show_signal(signo, str);
if (signo == SIGKILL)
force_sig(SIGKILL, current);
force_sig(SIGKILL);
else
force_sig_fault(signo, code, addr, current);
force_sig_fault(signo, code, addr);
}

void arm64_force_sig_mceerr(int code, void __user *addr, short lsb,
const char *str)
{
arm64_show_signal(SIGBUS, str);
force_sig_mceerr(code, addr, lsb, current);
force_sig_mceerr(code, addr, lsb);
}

void arm64_force_sig_ptrace_errno_trap(int errno, void __user *addr,
Expand Down
2 changes: 1 addition & 1 deletion arch/c6x/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ asmlinkage int do_rt_sigreturn(struct pt_regs *regs)
return regs->a4;

badframe:
force_sig(SIGSEGV, current);
force_sig(SIGSEGV);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion arch/c6x/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ static void do_trap(struct exception_info *except_info, struct pt_regs *regs)
die_if_kernel(except_info->kernel_str, regs, addr);

force_sig_fault(except_info->signo, except_info->code,
(void __user *)addr, current);
(void __user *)addr);
}

/*
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 @@ -283,7 +283,7 @@ void csky_alignment(struct pt_regs *regs)
do_exit(SIGKILL);
}

force_sig_fault(SIGBUS, BUS_ADRALN, (void __user *)addr, current);
force_sig_fault(SIGBUS, BUS_ADRALN, (void __user *)addr);
}

static struct ctl_table alignment_tbl[4] = {
Expand Down
2 changes: 1 addition & 1 deletion arch/csky/abiv2/fpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void fpu_fpe(struct pt_regs *regs)
code = FPE_FLTRES;
}

force_sig_fault(sig, code, (void __user *)regs->pc, current);
force_sig_fault(sig, code, (void __user *)regs->pc);
}

#define FMFVR_FPU_REGS(vrx, vry) \
Expand Down
4 changes: 1 addition & 3 deletions arch/csky/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ SYSCALL_DEFINE0(rt_sigreturn)
{
struct pt_regs *regs = current_pt_regs();
struct rt_sigframe __user *frame;
struct task_struct *task;
sigset_t set;

/* Always make any pending restarted system calls return -EINTR */
Expand All @@ -91,8 +90,7 @@ SYSCALL_DEFINE0(rt_sigreturn)
return regs->a0;

badframe:
task = current;
force_sig(SIGSEGV, task);
force_sig(SIGSEGV);
return 0;
}

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 @@ -106,7 +106,7 @@ void buserr(struct pt_regs *regs)
pr_err("User mode Bus Error\n");
show_regs(regs);

force_sig_fault(SIGSEGV, 0, (void __user *)regs->pc, current);
force_sig_fault(SIGSEGV, 0, (void __user *)regs->pc);
}

#define USR_BKPT 0x1464
Expand Down
4 changes: 2 additions & 2 deletions arch/csky/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
bad_area_nosemaphore:
/* User mode accesses just cause a SIGSEGV */
if (user_mode(regs)) {
force_sig_fault(SIGSEGV, si_code, (void __user *)address, current);
force_sig_fault(SIGSEGV, si_code, (void __user *)address);
return;
}

Expand Down Expand Up @@ -212,5 +212,5 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
if (!user_mode(regs))
goto no_context;

force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *)address, current);
force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *)address);
}
4 changes: 2 additions & 2 deletions arch/h8300/kernel/ptrace_h.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ asmlinkage void trace_trap(unsigned long bp)
{
if ((unsigned long)current->thread.breakinfo.addr == bp) {
user_disable_single_step(current);
force_sig(SIGTRAP, current);
force_sig(SIGTRAP);
} else
force_sig(SIGILL, current);
force_sig(SIGILL);
}
2 changes: 1 addition & 1 deletion arch/h8300/kernel/ptrace_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ void user_enable_single_step(struct task_struct *child)
asmlinkage void trace_trap(unsigned long bp)
{
(void)bp;
force_sig(SIGTRAP, current);
force_sig(SIGTRAP);
}
2 changes: 1 addition & 1 deletion arch/h8300/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ asmlinkage int sys_rt_sigreturn(void)
return er0;

badframe:
force_sig(SIGSEGV, current);
force_sig(SIGSEGV);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion arch/hexagon/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,6 @@ asmlinkage int sys_rt_sigreturn(void)
return regs->r00;

badframe:
force_sig(SIGSEGV, current);
force_sig(SIGSEGV);
return 0;
}
12 changes: 6 additions & 6 deletions arch/hexagon/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ int die_if_kernel(char *str, struct pt_regs *regs, long err)
static void misaligned_instruction(struct pt_regs *regs)
{
die_if_kernel("Misaligned Instruction", regs, 0);
force_sig(SIGBUS, current);
force_sig(SIGBUS);
}

/*
Expand All @@ -250,19 +250,19 @@ static void misaligned_instruction(struct pt_regs *regs)
static void misaligned_data_load(struct pt_regs *regs)
{
die_if_kernel("Misaligned Data Load", regs, 0);
force_sig(SIGBUS, current);
force_sig(SIGBUS);
}

static void misaligned_data_store(struct pt_regs *regs)
{
die_if_kernel("Misaligned Data Store", regs, 0);
force_sig(SIGBUS, current);
force_sig(SIGBUS);
}

static void illegal_instruction(struct pt_regs *regs)
{
die_if_kernel("Illegal Instruction", regs, 0);
force_sig(SIGILL, current);
force_sig(SIGILL);
}

/*
Expand All @@ -272,7 +272,7 @@ static void illegal_instruction(struct pt_regs *regs)
static void precise_bus_error(struct pt_regs *regs)
{
die_if_kernel("Precise Bus Error", regs, 0);
force_sig(SIGBUS, current);
force_sig(SIGBUS);
}

/*
Expand Down Expand Up @@ -407,7 +407,7 @@ void do_trap0(struct pt_regs *regs)
* may want to use a different trap0 flavor.
*/
force_sig_fault(SIGTRAP, TRAP_BRKPT,
(void __user *) pt_elr(regs), current);
(void __user *) pt_elr(regs));
} else {
#ifdef CONFIG_KGDB
kgdb_handle_exception(pt_cause(regs), SIGTRAP,
Expand Down
Loading

0 comments on commit 5ad18b2

Please sign in to comment.