Skip to content

Commit 2c9f7ea

Browse files
committed
signal/sparc: si_trapno is only used with SIGILL ILL_ILLTRP
While reviewing the signal handlers on sparc it became clear that si_trapno is only set to a non-zero value when sending SIGILL with si_code ILL_ILLTRP. Add force_sig_fault_trapno and send SIGILL ILL_ILLTRP with it. Remove the define of __ARCH_SI_TRAPNO and remove the always zero si_trapno parameter from send_sig_fault and force_sig_fault. v1: https://lkml.kernel.org/r/m1eeers7q7.fsf_-_@fess.ebiederm.org v2: https://lkml.kernel.org/r/20210505141101.11519-7-ebiederm@xmission.com Link: https://lkml.kernel.org/r/87mtqnxx89.fsf_-_@disp2133 Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
1 parent 726e337 commit 2c9f7ea

11 files changed

Lines changed: 56 additions & 45 deletions

File tree

arch/sparc/include/uapi/asm/siginfo.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88

99
#endif /* defined(__sparc__) && defined(__arch64__) */
1010

11-
12-
#define __ARCH_SI_TRAPNO
13-
1411
#include <asm-generic/siginfo.h>
1512

1613

arch/sparc/kernel/process_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ void synchronize_user_stack(void)
518518

519519
static void stack_unaligned(unsigned long sp)
520520
{
521-
force_sig_fault(SIGBUS, BUS_ADRALN, (void __user *) sp, 0);
521+
force_sig_fault(SIGBUS, BUS_ADRALN, (void __user *) sp);
522522
}
523523

524524
static const char uwfault32[] = KERN_INFO \

arch/sparc/kernel/sys_sparc_32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ sparc_breakpoint (struct pt_regs *regs)
151151
#ifdef DEBUG_SPARC_BREAKPOINT
152152
printk ("TRAP: Entering kernel PC=%x, nPC=%x\n", regs->pc, regs->npc);
153153
#endif
154-
force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->pc, 0);
154+
force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->pc);
155155

156156
#ifdef DEBUG_SPARC_BREAKPOINT
157157
printk ("TRAP: Returning to space: PC=%x nPC=%x\n", regs->pc, regs->npc);

arch/sparc/kernel/sys_sparc_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ asmlinkage void sparc_breakpoint(struct pt_regs *regs)
514514
#ifdef DEBUG_SPARC_BREAKPOINT
515515
printk ("TRAP: Entering kernel PC=%lx, nPC=%lx\n", regs->tpc, regs->tnpc);
516516
#endif
517-
force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->tpc, 0);
517+
force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->tpc);
518518
#ifdef DEBUG_SPARC_BREAKPOINT
519519
printk ("TRAP: Returning to space: PC=%lx nPC=%lx\n", regs->tpc, regs->tnpc);
520520
#endif

arch/sparc/kernel/traps_32.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ void do_hw_interrupt(struct pt_regs *regs, unsigned long type)
102102
if(regs->psr & PSR_PS)
103103
die_if_kernel("Kernel bad trap", regs);
104104

105-
force_sig_fault(SIGILL, ILL_ILLTRP,
106-
(void __user *)regs->pc, type - 0x80);
105+
force_sig_fault_trapno(SIGILL, ILL_ILLTRP,
106+
(void __user *)regs->pc, type - 0x80);
107107
}
108108

109109
void do_illegal_instruction(struct pt_regs *regs, unsigned long pc, unsigned long npc,
@@ -116,15 +116,15 @@ void do_illegal_instruction(struct pt_regs *regs, unsigned long pc, unsigned lon
116116
regs->pc, *(unsigned long *)regs->pc);
117117
#endif
118118

119-
send_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)pc, 0, current);
119+
send_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)pc, current);
120120
}
121121

122122
void do_priv_instruction(struct pt_regs *regs, unsigned long pc, unsigned long npc,
123123
unsigned long psr)
124124
{
125125
if(psr & PSR_PS)
126126
die_if_kernel("Penguin instruction from Penguin mode??!?!", regs);
127-
send_sig_fault(SIGILL, ILL_PRVOPC, (void __user *)pc, 0, current);
127+
send_sig_fault(SIGILL, ILL_PRVOPC, (void __user *)pc, current);
128128
}
129129

130130
/* XXX User may want to be allowed to do this. XXX */
@@ -145,7 +145,7 @@ void do_memaccess_unaligned(struct pt_regs *regs, unsigned long pc, unsigned lon
145145
#endif
146146
send_sig_fault(SIGBUS, BUS_ADRALN,
147147
/* FIXME: Should dig out mna address */ (void *)0,
148-
0, current);
148+
current);
149149
}
150150

151151
static unsigned long init_fsr = 0x0UL;
@@ -291,7 +291,7 @@ void do_fpe_trap(struct pt_regs *regs, unsigned long pc, unsigned long npc,
291291
else if (fsr & 0x01)
292292
code = FPE_FLTRES;
293293
}
294-
send_sig_fault(SIGFPE, code, (void __user *)pc, 0, fpt);
294+
send_sig_fault(SIGFPE, code, (void __user *)pc, fpt);
295295
#ifndef CONFIG_SMP
296296
last_task_used_math = NULL;
297297
#endif
@@ -305,7 +305,7 @@ void handle_tag_overflow(struct pt_regs *regs, unsigned long pc, unsigned long n
305305
{
306306
if(psr & PSR_PS)
307307
die_if_kernel("Penguin overflow trap from kernel mode", regs);
308-
send_sig_fault(SIGEMT, EMT_TAGOVF, (void __user *)pc, 0, current);
308+
send_sig_fault(SIGEMT, EMT_TAGOVF, (void __user *)pc, current);
309309
}
310310

311311
void handle_watchpoint(struct pt_regs *regs, unsigned long pc, unsigned long npc,
@@ -327,13 +327,13 @@ void handle_reg_access(struct pt_regs *regs, unsigned long pc, unsigned long npc
327327
printk("Register Access Exception at PC %08lx NPC %08lx PSR %08lx\n",
328328
pc, npc, psr);
329329
#endif
330-
force_sig_fault(SIGBUS, BUS_OBJERR, (void __user *)pc, 0);
330+
force_sig_fault(SIGBUS, BUS_OBJERR, (void __user *)pc);
331331
}
332332

333333
void handle_cp_disabled(struct pt_regs *regs, unsigned long pc, unsigned long npc,
334334
unsigned long psr)
335335
{
336-
send_sig_fault(SIGILL, ILL_COPROC, (void __user *)pc, 0, current);
336+
send_sig_fault(SIGILL, ILL_COPROC, (void __user *)pc, current);
337337
}
338338

339339
void handle_cp_exception(struct pt_regs *regs, unsigned long pc, unsigned long npc,
@@ -343,13 +343,13 @@ void handle_cp_exception(struct pt_regs *regs, unsigned long pc, unsigned long n
343343
printk("Co-Processor Exception at PC %08lx NPC %08lx PSR %08lx\n",
344344
pc, npc, psr);
345345
#endif
346-
send_sig_fault(SIGILL, ILL_COPROC, (void __user *)pc, 0, current);
346+
send_sig_fault(SIGILL, ILL_COPROC, (void __user *)pc, current);
347347
}
348348

349349
void handle_hw_divzero(struct pt_regs *regs, unsigned long pc, unsigned long npc,
350350
unsigned long psr)
351351
{
352-
send_sig_fault(SIGFPE, FPE_INTDIV, (void __user *)pc, 0, current);
352+
send_sig_fault(SIGFPE, FPE_INTDIV, (void __user *)pc, current);
353353
}
354354

355355
#ifdef CONFIG_DEBUG_BUGVERBOSE

arch/sparc/kernel/traps_64.c

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ void bad_trap(struct pt_regs *regs, long lvl)
107107
regs->tpc &= 0xffffffff;
108108
regs->tnpc &= 0xffffffff;
109109
}
110-
force_sig_fault(SIGILL, ILL_ILLTRP,
111-
(void __user *)regs->tpc, lvl);
110+
force_sig_fault_trapno(SIGILL, ILL_ILLTRP,
111+
(void __user *)regs->tpc, lvl);
112112
}
113113

114114
void bad_trap_tl1(struct pt_regs *regs, long lvl)
@@ -201,8 +201,7 @@ void spitfire_insn_access_exception(struct pt_regs *regs, unsigned long sfsr, un
201201
regs->tpc &= 0xffffffff;
202202
regs->tnpc &= 0xffffffff;
203203
}
204-
force_sig_fault(SIGSEGV, SEGV_MAPERR,
205-
(void __user *)regs->tpc, 0);
204+
force_sig_fault(SIGSEGV, SEGV_MAPERR, (void __user *)regs->tpc);
206205
out:
207206
exception_exit(prev_state);
208207
}
@@ -237,7 +236,7 @@ void sun4v_insn_access_exception(struct pt_regs *regs, unsigned long addr, unsig
237236
regs->tpc &= 0xffffffff;
238237
regs->tnpc &= 0xffffffff;
239238
}
240-
force_sig_fault(SIGSEGV, SEGV_MAPERR, (void __user *) addr, 0);
239+
force_sig_fault(SIGSEGV, SEGV_MAPERR, (void __user *) addr);
241240
}
242241

243242
void sun4v_insn_access_exception_tl1(struct pt_regs *regs, unsigned long addr, unsigned long type_ctx)
@@ -321,7 +320,7 @@ void spitfire_data_access_exception(struct pt_regs *regs, unsigned long sfsr, un
321320
if (is_no_fault_exception(regs))
322321
return;
323322

324-
force_sig_fault(SIGSEGV, SEGV_MAPERR, (void __user *)sfar, 0);
323+
force_sig_fault(SIGSEGV, SEGV_MAPERR, (void __user *)sfar);
325324
out:
326325
exception_exit(prev_state);
327326
}
@@ -385,13 +384,13 @@ void sun4v_data_access_exception(struct pt_regs *regs, unsigned long addr, unsig
385384
*/
386385
switch (type) {
387386
case HV_FAULT_TYPE_INV_ASI:
388-
force_sig_fault(SIGILL, ILL_ILLADR, (void __user *)addr, 0);
387+
force_sig_fault(SIGILL, ILL_ILLADR, (void __user *)addr);
389388
break;
390389
case HV_FAULT_TYPE_MCD_DIS:
391-
force_sig_fault(SIGSEGV, SEGV_ACCADI, (void __user *)addr, 0);
390+
force_sig_fault(SIGSEGV, SEGV_ACCADI, (void __user *)addr);
392391
break;
393392
default:
394-
force_sig_fault(SIGSEGV, SEGV_MAPERR, (void __user *)addr, 0);
393+
force_sig_fault(SIGSEGV, SEGV_MAPERR, (void __user *)addr);
395394
break;
396395
}
397396
}
@@ -568,7 +567,7 @@ static void spitfire_ue_log(unsigned long afsr, unsigned long afar, unsigned lon
568567
regs->tpc &= 0xffffffff;
569568
regs->tnpc &= 0xffffffff;
570569
}
571-
force_sig_fault(SIGBUS, BUS_OBJERR, (void *)0, 0);
570+
force_sig_fault(SIGBUS, BUS_OBJERR, (void *)0);
572571
}
573572

574573
void spitfire_access_error(struct pt_regs *regs, unsigned long status_encoded, unsigned long afar)
@@ -2069,8 +2068,7 @@ void do_mcd_err(struct pt_regs *regs, struct sun4v_error_entry ent)
20692068
/* Send SIGSEGV to the userspace process with the right signal
20702069
* code
20712070
*/
2072-
force_sig_fault(SIGSEGV, SEGV_ADIDERR, (void __user *)ent.err_raddr,
2073-
0);
2071+
force_sig_fault(SIGSEGV, SEGV_ADIDERR, (void __user *)ent.err_raddr);
20742072
}
20752073

20762074
/* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
@@ -2184,7 +2182,7 @@ bool sun4v_nonresum_error_user_handled(struct pt_regs *regs,
21842182
}
21852183
if (attrs & SUN4V_ERR_ATTRS_PIO) {
21862184
force_sig_fault(SIGBUS, BUS_ADRERR,
2187-
(void __user *)sun4v_get_vaddr(regs), 0);
2185+
(void __user *)sun4v_get_vaddr(regs));
21882186
return true;
21892187
}
21902188

@@ -2340,8 +2338,7 @@ static void do_fpe_common(struct pt_regs *regs)
23402338
else if (fsr & 0x01)
23412339
code = FPE_FLTRES;
23422340
}
2343-
force_sig_fault(SIGFPE, code,
2344-
(void __user *)regs->tpc, 0);
2341+
force_sig_fault(SIGFPE, code, (void __user *)regs->tpc);
23452342
}
23462343
}
23472344

@@ -2395,8 +2392,7 @@ void do_tof(struct pt_regs *regs)
23952392
regs->tpc &= 0xffffffff;
23962393
regs->tnpc &= 0xffffffff;
23972394
}
2398-
force_sig_fault(SIGEMT, EMT_TAGOVF,
2399-
(void __user *)regs->tpc, 0);
2395+
force_sig_fault(SIGEMT, EMT_TAGOVF, (void __user *)regs->tpc);
24002396
out:
24012397
exception_exit(prev_state);
24022398
}
@@ -2415,8 +2411,7 @@ void do_div0(struct pt_regs *regs)
24152411
regs->tpc &= 0xffffffff;
24162412
regs->tnpc &= 0xffffffff;
24172413
}
2418-
force_sig_fault(SIGFPE, FPE_INTDIV,
2419-
(void __user *)regs->tpc, 0);
2414+
force_sig_fault(SIGFPE, FPE_INTDIV, (void __user *)regs->tpc);
24202415
out:
24212416
exception_exit(prev_state);
24222417
}
@@ -2612,7 +2607,7 @@ void do_illegal_instruction(struct pt_regs *regs)
26122607
}
26132608
}
26142609
}
2615-
force_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)pc, 0);
2610+
force_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)pc);
26162611
out:
26172612
exception_exit(prev_state);
26182613
}
@@ -2632,7 +2627,7 @@ void mem_address_unaligned(struct pt_regs *regs, unsigned long sfar, unsigned lo
26322627
if (is_no_fault_exception(regs))
26332628
return;
26342629

2635-
force_sig_fault(SIGBUS, BUS_ADRALN, (void __user *)sfar, 0);
2630+
force_sig_fault(SIGBUS, BUS_ADRALN, (void __user *)sfar);
26362631
out:
26372632
exception_exit(prev_state);
26382633
}
@@ -2650,7 +2645,7 @@ void sun4v_do_mna(struct pt_regs *regs, unsigned long addr, unsigned long type_c
26502645
if (is_no_fault_exception(regs))
26512646
return;
26522647

2653-
force_sig_fault(SIGBUS, BUS_ADRALN, (void __user *) addr, 0);
2648+
force_sig_fault(SIGBUS, BUS_ADRALN, (void __user *) addr);
26542649
}
26552650

26562651
/* sun4v_mem_corrupt_detect_precise() - Handle precise exception on an ADI
@@ -2697,7 +2692,7 @@ void sun4v_mem_corrupt_detect_precise(struct pt_regs *regs, unsigned long addr,
26972692
regs->tpc &= 0xffffffff;
26982693
regs->tnpc &= 0xffffffff;
26992694
}
2700-
force_sig_fault(SIGSEGV, SEGV_ADIPERR, (void __user *)addr, 0);
2695+
force_sig_fault(SIGSEGV, SEGV_ADIPERR, (void __user *)addr);
27012696
}
27022697

27032698
void do_privop(struct pt_regs *regs)
@@ -2712,8 +2707,7 @@ void do_privop(struct pt_regs *regs)
27122707
regs->tpc &= 0xffffffff;
27132708
regs->tnpc &= 0xffffffff;
27142709
}
2715-
force_sig_fault(SIGILL, ILL_PRVOPC,
2716-
(void __user *)regs->tpc, 0);
2710+
force_sig_fault(SIGILL, ILL_PRVOPC, (void __user *)regs->tpc);
27172711
out:
27182712
exception_exit(prev_state);
27192713
}

arch/sparc/kernel/unaligned_32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,5 +278,5 @@ asmlinkage void user_unaligned_trap(struct pt_regs *regs, unsigned int insn)
278278
{
279279
send_sig_fault(SIGBUS, BUS_ADRALN,
280280
(void __user *)safe_compute_effective_address(regs, insn),
281-
0, current);
281+
current);
282282
}

arch/sparc/mm/fault_32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static void __do_fault_siginfo(int code, int sig, struct pt_regs *regs,
8383
show_signal_msg(regs, sig, code,
8484
addr, current);
8585

86-
force_sig_fault(sig, code, (void __user *) addr, 0);
86+
force_sig_fault(sig, code, (void __user *) addr);
8787
}
8888

8989
static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)

arch/sparc/mm/fault_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
176176
if (unlikely(show_unhandled_signals))
177177
show_signal_msg(regs, sig, code, addr, current);
178178

179-
force_sig_fault(sig, code, (void __user *) addr, 0);
179+
force_sig_fault(sig, code, (void __user *) addr);
180180
}
181181

182182
static unsigned int get_fault_insn(struct pt_regs *regs, unsigned int insn)

include/linux/sched/signal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ int force_sig_pkuerr(void __user *addr, u32 pkey);
329329
int force_sig_perf(void __user *addr, u32 type, u64 sig_data);
330330

331331
int force_sig_ptrace_errno_trap(int errno, void __user *addr);
332+
int force_sig_fault_trapno(int sig, int code, void __user *addr, int trapno);
332333

333334
extern int send_sig_info(int, struct kernel_siginfo *, struct task_struct *);
334335
extern void force_sigsegv(int sig);

0 commit comments

Comments
 (0)