Skip to content

Commit 93e95fa

Browse files
committed
Merge branch 'siginfo-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace
Pull siginfo updates from Eric Biederman: "This set of changes close the known issues with setting si_code to an invalid value, and with not fully initializing struct siginfo. There remains work to do on nds32, arc, unicore32, powerpc, arm, arm64, ia64 and x86 to get the code that generates siginfo into a simpler and more maintainable state. Most of that work involves refactoring the signal handling code and thus careful code review. Also not included is the work to shrink the in kernel version of struct siginfo. That depends on getting the number of places that directly manipulate struct siginfo under control, as it requires the introduction of struct kernel_siginfo for the in kernel things. Overall this set of changes looks like it is making good progress, and with a little luck I will be wrapping up the siginfo work next development cycle" * 'siginfo-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace: (46 commits) signal/sh: Stop gcc warning about an impossible case in do_divide_error signal/mips: Report FPE_FLTUNK for undiagnosed floating point exceptions signal/um: More carefully relay signals in relay_signal. signal: Extend siginfo_layout with SIL_FAULT_{MCEERR|BNDERR|PKUERR} signal: Remove unncessary #ifdef SEGV_PKUERR in 32bit compat code signal/signalfd: Add support for SIGSYS signal/signalfd: Remove __put_user from signalfd_copyinfo signal/xtensa: Use force_sig_fault where appropriate signal/xtensa: Consistenly use SIGBUS in do_unaligned_user signal/um: Use force_sig_fault where appropriate signal/sparc: Use force_sig_fault where appropriate signal/sparc: Use send_sig_fault where appropriate signal/sh: Use force_sig_fault where appropriate signal/s390: Use force_sig_fault where appropriate signal/riscv: Replace do_trap_siginfo with force_sig_fault signal/riscv: Use force_sig_fault where appropriate signal/parisc: Use force_sig_fault where appropriate signal/parisc: Use force_sig_mceerr where appropriate signal/openrisc: Use force_sig_fault where appropriate signal/nios2: Use force_sig_fault where appropriate ...
2 parents d8aed84 + 26da350 commit 93e95fa

83 files changed

Lines changed: 493 additions & 1066 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎arch/alpha/include/uapi/asm/siginfo.h‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,4 @@
77

88
#include <asm-generic/siginfo.h>
99

10-
/*
11-
* SIGFPE si_codes
12-
*/
13-
#ifdef __KERNEL__
14-
#define FPE_FIXME 0 /* Broken dup of SI_USER */
15-
#endif /* __KERNEL__ */
16-
17-
/*
18-
* SIGTRAP si_codes
19-
*/
20-
#ifdef __KERNEL__
21-
#define TRAP_FIXME 0 /* Broken dup of SI_USER */
22-
#endif /* __KERNEL__ */
23-
2410
#endif

‎arch/alpha/kernel/osf_sys.c‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -871,8 +871,7 @@ SYSCALL_DEFINE5(osf_setsysinfo, unsigned long, op, void __user *, buffer,
871871
send a signal. Old exceptions are not signaled. */
872872
fex = (exc >> IEEE_STATUS_TO_EXCSUM_SHIFT) & swcr;
873873
if (fex) {
874-
siginfo_t info;
875-
int si_code = 0;
874+
int si_code = FPE_FLTUNK;
876875

877876
if (fex & IEEE_TRAP_ENABLE_DNO) si_code = FPE_FLTUND;
878877
if (fex & IEEE_TRAP_ENABLE_INE) si_code = FPE_FLTRES;
@@ -881,11 +880,9 @@ SYSCALL_DEFINE5(osf_setsysinfo, unsigned long, op, void __user *, buffer,
881880
if (fex & IEEE_TRAP_ENABLE_DZE) si_code = FPE_FLTDIV;
882881
if (fex & IEEE_TRAP_ENABLE_INV) si_code = FPE_FLTINV;
883882

884-
info.si_signo = SIGFPE;
885-
info.si_errno = 0;
886-
info.si_code = si_code;
887-
info.si_addr = NULL; /* FIXME */
888-
send_sig_info(SIGFPE, &info, current);
883+
send_sig_fault(SIGFPE, si_code,
884+
(void __user *)NULL, /* FIXME */
885+
0, current);
889886
}
890887
return 0;
891888
}

‎arch/alpha/kernel/signal.c‎

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,8 @@ do_sigreturn(struct sigcontext __user *sc)
219219

220220
/* Send SIGTRAP if we're single-stepping: */
221221
if (ptrace_cancel_bpt (current)) {
222-
siginfo_t info;
223-
224-
info.si_signo = SIGTRAP;
225-
info.si_errno = 0;
226-
info.si_code = TRAP_BRKPT;
227-
info.si_addr = (void __user *) regs->pc;
228-
info.si_trapno = 0;
229-
send_sig_info(SIGTRAP, &info, current);
222+
send_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *) regs->pc, 0,
223+
current);
230224
}
231225
return;
232226

@@ -253,14 +247,8 @@ do_rt_sigreturn(struct rt_sigframe __user *frame)
253247

254248
/* Send SIGTRAP if we're single-stepping: */
255249
if (ptrace_cancel_bpt (current)) {
256-
siginfo_t info;
257-
258-
info.si_signo = SIGTRAP;
259-
info.si_errno = 0;
260-
info.si_code = TRAP_BRKPT;
261-
info.si_addr = (void __user *) regs->pc;
262-
info.si_trapno = 0;
263-
send_sig_info(SIGTRAP, &info, current);
250+
send_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *) regs->pc, 0,
251+
current);
264252
}
265253
return;
266254

‎arch/alpha/kernel/traps.c‎

Lines changed: 20 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ do_entArith(unsigned long summary, unsigned long write_mask,
213213
struct pt_regs *regs)
214214
{
215215
long si_code = FPE_FLTINV;
216-
siginfo_t info;
217216

218217
if (summary & 1) {
219218
/* Software-completion summary bit is set, so try to
@@ -228,17 +227,12 @@ do_entArith(unsigned long summary, unsigned long write_mask,
228227
}
229228
die_if_kernel("Arithmetic fault", regs, 0, NULL);
230229

231-
info.si_signo = SIGFPE;
232-
info.si_errno = 0;
233-
info.si_code = si_code;
234-
info.si_addr = (void __user *) regs->pc;
235-
send_sig_info(SIGFPE, &info, current);
230+
send_sig_fault(SIGFPE, si_code, (void __user *) regs->pc, 0, current);
236231
}
237232

238233
asmlinkage void
239234
do_entIF(unsigned long type, struct pt_regs *regs)
240235
{
241-
siginfo_t info;
242236
int signo, code;
243237

244238
if ((regs->ps & ~IPL_MAX) == 0) {
@@ -270,31 +264,20 @@ do_entIF(unsigned long type, struct pt_regs *regs)
270264

271265
switch (type) {
272266
case 0: /* breakpoint */
273-
info.si_signo = SIGTRAP;
274-
info.si_errno = 0;
275-
info.si_code = TRAP_BRKPT;
276-
info.si_trapno = 0;
277-
info.si_addr = (void __user *) regs->pc;
278-
279267
if (ptrace_cancel_bpt(current)) {
280268
regs->pc -= 4; /* make pc point to former bpt */
281269
}
282270

283-
send_sig_info(SIGTRAP, &info, current);
271+
send_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->pc, 0,
272+
current);
284273
return;
285274

286275
case 1: /* bugcheck */
287-
info.si_signo = SIGTRAP;
288-
info.si_errno = 0;
289-
info.si_code = TRAP_FIXME;
290-
info.si_addr = (void __user *) regs->pc;
291-
info.si_trapno = 0;
292-
send_sig_info(SIGTRAP, &info, current);
276+
send_sig_fault(SIGTRAP, TRAP_UNK, (void __user *) regs->pc, 0,
277+
current);
293278
return;
294279

295280
case 2: /* gentrap */
296-
info.si_addr = (void __user *) regs->pc;
297-
info.si_trapno = regs->r16;
298281
switch ((long) regs->r16) {
299282
case GEN_INTOVF:
300283
signo = SIGFPE;
@@ -326,7 +309,7 @@ do_entIF(unsigned long type, struct pt_regs *regs)
326309
break;
327310
case GEN_ROPRAND:
328311
signo = SIGFPE;
329-
code = FPE_FIXME;
312+
code = FPE_FLTUNK;
330313
break;
331314

332315
case GEN_DECOVF:
@@ -348,15 +331,12 @@ do_entIF(unsigned long type, struct pt_regs *regs)
348331
case GEN_SUBRNG7:
349332
default:
350333
signo = SIGTRAP;
351-
code = TRAP_FIXME;
334+
code = TRAP_UNK;
352335
break;
353336
}
354337

355-
info.si_signo = signo;
356-
info.si_errno = 0;
357-
info.si_code = code;
358-
info.si_addr = (void __user *) regs->pc;
359-
send_sig_info(signo, &info, current);
338+
send_sig_fault(signo, code, (void __user *) regs->pc, regs->r16,
339+
current);
360340
return;
361341

362342
case 4: /* opDEC */
@@ -380,11 +360,9 @@ do_entIF(unsigned long type, struct pt_regs *regs)
380360
if (si_code == 0)
381361
return;
382362
if (si_code > 0) {
383-
info.si_signo = SIGFPE;
384-
info.si_errno = 0;
385-
info.si_code = si_code;
386-
info.si_addr = (void __user *) regs->pc;
387-
send_sig_info(SIGFPE, &info, current);
363+
send_sig_fault(SIGFPE, si_code,
364+
(void __user *) regs->pc, 0,
365+
current);
388366
return;
389367
}
390368
}
@@ -409,11 +387,7 @@ do_entIF(unsigned long type, struct pt_regs *regs)
409387
;
410388
}
411389

412-
info.si_signo = SIGILL;
413-
info.si_errno = 0;
414-
info.si_code = ILL_ILLOPC;
415-
info.si_addr = (void __user *) regs->pc;
416-
send_sig_info(SIGILL, &info, current);
390+
send_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)regs->pc, 0, current);
417391
}
418392

419393
/* There is an ifdef in the PALcode in MILO that enables a
@@ -426,15 +400,9 @@ do_entIF(unsigned long type, struct pt_regs *regs)
426400
asmlinkage void
427401
do_entDbg(struct pt_regs *regs)
428402
{
429-
siginfo_t info;
430-
431403
die_if_kernel("Instruction fault", regs, 0, NULL);
432404

433-
info.si_signo = SIGILL;
434-
info.si_errno = 0;
435-
info.si_code = ILL_ILLOPC;
436-
info.si_addr = (void __user *) regs->pc;
437-
force_sig_info(SIGILL, &info, current);
405+
force_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)regs->pc, 0, current);
438406
}
439407

440408

@@ -758,7 +726,7 @@ do_entUnaUser(void __user * va, unsigned long opcode,
758726

759727
unsigned long tmp1, tmp2, tmp3, tmp4;
760728
unsigned long fake_reg, *reg_addr = &fake_reg;
761-
siginfo_t info;
729+
int si_code;
762730
long error;
763731

764732
/* Check the UAC bits to decide what the user wants us to do
@@ -981,34 +949,27 @@ do_entUnaUser(void __user * va, unsigned long opcode,
981949

982950
give_sigsegv:
983951
regs->pc -= 4; /* make pc point to faulting insn */
984-
info.si_signo = SIGSEGV;
985-
info.si_errno = 0;
986952

987953
/* We need to replicate some of the logic in mm/fault.c,
988954
since we don't have access to the fault code in the
989955
exception handling return path. */
990956
if ((unsigned long)va >= TASK_SIZE)
991-
info.si_code = SEGV_ACCERR;
957+
si_code = SEGV_ACCERR;
992958
else {
993959
struct mm_struct *mm = current->mm;
994960
down_read(&mm->mmap_sem);
995961
if (find_vma(mm, (unsigned long)va))
996-
info.si_code = SEGV_ACCERR;
962+
si_code = SEGV_ACCERR;
997963
else
998-
info.si_code = SEGV_MAPERR;
964+
si_code = SEGV_MAPERR;
999965
up_read(&mm->mmap_sem);
1000966
}
1001-
info.si_addr = va;
1002-
send_sig_info(SIGSEGV, &info, current);
967+
send_sig_fault(SIGSEGV, si_code, va, 0, current);
1003968
return;
1004969

1005970
give_sigbus:
1006971
regs->pc -= 4;
1007-
info.si_signo = SIGBUS;
1008-
info.si_errno = 0;
1009-
info.si_code = BUS_ADRALN;
1010-
info.si_addr = va;
1011-
send_sig_info(SIGBUS, &info, current);
972+
send_sig_fault(SIGBUS, BUS_ADRALN, va, 0, current);
1012973
return;
1013974
}
1014975

‎arch/alpha/mm/fault.c‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ do_page_fault(unsigned long address, unsigned long mmcsr,
8888
struct mm_struct *mm = current->mm;
8989
const struct exception_table_entry *fixup;
9090
int fault, si_code = SEGV_MAPERR;
91-
siginfo_t info;
9291
unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
9392

9493
/* As of EV6, a load into $31/$f31 is a prefetch, and never faults
@@ -221,21 +220,13 @@ do_page_fault(unsigned long address, unsigned long mmcsr,
221220
up_read(&mm->mmap_sem);
222221
/* Send a sigbus, regardless of whether we were in kernel
223222
or user mode. */
224-
info.si_signo = SIGBUS;
225-
info.si_errno = 0;
226-
info.si_code = BUS_ADRERR;
227-
info.si_addr = (void __user *) address;
228-
force_sig_info(SIGBUS, &info, current);
223+
force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *) address, 0, current);
229224
if (!user_mode(regs))
230225
goto no_context;
231226
return;
232227

233228
do_sigsegv:
234-
info.si_signo = SIGSEGV;
235-
info.si_errno = 0;
236-
info.si_code = si_code;
237-
info.si_addr = (void __user *) address;
238-
force_sig_info(SIGSEGV, &info, current);
229+
force_sig_fault(SIGSEGV, si_code, (void __user *) address, 0, current);
239230
return;
240231

241232
#ifdef CONFIG_ALPHA_LARGE_VMALLOC

‎arch/arc/mm/fault.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ void do_page_fault(unsigned long address, struct pt_regs *regs)
7070
int write = regs->ecr_cause & ECR_C_PROTV_STORE; /* ST/EX */
7171
unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
7272

73+
clear_siginfo(&info);
74+
7375
/*
7476
* We fault-in kernel-space virtual memory on-demand. The
7577
* 'reference' page table is init_mm.pgd.

‎arch/arm/kernel/ptrace.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ void ptrace_break(struct task_struct *tsk, struct pt_regs *regs)
205205
{
206206
siginfo_t info;
207207

208+
clear_siginfo(&info);
208209
info.si_signo = SIGTRAP;
209210
info.si_errno = 0;
210211
info.si_code = TRAP_BRKPT;

‎arch/arm/kernel/swp_emulate.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ static void set_segfault(struct pt_regs *regs, unsigned long addr)
100100
{
101101
siginfo_t info;
102102

103+
clear_siginfo(&info);
103104
down_read(&current->mm->mmap_sem);
104105
if (find_vma(current->mm, addr) == NULL)
105106
info.si_code = SEGV_MAPERR;

‎arch/arm/kernel/traps.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ asmlinkage void do_undefinstr(struct pt_regs *regs)
441441
siginfo_t info;
442442
void __user *pc;
443443

444+
clear_siginfo(&info);
444445
pc = (void __user *)instruction_pointer(regs);
445446

446447
if (processor_mode(regs) == SVC_MODE) {
@@ -540,6 +541,7 @@ static int bad_syscall(int n, struct pt_regs *regs)
540541
{
541542
siginfo_t info;
542543

544+
clear_siginfo(&info);
543545
if ((current->personality & PER_MASK) != PER_LINUX) {
544546
send_sig(SIGSEGV, current, 1);
545547
return regs->ARM_r0;
@@ -607,6 +609,7 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
607609
{
608610
siginfo_t info;
609611

612+
clear_siginfo(&info);
610613
if ((no >> 16) != (__ARM_NR_BASE>> 16))
611614
return bad_syscall(no, regs);
612615

@@ -743,6 +746,8 @@ baddataabort(int code, unsigned long instr, struct pt_regs *regs)
743746
unsigned long addr = instruction_pointer(regs);
744747
siginfo_t info;
745748

749+
clear_siginfo(&info);
750+
746751
#ifdef CONFIG_DEBUG_USER
747752
if (user_debug & UDBG_BADABORT) {
748753
pr_err("[%d] %s: bad data abort: code %d instr 0x%08lx\n",

‎arch/arm/mm/alignment.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,7 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
950950
if (ai_usermode & UM_SIGNAL) {
951951
siginfo_t si;
952952

953+
clear_siginfo(&si);
953954
si.si_signo = SIGBUS;
954955
si.si_errno = 0;
955956
si.si_code = BUS_ADRALN;

0 commit comments

Comments
 (0)