diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2018-04-15 20:56:33 -0400 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2018-04-25 11:44:09 -0400 |
commit | c65626c0cd4d3e2f43a5f62fcde4fcd594959938 (patch) | |
tree | 7a63ed0e1595b3692aea2bf21657ef50b500211f | |
parent | 9507a5d01254b96d1b90225b3037e9143149fdc6 (diff) |
signal/sh: Use force_sig_fault where appropriate
Filling in struct siginfo before calling force_sig_info a tedious and
error prone process, where once in a great while the wrong fields
are filled out, and siginfo has been inconsistently cleared.
Simplify this process by using the helper force_sig_fault. Which
takes as a parameters all of the information it needs, ensures
all of the fiddly bits of filling in struct siginfo are done properly
and then calls force_sig_info.
In short about a 5 line reduction in code for every time force_sig_info
is called, which makes the calling function clearer.
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: linux-sh@vger.kernel.org
Acked-by: Rich Felker <dalias@libc.org>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
-rw-r--r-- | arch/sh/kernel/traps_32.c | 19 | ||||
-rw-r--r-- | arch/sh/math-emu/math.c | 9 | ||||
-rw-r--r-- | arch/sh/mm/fault.c | 10 |
3 files changed, 8 insertions, 30 deletions
diff --git a/arch/sh/kernel/traps_32.c b/arch/sh/kernel/traps_32.c index e85e59c3d6df..660a4bc17698 100644 --- a/arch/sh/kernel/traps_32.c +++ b/arch/sh/kernel/traps_32.c | |||
@@ -477,7 +477,6 @@ asmlinkage void do_address_error(struct pt_regs *regs, | |||
477 | { | 477 | { |
478 | unsigned long error_code = 0; | 478 | unsigned long error_code = 0; |
479 | mm_segment_t oldfs; | 479 | mm_segment_t oldfs; |
480 | siginfo_t info; | ||
481 | insn_size_t instruction; | 480 | insn_size_t instruction; |
482 | int tmp; | 481 | int tmp; |
483 | 482 | ||
@@ -537,12 +536,7 @@ uspace_segv: | |||
537 | "access (PC %lx PR %lx)\n", current->comm, regs->pc, | 536 | "access (PC %lx PR %lx)\n", current->comm, regs->pc, |
538 | regs->pr); | 537 | regs->pr); |
539 | 538 | ||
540 | clear_siginfo(&info); | 539 | force_sig_fault(SIGBUS, si_code, (void __user *)address, current); |
541 | info.si_signo = SIGBUS; | ||
542 | info.si_errno = 0; | ||
543 | info.si_code = si_code; | ||
544 | info.si_addr = (void __user *)address; | ||
545 | force_sig_info(SIGBUS, &info, current); | ||
546 | } else { | 540 | } else { |
547 | inc_unaligned_kernel_access(); | 541 | inc_unaligned_kernel_access(); |
548 | 542 | ||
@@ -599,20 +593,17 @@ int is_dsp_inst(struct pt_regs *regs) | |||
599 | #ifdef CONFIG_CPU_SH2A | 593 | #ifdef CONFIG_CPU_SH2A |
600 | asmlinkage void do_divide_error(unsigned long r4) | 594 | asmlinkage void do_divide_error(unsigned long r4) |
601 | { | 595 | { |
602 | siginfo_t info; | 596 | int code; |
603 | 597 | ||
604 | clear_siginfo(&info); | ||
605 | switch (r4) { | 598 | switch (r4) { |
606 | case TRAP_DIVZERO_ERROR: | 599 | case TRAP_DIVZERO_ERROR: |
607 | info.si_code = FPE_INTDIV; | 600 | code = FPE_INTDIV; |
608 | break; | 601 | break; |
609 | case TRAP_DIVOVF_ERROR: | 602 | case TRAP_DIVOVF_ERROR: |
610 | info.si_code = FPE_INTOVF; | 603 | code = FPE_INTOVF; |
611 | break; | 604 | break; |
612 | } | 605 | } |
613 | 606 | force_sig_fault(SIGFPE, code, NULL, current); | |
614 | info.si_signo = SIGFPE; | ||
615 | force_sig_info(info.si_signo, &info, current); | ||
616 | } | 607 | } |
617 | #endif | 608 | #endif |
618 | 609 | ||
diff --git a/arch/sh/math-emu/math.c b/arch/sh/math-emu/math.c index d6d2213df078..a0fa8fc88739 100644 --- a/arch/sh/math-emu/math.c +++ b/arch/sh/math-emu/math.c | |||
@@ -507,7 +507,6 @@ static int ieee_fpe_handler(struct pt_regs *regs) | |||
507 | unsigned short insn = *(unsigned short *)regs->pc; | 507 | unsigned short insn = *(unsigned short *)regs->pc; |
508 | unsigned short finsn; | 508 | unsigned short finsn; |
509 | unsigned long nextpc; | 509 | unsigned long nextpc; |
510 | siginfo_t info; | ||
511 | int nib[4] = { | 510 | int nib[4] = { |
512 | (insn >> 12) & 0xf, | 511 | (insn >> 12) & 0xf, |
513 | (insn >> 8) & 0xf, | 512 | (insn >> 8) & 0xf, |
@@ -560,12 +559,8 @@ static int ieee_fpe_handler(struct pt_regs *regs) | |||
560 | ~(FPSCR_CAUSE_MASK | FPSCR_FLAG_MASK); | 559 | ~(FPSCR_CAUSE_MASK | FPSCR_FLAG_MASK); |
561 | task_thread_info(tsk)->status |= TS_USEDFPU; | 560 | task_thread_info(tsk)->status |= TS_USEDFPU; |
562 | } else { | 561 | } else { |
563 | clear_siginfo(&info); | 562 | force_sig_fault(SIGFPE, FPE_FLTINV, |
564 | info.si_signo = SIGFPE; | 563 | (void __user *)regs->pc, tsk); |
565 | info.si_errno = 0; | ||
566 | info.si_code = FPE_FLTINV; | ||
567 | info.si_addr = (void __user *)regs->pc; | ||
568 | force_sig_info(SIGFPE, &info, tsk); | ||
569 | } | 564 | } |
570 | 565 | ||
571 | regs->pc = nextpc; | 566 | regs->pc = nextpc; |
diff --git a/arch/sh/mm/fault.c b/arch/sh/mm/fault.c index 4c98b6f20e02..b8e7bb84b6b1 100644 --- a/arch/sh/mm/fault.c +++ b/arch/sh/mm/fault.c | |||
@@ -42,15 +42,7 @@ static void | |||
42 | force_sig_info_fault(int si_signo, int si_code, unsigned long address, | 42 | force_sig_info_fault(int si_signo, int si_code, unsigned long address, |
43 | struct task_struct *tsk) | 43 | struct task_struct *tsk) |
44 | { | 44 | { |
45 | siginfo_t info; | 45 | force_sig_fault(si_signo, si_code, (void __user *)address, tsk); |
46 | |||
47 | clear_siginfo(&info); | ||
48 | info.si_signo = si_signo; | ||
49 | info.si_errno = 0; | ||
50 | info.si_code = si_code; | ||
51 | info.si_addr = (void __user *)address; | ||
52 | |||
53 | force_sig_info(si_signo, &info, tsk); | ||
54 | } | 46 | } |
55 | 47 | ||
56 | /* | 48 | /* |