Skip to content

Commit 05e792e

Browse files
committed
signal/arm: Push siginfo generation into arm_notify_die
In arm_notify_die call force_sig_fault to let the generic code handle siginfo generation. This removes some boiler plate making the code easier to maintain in the long run. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
1 parent c852680 commit 05e792e

4 files changed

Lines changed: 30 additions & 71 deletions

File tree

‎arch/arm/include/asm/bug.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ do { \
6262
struct pt_regs;
6363
void die(const char *msg, struct pt_regs *regs, int err);
6464

65-
struct siginfo;
66-
void arm_notify_die(const char *str, struct pt_regs *regs, struct siginfo *info,
65+
void arm_notify_die(const char *str, struct pt_regs *regs,
66+
int signo, int si_code, void __user *addr,
6767
unsigned long err, unsigned long trap);
6868

6969
#ifdef CONFIG_ARM_LPAE

‎arch/arm/kernel/swp_emulate.c‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,22 +98,20 @@ static int proc_status_show(struct seq_file *m, void *v)
9898
*/
9999
static void set_segfault(struct pt_regs *regs, unsigned long addr)
100100
{
101-
siginfo_t info;
101+
int si_code;
102102

103-
clear_siginfo(&info);
104103
down_read(&current->mm->mmap_sem);
105104
if (find_vma(current->mm, addr) == NULL)
106-
info.si_code = SEGV_MAPERR;
105+
si_code = SEGV_MAPERR;
107106
else
108-
info.si_code = SEGV_ACCERR;
107+
si_code = SEGV_ACCERR;
109108
up_read(&current->mm->mmap_sem);
110109

111-
info.si_signo = SIGSEGV;
112-
info.si_errno = 0;
113-
info.si_addr = (void *) instruction_pointer(regs);
114-
115110
pr_debug("SWP{B} emulation: access caused memory abort!\n");
116-
arm_notify_die("Illegal memory access", regs, &info, 0, 0);
111+
arm_notify_die("Illegal memory access", regs,
112+
SIGSEGV, si_code,
113+
(void __user *)instruction_pointer(regs),
114+
0, 0);
117115

118116
abtcounter++;
119117
}

‎arch/arm/kernel/traps.c‎

Lines changed: 17 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,14 @@ void die(const char *str, struct pt_regs *regs, int err)
365365
}
366366

367367
void arm_notify_die(const char *str, struct pt_regs *regs,
368-
struct siginfo *info, unsigned long err, unsigned long trap)
368+
int signo, int si_code, void __user *addr,
369+
unsigned long err, unsigned long trap)
369370
{
370371
if (user_mode(regs)) {
371372
current->thread.error_code = err;
372373
current->thread.trap_no = trap;
373374

374-
force_sig_info(info->si_signo, info, current);
375+
force_sig_fault(signo, si_code, addr, current);
375376
} else {
376377
die(str, regs, err);
377378
}
@@ -438,10 +439,8 @@ int call_undef_hook(struct pt_regs *regs, unsigned int instr)
438439
asmlinkage void do_undefinstr(struct pt_regs *regs)
439440
{
440441
unsigned int instr;
441-
siginfo_t info;
442442
void __user *pc;
443443

444-
clear_siginfo(&info);
445444
pc = (void __user *)instruction_pointer(regs);
446445

447446
if (processor_mode(regs) == SVC_MODE) {
@@ -485,13 +484,8 @@ asmlinkage void do_undefinstr(struct pt_regs *regs)
485484
dump_instr(KERN_INFO, regs);
486485
}
487486
#endif
488-
489-
info.si_signo = SIGILL;
490-
info.si_errno = 0;
491-
info.si_code = ILL_ILLOPC;
492-
info.si_addr = pc;
493-
494-
arm_notify_die("Oops - undefined instruction", regs, &info, 0, 6);
487+
arm_notify_die("Oops - undefined instruction", regs,
488+
SIGILL, ILL_ILLOPC, pc, 0, 6);
495489
}
496490
NOKPROBE_SYMBOL(do_undefinstr)
497491

@@ -539,9 +533,6 @@ asmlinkage void bad_mode(struct pt_regs *regs, int reason)
539533

540534
static int bad_syscall(int n, struct pt_regs *regs)
541535
{
542-
siginfo_t info;
543-
544-
clear_siginfo(&info);
545536
if ((current->personality & PER_MASK) != PER_LINUX) {
546537
send_sig(SIGSEGV, current, 1);
547538
return regs->ARM_r0;
@@ -555,13 +546,10 @@ static int bad_syscall(int n, struct pt_regs *regs)
555546
}
556547
#endif
557548

558-
info.si_signo = SIGILL;
559-
info.si_errno = 0;
560-
info.si_code = ILL_ILLTRP;
561-
info.si_addr = (void __user *)instruction_pointer(regs) -
562-
(thumb_mode(regs) ? 2 : 4);
563-
564-
arm_notify_die("Oops - bad syscall", regs, &info, n, 0);
549+
arm_notify_die("Oops - bad syscall", regs, SIGILL, ILL_ILLTRP,
550+
(void __user *)instruction_pointer(regs) -
551+
(thumb_mode(regs) ? 2 : 4),
552+
n, 0);
565553

566554
return regs->ARM_r0;
567555
}
@@ -607,20 +595,13 @@ do_cache_op(unsigned long start, unsigned long end, int flags)
607595
#define NR(x) ((__ARM_NR_##x) - __ARM_NR_BASE)
608596
asmlinkage int arm_syscall(int no, struct pt_regs *regs)
609597
{
610-
siginfo_t info;
611-
612-
clear_siginfo(&info);
613598
if ((no >> 16) != (__ARM_NR_BASE>> 16))
614599
return bad_syscall(no, regs);
615600

616601
switch (no & 0xffff) {
617602
case 0: /* branch through 0 */
618-
info.si_signo = SIGSEGV;
619-
info.si_errno = 0;
620-
info.si_code = SEGV_MAPERR;
621-
info.si_addr = NULL;
622-
623-
arm_notify_die("branch through zero", regs, &info, 0, 0);
603+
arm_notify_die("branch through zero", regs,
604+
SIGSEGV, SEGV_MAPERR, NULL, 0, 0);
624605
return 0;
625606

626607
case NR(breakpoint): /* SWI BREAK_POINT */
@@ -688,13 +669,10 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
688669
}
689670
}
690671
#endif
691-
info.si_signo = SIGILL;
692-
info.si_errno = 0;
693-
info.si_code = ILL_ILLTRP;
694-
info.si_addr = (void __user *)instruction_pointer(regs) -
695-
(thumb_mode(regs) ? 2 : 4);
696-
697-
arm_notify_die("Oops - bad syscall(2)", regs, &info, no, 0);
672+
arm_notify_die("Oops - bad syscall(2)", regs, SIGILL, ILL_ILLTRP,
673+
(void __user *)instruction_pointer(regs) -
674+
(thumb_mode(regs) ? 2 : 4),
675+
no, 0);
698676
return 0;
699677
}
700678

@@ -744,9 +722,6 @@ asmlinkage void
744722
baddataabort(int code, unsigned long instr, struct pt_regs *regs)
745723
{
746724
unsigned long addr = instruction_pointer(regs);
747-
siginfo_t info;
748-
749-
clear_siginfo(&info);
750725

751726
#ifdef CONFIG_DEBUG_USER
752727
if (user_debug & UDBG_BADABORT) {
@@ -757,12 +732,8 @@ baddataabort(int code, unsigned long instr, struct pt_regs *regs)
757732
}
758733
#endif
759734

760-
info.si_signo = SIGILL;
761-
info.si_errno = 0;
762-
info.si_code = ILL_ILLOPC;
763-
info.si_addr = (void __user *)addr;
764-
765-
arm_notify_die("unknown data abort code", regs, &info, instr, 0);
735+
arm_notify_die("unknown data abort code", regs,
736+
SIGILL, ILL_ILLOPC, (void __user *)addr, instr, 0);
766737
}
767738

768739
void __readwrite_bug(const char *fn)

‎arch/arm/mm/fault.c‎

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,6 @@ asmlinkage void
554554
do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
555555
{
556556
const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
557-
struct siginfo info;
558557

559558
if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
560559
return;
@@ -563,12 +562,8 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
563562
inf->name, fsr, addr);
564563
show_pte(current->mm, addr);
565564

566-
clear_siginfo(&info);
567-
info.si_signo = inf->sig;
568-
info.si_errno = 0;
569-
info.si_code = inf->code;
570-
info.si_addr = (void __user *)addr;
571-
arm_notify_die("", regs, &info, fsr, 0);
565+
arm_notify_die("", regs, inf->sig, inf->code, (void __user *)addr,
566+
fsr, 0);
572567
}
573568

574569
void __init
@@ -588,20 +583,15 @@ asmlinkage void
588583
do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
589584
{
590585
const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
591-
struct siginfo info;
592586

593587
if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
594588
return;
595589

596590
pr_alert("Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
597591
inf->name, ifsr, addr);
598592

599-
clear_siginfo(&info);
600-
info.si_signo = inf->sig;
601-
info.si_errno = 0;
602-
info.si_code = inf->code;
603-
info.si_addr = (void __user *)addr;
604-
arm_notify_die("", regs, &info, ifsr, 0);
593+
arm_notify_die("", regs, inf->sig, inf->code, (void __user *)addr,
594+
ifsr, 0);
605595
}
606596

607597
/*

0 commit comments

Comments
 (0)