Skip to content

Commit ee53488

Browse files
committed
Final si_trapno bits
As a part of a fix for the ABI of the newly added SIGTRAP TRAP_PERF a si_trapno was reduced to an ordinary extention of the _sigfault case of struct siginfo. When Linus saw the complete set of changes come in as a fix he requested that the set of changes be trimmed down to just what was necessary to fix the SIGTRAP TRAP_PERF ABI. I had intended to get the rest of the changes into the merge window for v5.14 but I dropped the ball. I have made the changes to stop using __ARCH_SI_TRAPNO be per architecture so they are easier to review. In doing so I found one place on alpha where I used send_sig_fault instead of send_sig_fault_trapno(... si_trapno = 0). That would not have changed the userspace behavior but it did make the kernel code less clear. My rule in these patches is everywhere that siginfo layout calls for SIL_FAULT_TRAPNO the code uses either force_sig_fault_trapno or send_sig_fault_trapno. And of course I have rebased and compile tested Marco's compile time assert patches. v1: https://lkml.kernel.org/r/[email protected] v2: https://lkml.kernel.org/r/[email protected] v3: https://lkml.kernel.org/r/[email protected] v4: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/87a6mnzbx2.fsf_-_@disp2133 Eric W. Biederman (5): signal/sparc: si_trapno is only used with SIGILL ILL_ILLTRP signal/alpha: si_trapno is only used with SIGFPE and SIGTRAP TRAP_UNK signal: Remove the generic __ARCH_SI_TRAPNO support signal: Verify the alignment and size of siginfo_t signal: Rename SIL_PERF_EVENT SIL_FAULT_PERF_EVENT for consistency Marco Elver (3): sparc64: Add compile-time asserts for siginfo_t offsets arm: Add compile-time asserts for siginfo_t offsets arm64: Add compile-time asserts for siginfo_t offsets arch/alpha/include/uapi/asm/siginfo.h | 2 -- arch/alpha/kernel/osf_sys.c | 2 +- arch/alpha/kernel/signal.c | 4 +-- arch/alpha/kernel/traps.c | 26 +++++++-------- arch/alpha/mm/fault.c | 4 +-- arch/arm/kernel/signal.c | 39 ++++++++++++++++++++++ arch/arm64/kernel/signal.c | 39 ++++++++++++++++++++++ arch/arm64/kernel/signal32.c | 39 ++++++++++++++++++++++ arch/mips/include/uapi/asm/siginfo.h | 2 -- arch/sparc/include/uapi/asm/siginfo.h | 3 -- arch/sparc/kernel/process_64.c | 2 +- arch/sparc/kernel/signal32.c | 37 +++++++++++++++++++++ arch/sparc/kernel/signal_64.c | 36 ++++++++++++++++++++ arch/sparc/kernel/sys_sparc_32.c | 2 +- arch/sparc/kernel/sys_sparc_64.c | 2 +- arch/sparc/kernel/traps_32.c | 22 ++++++------- arch/sparc/kernel/traps_64.c | 44 +++++++++++-------------- arch/sparc/kernel/unaligned_32.c | 2 +- arch/sparc/mm/fault_32.c | 2 +- arch/sparc/mm/fault_64.c | 2 +- arch/x86/kernel/signal_compat.c | 6 ++++ fs/signalfd.c | 4 +-- include/linux/sched/signal.h | 11 ++----- include/linux/signal.h | 2 +- include/uapi/asm-generic/siginfo.h | 5 +++ kernel/signal.c | 62 +++++++++++++++++++++++++---------- 26 files changed, 305 insertions(+), 96 deletions(-)
2 parents e73f0f0 + f4ac730 commit ee53488

File tree

26 files changed

+305
-96
lines changed

26 files changed

+305
-96
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
#ifndef _ALPHA_SIGINFO_H
33
#define _ALPHA_SIGINFO_H
44

5-
#define __ARCH_SI_TRAPNO
6-
75
#include <asm-generic/siginfo.h>
86

97
#endif

arch/alpha/kernel/osf_sys.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ SYSCALL_DEFINE5(osf_setsysinfo, unsigned long, op, void __user *, buffer,
876876
if (fex & IEEE_TRAP_ENABLE_DZE) si_code = FPE_FLTDIV;
877877
if (fex & IEEE_TRAP_ENABLE_INV) si_code = FPE_FLTINV;
878878

879-
send_sig_fault(SIGFPE, si_code,
879+
send_sig_fault_trapno(SIGFPE, si_code,
880880
(void __user *)NULL, /* FIXME */
881881
0, current);
882882
}

arch/alpha/kernel/signal.c

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

220220
/* Send SIGTRAP if we're single-stepping: */
221221
if (ptrace_cancel_bpt (current)) {
222-
send_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *) regs->pc, 0,
222+
send_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *) regs->pc,
223223
current);
224224
}
225225
return;
@@ -247,7 +247,7 @@ do_rt_sigreturn(struct rt_sigframe __user *frame)
247247

248248
/* Send SIGTRAP if we're single-stepping: */
249249
if (ptrace_cancel_bpt (current)) {
250-
send_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *) regs->pc, 0,
250+
send_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *) regs->pc,
251251
current);
252252
}
253253
return;

arch/alpha/kernel/traps.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ do_entArith(unsigned long summary, unsigned long write_mask,
227227
}
228228
die_if_kernel("Arithmetic fault", regs, 0, NULL);
229229

230-
send_sig_fault(SIGFPE, si_code, (void __user *) regs->pc, 0, current);
230+
send_sig_fault_trapno(SIGFPE, si_code, (void __user *) regs->pc, 0, current);
231231
}
232232

233233
asmlinkage void
@@ -268,13 +268,13 @@ do_entIF(unsigned long type, struct pt_regs *regs)
268268
regs->pc -= 4; /* make pc point to former bpt */
269269
}
270270

271-
send_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->pc, 0,
271+
send_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->pc,
272272
current);
273273
return;
274274

275275
case 1: /* bugcheck */
276-
send_sig_fault(SIGTRAP, TRAP_UNK, (void __user *) regs->pc, 0,
277-
current);
276+
send_sig_fault_trapno(SIGTRAP, TRAP_UNK,
277+
(void __user *) regs->pc, 0, current);
278278
return;
279279

280280
case 2: /* gentrap */
@@ -335,8 +335,8 @@ do_entIF(unsigned long type, struct pt_regs *regs)
335335
break;
336336
}
337337

338-
send_sig_fault(signo, code, (void __user *) regs->pc, regs->r16,
339-
current);
338+
send_sig_fault_trapno(signo, code, (void __user *) regs->pc,
339+
regs->r16, current);
340340
return;
341341

342342
case 4: /* opDEC */
@@ -360,9 +360,9 @@ do_entIF(unsigned long type, struct pt_regs *regs)
360360
if (si_code == 0)
361361
return;
362362
if (si_code > 0) {
363-
send_sig_fault(SIGFPE, si_code,
364-
(void __user *) regs->pc, 0,
365-
current);
363+
send_sig_fault_trapno(SIGFPE, si_code,
364+
(void __user *) regs->pc,
365+
0, current);
366366
return;
367367
}
368368
}
@@ -387,7 +387,7 @@ do_entIF(unsigned long type, struct pt_regs *regs)
387387
;
388388
}
389389

390-
send_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)regs->pc, 0, current);
390+
send_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)regs->pc, current);
391391
}
392392

393393
/* There is an ifdef in the PALcode in MILO that enables a
@@ -402,7 +402,7 @@ do_entDbg(struct pt_regs *regs)
402402
{
403403
die_if_kernel("Instruction fault", regs, 0, NULL);
404404

405-
force_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)regs->pc, 0);
405+
force_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)regs->pc);
406406
}
407407

408408

@@ -964,12 +964,12 @@ do_entUnaUser(void __user * va, unsigned long opcode,
964964
si_code = SEGV_MAPERR;
965965
mmap_read_unlock(mm);
966966
}
967-
send_sig_fault(SIGSEGV, si_code, va, 0, current);
967+
send_sig_fault(SIGSEGV, si_code, va, current);
968968
return;
969969

970970
give_sigbus:
971971
regs->pc -= 4;
972-
send_sig_fault(SIGBUS, BUS_ADRALN, va, 0, current);
972+
send_sig_fault(SIGBUS, BUS_ADRALN, va, current);
973973
return;
974974
}
975975

arch/alpha/mm/fault.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,13 @@ do_page_fault(unsigned long address, unsigned long mmcsr,
219219
mmap_read_unlock(mm);
220220
/* Send a sigbus, regardless of whether we were in kernel
221221
or user mode. */
222-
force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *) address, 0);
222+
force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *) address);
223223
if (!user_mode(regs))
224224
goto no_context;
225225
return;
226226

227227
do_sigsegv:
228-
force_sig_fault(SIGSEGV, si_code, (void __user *) address, 0);
228+
force_sig_fault(SIGSEGV, si_code, (void __user *) address);
229229
return;
230230

231231
#ifdef CONFIG_ALPHA_LARGE_VMALLOC

arch/arm/kernel/signal.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,3 +725,42 @@ asmlinkage void do_rseq_syscall(struct pt_regs *regs)
725725
rseq_syscall(regs);
726726
}
727727
#endif
728+
729+
/*
730+
* Compile-time assertions for siginfo_t offsets. Check NSIG* as well, as
731+
* changes likely come with new fields that should be added below.
732+
*/
733+
static_assert(NSIGILL == 11);
734+
static_assert(NSIGFPE == 15);
735+
static_assert(NSIGSEGV == 9);
736+
static_assert(NSIGBUS == 5);
737+
static_assert(NSIGTRAP == 6);
738+
static_assert(NSIGCHLD == 6);
739+
static_assert(NSIGSYS == 2);
740+
static_assert(sizeof(siginfo_t) == 128);
741+
static_assert(__alignof__(siginfo_t) == 4);
742+
static_assert(offsetof(siginfo_t, si_signo) == 0x00);
743+
static_assert(offsetof(siginfo_t, si_errno) == 0x04);
744+
static_assert(offsetof(siginfo_t, si_code) == 0x08);
745+
static_assert(offsetof(siginfo_t, si_pid) == 0x0c);
746+
static_assert(offsetof(siginfo_t, si_uid) == 0x10);
747+
static_assert(offsetof(siginfo_t, si_tid) == 0x0c);
748+
static_assert(offsetof(siginfo_t, si_overrun) == 0x10);
749+
static_assert(offsetof(siginfo_t, si_status) == 0x14);
750+
static_assert(offsetof(siginfo_t, si_utime) == 0x18);
751+
static_assert(offsetof(siginfo_t, si_stime) == 0x1c);
752+
static_assert(offsetof(siginfo_t, si_value) == 0x14);
753+
static_assert(offsetof(siginfo_t, si_int) == 0x14);
754+
static_assert(offsetof(siginfo_t, si_ptr) == 0x14);
755+
static_assert(offsetof(siginfo_t, si_addr) == 0x0c);
756+
static_assert(offsetof(siginfo_t, si_addr_lsb) == 0x10);
757+
static_assert(offsetof(siginfo_t, si_lower) == 0x14);
758+
static_assert(offsetof(siginfo_t, si_upper) == 0x18);
759+
static_assert(offsetof(siginfo_t, si_pkey) == 0x14);
760+
static_assert(offsetof(siginfo_t, si_perf_data) == 0x10);
761+
static_assert(offsetof(siginfo_t, si_perf_type) == 0x14);
762+
static_assert(offsetof(siginfo_t, si_band) == 0x0c);
763+
static_assert(offsetof(siginfo_t, si_fd) == 0x10);
764+
static_assert(offsetof(siginfo_t, si_call_addr) == 0x0c);
765+
static_assert(offsetof(siginfo_t, si_syscall) == 0x10);
766+
static_assert(offsetof(siginfo_t, si_arch) == 0x14);

arch/arm64/kernel/signal.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,3 +999,42 @@ void __init minsigstksz_setup(void)
999999
round_up(sizeof(struct frame_record), 16) +
10001000
16; /* max alignment padding */
10011001
}
1002+
1003+
/*
1004+
* Compile-time assertions for siginfo_t offsets. Check NSIG* as well, as
1005+
* changes likely come with new fields that should be added below.
1006+
*/
1007+
static_assert(NSIGILL == 11);
1008+
static_assert(NSIGFPE == 15);
1009+
static_assert(NSIGSEGV == 9);
1010+
static_assert(NSIGBUS == 5);
1011+
static_assert(NSIGTRAP == 6);
1012+
static_assert(NSIGCHLD == 6);
1013+
static_assert(NSIGSYS == 2);
1014+
static_assert(sizeof(siginfo_t) == 128);
1015+
static_assert(__alignof__(siginfo_t) == 8);
1016+
static_assert(offsetof(siginfo_t, si_signo) == 0x00);
1017+
static_assert(offsetof(siginfo_t, si_errno) == 0x04);
1018+
static_assert(offsetof(siginfo_t, si_code) == 0x08);
1019+
static_assert(offsetof(siginfo_t, si_pid) == 0x10);
1020+
static_assert(offsetof(siginfo_t, si_uid) == 0x14);
1021+
static_assert(offsetof(siginfo_t, si_tid) == 0x10);
1022+
static_assert(offsetof(siginfo_t, si_overrun) == 0x14);
1023+
static_assert(offsetof(siginfo_t, si_status) == 0x18);
1024+
static_assert(offsetof(siginfo_t, si_utime) == 0x20);
1025+
static_assert(offsetof(siginfo_t, si_stime) == 0x28);
1026+
static_assert(offsetof(siginfo_t, si_value) == 0x18);
1027+
static_assert(offsetof(siginfo_t, si_int) == 0x18);
1028+
static_assert(offsetof(siginfo_t, si_ptr) == 0x18);
1029+
static_assert(offsetof(siginfo_t, si_addr) == 0x10);
1030+
static_assert(offsetof(siginfo_t, si_addr_lsb) == 0x18);
1031+
static_assert(offsetof(siginfo_t, si_lower) == 0x20);
1032+
static_assert(offsetof(siginfo_t, si_upper) == 0x28);
1033+
static_assert(offsetof(siginfo_t, si_pkey) == 0x20);
1034+
static_assert(offsetof(siginfo_t, si_perf_data) == 0x18);
1035+
static_assert(offsetof(siginfo_t, si_perf_type) == 0x20);
1036+
static_assert(offsetof(siginfo_t, si_band) == 0x10);
1037+
static_assert(offsetof(siginfo_t, si_fd) == 0x18);
1038+
static_assert(offsetof(siginfo_t, si_call_addr) == 0x10);
1039+
static_assert(offsetof(siginfo_t, si_syscall) == 0x18);
1040+
static_assert(offsetof(siginfo_t, si_arch) == 0x1c);

arch/arm64/kernel/signal32.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,3 +457,42 @@ void compat_setup_restart_syscall(struct pt_regs *regs)
457457
{
458458
regs->regs[7] = __NR_compat_restart_syscall;
459459
}
460+
461+
/*
462+
* Compile-time assertions for siginfo_t offsets. Check NSIG* as well, as
463+
* changes likely come with new fields that should be added below.
464+
*/
465+
static_assert(NSIGILL == 11);
466+
static_assert(NSIGFPE == 15);
467+
static_assert(NSIGSEGV == 9);
468+
static_assert(NSIGBUS == 5);
469+
static_assert(NSIGTRAP == 6);
470+
static_assert(NSIGCHLD == 6);
471+
static_assert(NSIGSYS == 2);
472+
static_assert(sizeof(compat_siginfo_t) == 128);
473+
static_assert(__alignof__(compat_siginfo_t) == 4);
474+
static_assert(offsetof(compat_siginfo_t, si_signo) == 0x00);
475+
static_assert(offsetof(compat_siginfo_t, si_errno) == 0x04);
476+
static_assert(offsetof(compat_siginfo_t, si_code) == 0x08);
477+
static_assert(offsetof(compat_siginfo_t, si_pid) == 0x0c);
478+
static_assert(offsetof(compat_siginfo_t, si_uid) == 0x10);
479+
static_assert(offsetof(compat_siginfo_t, si_tid) == 0x0c);
480+
static_assert(offsetof(compat_siginfo_t, si_overrun) == 0x10);
481+
static_assert(offsetof(compat_siginfo_t, si_status) == 0x14);
482+
static_assert(offsetof(compat_siginfo_t, si_utime) == 0x18);
483+
static_assert(offsetof(compat_siginfo_t, si_stime) == 0x1c);
484+
static_assert(offsetof(compat_siginfo_t, si_value) == 0x14);
485+
static_assert(offsetof(compat_siginfo_t, si_int) == 0x14);
486+
static_assert(offsetof(compat_siginfo_t, si_ptr) == 0x14);
487+
static_assert(offsetof(compat_siginfo_t, si_addr) == 0x0c);
488+
static_assert(offsetof(compat_siginfo_t, si_addr_lsb) == 0x10);
489+
static_assert(offsetof(compat_siginfo_t, si_lower) == 0x14);
490+
static_assert(offsetof(compat_siginfo_t, si_upper) == 0x18);
491+
static_assert(offsetof(compat_siginfo_t, si_pkey) == 0x14);
492+
static_assert(offsetof(compat_siginfo_t, si_perf_data) == 0x10);
493+
static_assert(offsetof(compat_siginfo_t, si_perf_type) == 0x14);
494+
static_assert(offsetof(compat_siginfo_t, si_band) == 0x0c);
495+
static_assert(offsetof(compat_siginfo_t, si_fd) == 0x10);
496+
static_assert(offsetof(compat_siginfo_t, si_call_addr) == 0x0c);
497+
static_assert(offsetof(compat_siginfo_t, si_syscall) == 0x10);
498+
static_assert(offsetof(compat_siginfo_t, si_arch) == 0x14);

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
#ifndef _UAPI_ASM_SIGINFO_H
1111
#define _UAPI_ASM_SIGINFO_H
1212

13-
1413
#define __ARCH_SIGEV_PREAMBLE_SIZE (sizeof(long) + 2*sizeof(int))
15-
#undef __ARCH_SI_TRAPNO /* exception code needs to fill this ... */
1614

1715
#define __ARCH_HAS_SWAPPED_SIGINFO
1816

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

0 commit comments

Comments
 (0)