Skip to content

Commit 4898370

Browse files
committed
Merge branch 'siginfo-si_trapno-for-v5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace
Pull siginfo si_trapno updates from Eric Biederman: "The full set of si_trapno changes was not appropriate as a fix for the newly added SIGTRAP TRAP_PERF, and so I postponed the rest of the related cleanups. This is the rest of the cleanups for si_trapno that reduces it from being a really weird arch special case that is expect to be always present (but isn't) on the architectures that support it to being yet another field in the _sigfault union of struct siginfo. The changes have been reviewed and marinated in linux-next. With the removal of this awkward special case new code (like SIGTRAP TRAP_PERF) that works across architectures should be easier to write and maintain" * 'siginfo-si_trapno-for-v5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace: signal: Rename SIL_PERF_EVENT SIL_FAULT_PERF_EVENT for consistency signal: Verify the alignment and size of siginfo_t signal: Remove the generic __ARCH_SI_TRAPNO support signal/alpha: si_trapno is only used with SIGFPE and SIGTRAP TRAP_UNK signal/sparc: si_trapno is only used with SIGILL ILL_ILLTRP arm64: Add compile-time asserts for siginfo_t offsets arm: Add compile-time asserts for siginfo_t offsets sparc64: Add compile-time asserts for siginfo_t offsets
2 parents 477f70c + ee53488 commit 4898370

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