Commit ee53488c authored by Eric W. Biederman's avatar Eric W. Biederman

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/m1zgxfs7zq.fsf_-_@fess.ebiederm.org
v2: https://lkml.kernel.org/r/m14kfjh8et.fsf_-_@fess.ebiederm.org
v3: https://lkml.kernel.org/r/m1tuni8ano.fsf_-_@fess.ebiederm.org
v4: https://lkml.kernel.org/r/m1a6ot5e2h.fsf_-_@fess.ebiederm.org
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(-)
parents e73f0f0e f4ac7302
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
#ifndef _ALPHA_SIGINFO_H #ifndef _ALPHA_SIGINFO_H
#define _ALPHA_SIGINFO_H #define _ALPHA_SIGINFO_H
#define __ARCH_SI_TRAPNO
#include <asm-generic/siginfo.h> #include <asm-generic/siginfo.h>
#endif #endif
...@@ -876,7 +876,7 @@ SYSCALL_DEFINE5(osf_setsysinfo, unsigned long, op, void __user *, buffer, ...@@ -876,7 +876,7 @@ SYSCALL_DEFINE5(osf_setsysinfo, unsigned long, op, void __user *, buffer,
if (fex & IEEE_TRAP_ENABLE_DZE) si_code = FPE_FLTDIV; if (fex & IEEE_TRAP_ENABLE_DZE) si_code = FPE_FLTDIV;
if (fex & IEEE_TRAP_ENABLE_INV) si_code = FPE_FLTINV; if (fex & IEEE_TRAP_ENABLE_INV) si_code = FPE_FLTINV;
send_sig_fault(SIGFPE, si_code, send_sig_fault_trapno(SIGFPE, si_code,
(void __user *)NULL, /* FIXME */ (void __user *)NULL, /* FIXME */
0, current); 0, current);
} }
......
...@@ -219,7 +219,7 @@ do_sigreturn(struct sigcontext __user *sc) ...@@ -219,7 +219,7 @@ do_sigreturn(struct sigcontext __user *sc)
/* Send SIGTRAP if we're single-stepping: */ /* Send SIGTRAP if we're single-stepping: */
if (ptrace_cancel_bpt (current)) { if (ptrace_cancel_bpt (current)) {
send_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *) regs->pc, 0, send_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *) regs->pc,
current); current);
} }
return; return;
...@@ -247,7 +247,7 @@ do_rt_sigreturn(struct rt_sigframe __user *frame) ...@@ -247,7 +247,7 @@ do_rt_sigreturn(struct rt_sigframe __user *frame)
/* Send SIGTRAP if we're single-stepping: */ /* Send SIGTRAP if we're single-stepping: */
if (ptrace_cancel_bpt (current)) { if (ptrace_cancel_bpt (current)) {
send_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *) regs->pc, 0, send_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *) regs->pc,
current); current);
} }
return; return;
......
...@@ -227,7 +227,7 @@ do_entArith(unsigned long summary, unsigned long write_mask, ...@@ -227,7 +227,7 @@ do_entArith(unsigned long summary, unsigned long write_mask,
} }
die_if_kernel("Arithmetic fault", regs, 0, NULL); die_if_kernel("Arithmetic fault", regs, 0, NULL);
send_sig_fault(SIGFPE, si_code, (void __user *) regs->pc, 0, current); send_sig_fault_trapno(SIGFPE, si_code, (void __user *) regs->pc, 0, current);
} }
asmlinkage void asmlinkage void
...@@ -268,13 +268,13 @@ do_entIF(unsigned long type, struct pt_regs *regs) ...@@ -268,13 +268,13 @@ do_entIF(unsigned long type, struct pt_regs *regs)
regs->pc -= 4; /* make pc point to former bpt */ regs->pc -= 4; /* make pc point to former bpt */
} }
send_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->pc, 0, send_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->pc,
current); current);
return; return;
case 1: /* bugcheck */ case 1: /* bugcheck */
send_sig_fault(SIGTRAP, TRAP_UNK, (void __user *) regs->pc, 0, send_sig_fault_trapno(SIGTRAP, TRAP_UNK,
current); (void __user *) regs->pc, 0, current);
return; return;
case 2: /* gentrap */ case 2: /* gentrap */
...@@ -335,8 +335,8 @@ do_entIF(unsigned long type, struct pt_regs *regs) ...@@ -335,8 +335,8 @@ do_entIF(unsigned long type, struct pt_regs *regs)
break; break;
} }
send_sig_fault(signo, code, (void __user *) regs->pc, regs->r16, send_sig_fault_trapno(signo, code, (void __user *) regs->pc,
current); regs->r16, current);
return; return;
case 4: /* opDEC */ case 4: /* opDEC */
...@@ -360,9 +360,9 @@ do_entIF(unsigned long type, struct pt_regs *regs) ...@@ -360,9 +360,9 @@ do_entIF(unsigned long type, struct pt_regs *regs)
if (si_code == 0) if (si_code == 0)
return; return;
if (si_code > 0) { if (si_code > 0) {
send_sig_fault(SIGFPE, si_code, send_sig_fault_trapno(SIGFPE, si_code,
(void __user *) regs->pc, 0, (void __user *) regs->pc,
current); 0, current);
return; return;
} }
} }
...@@ -387,7 +387,7 @@ do_entIF(unsigned long type, struct pt_regs *regs) ...@@ -387,7 +387,7 @@ do_entIF(unsigned long type, struct pt_regs *regs)
; ;
} }
send_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)regs->pc, 0, current); send_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)regs->pc, current);
} }
/* There is an ifdef in the PALcode in MILO that enables a /* There is an ifdef in the PALcode in MILO that enables a
...@@ -402,7 +402,7 @@ do_entDbg(struct pt_regs *regs) ...@@ -402,7 +402,7 @@ do_entDbg(struct pt_regs *regs)
{ {
die_if_kernel("Instruction fault", regs, 0, NULL); die_if_kernel("Instruction fault", regs, 0, NULL);
force_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)regs->pc, 0); force_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)regs->pc);
} }
...@@ -964,12 +964,12 @@ do_entUnaUser(void __user * va, unsigned long opcode, ...@@ -964,12 +964,12 @@ do_entUnaUser(void __user * va, unsigned long opcode,
si_code = SEGV_MAPERR; si_code = SEGV_MAPERR;
mmap_read_unlock(mm); mmap_read_unlock(mm);
} }
send_sig_fault(SIGSEGV, si_code, va, 0, current); send_sig_fault(SIGSEGV, si_code, va, current);
return; return;
give_sigbus: give_sigbus:
regs->pc -= 4; regs->pc -= 4;
send_sig_fault(SIGBUS, BUS_ADRALN, va, 0, current); send_sig_fault(SIGBUS, BUS_ADRALN, va, current);
return; return;
} }
......
...@@ -219,13 +219,13 @@ do_page_fault(unsigned long address, unsigned long mmcsr, ...@@ -219,13 +219,13 @@ do_page_fault(unsigned long address, unsigned long mmcsr,
mmap_read_unlock(mm); mmap_read_unlock(mm);
/* Send a sigbus, regardless of whether we were in kernel /* Send a sigbus, regardless of whether we were in kernel
or user mode. */ or user mode. */
force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *) address, 0); force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *) address);
if (!user_mode(regs)) if (!user_mode(regs))
goto no_context; goto no_context;
return; return;
do_sigsegv: do_sigsegv:
force_sig_fault(SIGSEGV, si_code, (void __user *) address, 0); force_sig_fault(SIGSEGV, si_code, (void __user *) address);
return; return;
#ifdef CONFIG_ALPHA_LARGE_VMALLOC #ifdef CONFIG_ALPHA_LARGE_VMALLOC
......
...@@ -725,3 +725,42 @@ asmlinkage void do_rseq_syscall(struct pt_regs *regs) ...@@ -725,3 +725,42 @@ asmlinkage void do_rseq_syscall(struct pt_regs *regs)
rseq_syscall(regs); rseq_syscall(regs);
} }
#endif #endif
/*
* Compile-time assertions for siginfo_t offsets. Check NSIG* as well, as
* changes likely come with new fields that should be added below.
*/
static_assert(NSIGILL == 11);
static_assert(NSIGFPE == 15);
static_assert(NSIGSEGV == 9);
static_assert(NSIGBUS == 5);
static_assert(NSIGTRAP == 6);
static_assert(NSIGCHLD == 6);
static_assert(NSIGSYS == 2);
static_assert(sizeof(siginfo_t) == 128);
static_assert(__alignof__(siginfo_t) == 4);
static_assert(offsetof(siginfo_t, si_signo) == 0x00);
static_assert(offsetof(siginfo_t, si_errno) == 0x04);
static_assert(offsetof(siginfo_t, si_code) == 0x08);
static_assert(offsetof(siginfo_t, si_pid) == 0x0c);
static_assert(offsetof(siginfo_t, si_uid) == 0x10);
static_assert(offsetof(siginfo_t, si_tid) == 0x0c);
static_assert(offsetof(siginfo_t, si_overrun) == 0x10);
static_assert(offsetof(siginfo_t, si_status) == 0x14);
static_assert(offsetof(siginfo_t, si_utime) == 0x18);
static_assert(offsetof(siginfo_t, si_stime) == 0x1c);
static_assert(offsetof(siginfo_t, si_value) == 0x14);
static_assert(offsetof(siginfo_t, si_int) == 0x14);
static_assert(offsetof(siginfo_t, si_ptr) == 0x14);
static_assert(offsetof(siginfo_t, si_addr) == 0x0c);
static_assert(offsetof(siginfo_t, si_addr_lsb) == 0x10);
static_assert(offsetof(siginfo_t, si_lower) == 0x14);
static_assert(offsetof(siginfo_t, si_upper) == 0x18);
static_assert(offsetof(siginfo_t, si_pkey) == 0x14);
static_assert(offsetof(siginfo_t, si_perf_data) == 0x10);
static_assert(offsetof(siginfo_t, si_perf_type) == 0x14);
static_assert(offsetof(siginfo_t, si_band) == 0x0c);
static_assert(offsetof(siginfo_t, si_fd) == 0x10);
static_assert(offsetof(siginfo_t, si_call_addr) == 0x0c);
static_assert(offsetof(siginfo_t, si_syscall) == 0x10);
static_assert(offsetof(siginfo_t, si_arch) == 0x14);
...@@ -999,3 +999,42 @@ void __init minsigstksz_setup(void) ...@@ -999,3 +999,42 @@ void __init minsigstksz_setup(void)
round_up(sizeof(struct frame_record), 16) + round_up(sizeof(struct frame_record), 16) +
16; /* max alignment padding */ 16; /* max alignment padding */
} }
/*
* Compile-time assertions for siginfo_t offsets. Check NSIG* as well, as
* changes likely come with new fields that should be added below.
*/
static_assert(NSIGILL == 11);
static_assert(NSIGFPE == 15);
static_assert(NSIGSEGV == 9);
static_assert(NSIGBUS == 5);
static_assert(NSIGTRAP == 6);
static_assert(NSIGCHLD == 6);
static_assert(NSIGSYS == 2);
static_assert(sizeof(siginfo_t) == 128);
static_assert(__alignof__(siginfo_t) == 8);
static_assert(offsetof(siginfo_t, si_signo) == 0x00);
static_assert(offsetof(siginfo_t, si_errno) == 0x04);
static_assert(offsetof(siginfo_t, si_code) == 0x08);
static_assert(offsetof(siginfo_t, si_pid) == 0x10);
static_assert(offsetof(siginfo_t, si_uid) == 0x14);
static_assert(offsetof(siginfo_t, si_tid) == 0x10);
static_assert(offsetof(siginfo_t, si_overrun) == 0x14);
static_assert(offsetof(siginfo_t, si_status) == 0x18);
static_assert(offsetof(siginfo_t, si_utime) == 0x20);
static_assert(offsetof(siginfo_t, si_stime) == 0x28);
static_assert(offsetof(siginfo_t, si_value) == 0x18);
static_assert(offsetof(siginfo_t, si_int) == 0x18);
static_assert(offsetof(siginfo_t, si_ptr) == 0x18);
static_assert(offsetof(siginfo_t, si_addr) == 0x10);
static_assert(offsetof(siginfo_t, si_addr_lsb) == 0x18);
static_assert(offsetof(siginfo_t, si_lower) == 0x20);
static_assert(offsetof(siginfo_t, si_upper) == 0x28);
static_assert(offsetof(siginfo_t, si_pkey) == 0x20);
static_assert(offsetof(siginfo_t, si_perf_data) == 0x18);
static_assert(offsetof(siginfo_t, si_perf_type) == 0x20);
static_assert(offsetof(siginfo_t, si_band) == 0x10);
static_assert(offsetof(siginfo_t, si_fd) == 0x18);
static_assert(offsetof(siginfo_t, si_call_addr) == 0x10);
static_assert(offsetof(siginfo_t, si_syscall) == 0x18);
static_assert(offsetof(siginfo_t, si_arch) == 0x1c);
...@@ -457,3 +457,42 @@ void compat_setup_restart_syscall(struct pt_regs *regs) ...@@ -457,3 +457,42 @@ void compat_setup_restart_syscall(struct pt_regs *regs)
{ {
regs->regs[7] = __NR_compat_restart_syscall; regs->regs[7] = __NR_compat_restart_syscall;
} }
/*
* Compile-time assertions for siginfo_t offsets. Check NSIG* as well, as
* changes likely come with new fields that should be added below.
*/
static_assert(NSIGILL == 11);
static_assert(NSIGFPE == 15);
static_assert(NSIGSEGV == 9);
static_assert(NSIGBUS == 5);
static_assert(NSIGTRAP == 6);
static_assert(NSIGCHLD == 6);
static_assert(NSIGSYS == 2);
static_assert(sizeof(compat_siginfo_t) == 128);
static_assert(__alignof__(compat_siginfo_t) == 4);
static_assert(offsetof(compat_siginfo_t, si_signo) == 0x00);
static_assert(offsetof(compat_siginfo_t, si_errno) == 0x04);
static_assert(offsetof(compat_siginfo_t, si_code) == 0x08);
static_assert(offsetof(compat_siginfo_t, si_pid) == 0x0c);
static_assert(offsetof(compat_siginfo_t, si_uid) == 0x10);
static_assert(offsetof(compat_siginfo_t, si_tid) == 0x0c);
static_assert(offsetof(compat_siginfo_t, si_overrun) == 0x10);
static_assert(offsetof(compat_siginfo_t, si_status) == 0x14);
static_assert(offsetof(compat_siginfo_t, si_utime) == 0x18);
static_assert(offsetof(compat_siginfo_t, si_stime) == 0x1c);
static_assert(offsetof(compat_siginfo_t, si_value) == 0x14);
static_assert(offsetof(compat_siginfo_t, si_int) == 0x14);
static_assert(offsetof(compat_siginfo_t, si_ptr) == 0x14);
static_assert(offsetof(compat_siginfo_t, si_addr) == 0x0c);
static_assert(offsetof(compat_siginfo_t, si_addr_lsb) == 0x10);
static_assert(offsetof(compat_siginfo_t, si_lower) == 0x14);
static_assert(offsetof(compat_siginfo_t, si_upper) == 0x18);
static_assert(offsetof(compat_siginfo_t, si_pkey) == 0x14);
static_assert(offsetof(compat_siginfo_t, si_perf_data) == 0x10);
static_assert(offsetof(compat_siginfo_t, si_perf_type) == 0x14);
static_assert(offsetof(compat_siginfo_t, si_band) == 0x0c);
static_assert(offsetof(compat_siginfo_t, si_fd) == 0x10);
static_assert(offsetof(compat_siginfo_t, si_call_addr) == 0x0c);
static_assert(offsetof(compat_siginfo_t, si_syscall) == 0x10);
static_assert(offsetof(compat_siginfo_t, si_arch) == 0x14);
...@@ -10,9 +10,7 @@ ...@@ -10,9 +10,7 @@
#ifndef _UAPI_ASM_SIGINFO_H #ifndef _UAPI_ASM_SIGINFO_H
#define _UAPI_ASM_SIGINFO_H #define _UAPI_ASM_SIGINFO_H
#define __ARCH_SIGEV_PREAMBLE_SIZE (sizeof(long) + 2*sizeof(int)) #define __ARCH_SIGEV_PREAMBLE_SIZE (sizeof(long) + 2*sizeof(int))
#undef __ARCH_SI_TRAPNO /* exception code needs to fill this ... */
#define __ARCH_HAS_SWAPPED_SIGINFO #define __ARCH_HAS_SWAPPED_SIGINFO
......
...@@ -8,9 +8,6 @@ ...@@ -8,9 +8,6 @@
#endif /* defined(__sparc__) && defined(__arch64__) */ #endif /* defined(__sparc__) && defined(__arch64__) */
#define __ARCH_SI_TRAPNO
#include <asm-generic/siginfo.h> #include <asm-generic/siginfo.h>
......
...@@ -518,7 +518,7 @@ void synchronize_user_stack(void) ...@@ -518,7 +518,7 @@ void synchronize_user_stack(void)
static void stack_unaligned(unsigned long sp) static void stack_unaligned(unsigned long sp)
{ {
force_sig_fault(SIGBUS, BUS_ADRALN, (void __user *) sp, 0); force_sig_fault(SIGBUS, BUS_ADRALN, (void __user *) sp);
} }
static const char uwfault32[] = KERN_INFO \ static const char uwfault32[] = KERN_INFO \
......
...@@ -745,3 +745,40 @@ asmlinkage int do_sys32_sigstack(u32 u_ssptr, u32 u_ossptr, unsigned long sp) ...@@ -745,3 +745,40 @@ asmlinkage int do_sys32_sigstack(u32 u_ssptr, u32 u_ossptr, unsigned long sp)
out: out:
return ret; return ret;
} }
/*
* Compile-time assertions for siginfo_t offsets. Check NSIG* as well, as
* changes likely come with new fields that should be added below.
*/
static_assert(NSIGILL == 11);
static_assert(NSIGFPE == 15);
static_assert(NSIGSEGV == 9);
static_assert(NSIGBUS == 5);
static_assert(NSIGTRAP == 6);
static_assert(NSIGCHLD == 6);
static_assert(NSIGSYS == 2);
static_assert(sizeof(compat_siginfo_t) == 128);
static_assert(__alignof__(compat_siginfo_t) == 4);
static_assert(offsetof(compat_siginfo_t, si_signo) == 0x00);
static_assert(offsetof(compat_siginfo_t, si_errno) == 0x04);
static_assert(offsetof(compat_siginfo_t, si_code) == 0x08);
static_assert(offsetof(compat_siginfo_t, si_pid) == 0x0c);
static_assert(offsetof(compat_siginfo_t, si_uid) == 0x10);
static_assert(offsetof(compat_siginfo_t, si_tid) == 0x0c);
static_assert(offsetof(compat_siginfo_t, si_overrun) == 0x10);
static_assert(offsetof(compat_siginfo_t, si_status) == 0x14);
static_assert(offsetof(compat_siginfo_t, si_utime) == 0x18);
static_assert(offsetof(compat_siginfo_t, si_stime) == 0x1c);
static_assert(offsetof(compat_siginfo_t, si_value) == 0x14);
static_assert(offsetof(compat_siginfo_t, si_int) == 0x14);
static_assert(offsetof(compat_siginfo_t, si_ptr) == 0x14);
static_assert(offsetof(compat_siginfo_t, si_addr) == 0x0c);
static_assert(offsetof(compat_siginfo_t, si_trapno) == 0x10);
static_assert(offsetof(compat_siginfo_t, si_addr_lsb) == 0x10);
static_assert(offsetof(compat_siginfo_t, si_lower) == 0x14);
static_assert(offsetof(compat_siginfo_t, si_upper) == 0x18);
static_assert(offsetof(compat_siginfo_t, si_pkey) == 0x14);
static_assert(offsetof(compat_siginfo_t, si_perf_data) == 0x10);
static_assert(offsetof(compat_siginfo_t, si_perf_type) == 0x14);
static_assert(offsetof(compat_siginfo_t, si_band) == 0x0c);
static_assert(offsetof(compat_siginfo_t, si_fd) == 0x10);
...@@ -556,3 +556,39 @@ void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0, unsigned long ...@@ -556,3 +556,39 @@ void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0, unsigned long
user_enter(); user_enter();
} }
/*
* Compile-time assertions for siginfo_t offsets. Check NSIG* as well, as
* changes likely come with new fields that should be added below.
*/
static_assert(NSIGILL == 11);
static_assert(NSIGFPE == 15);
static_assert(NSIGSEGV == 9);
static_assert(NSIGBUS == 5);
static_assert(NSIGTRAP == 6);
static_assert(NSIGCHLD == 6);
static_assert(NSIGSYS == 2);
static_assert(sizeof(siginfo_t) == 128);
static_assert(__alignof__(siginfo_t) == 8);
static_assert(offsetof(siginfo_t, si_signo) == 0x00);
static_assert(offsetof(siginfo_t, si_errno) == 0x04);
static_assert(offsetof(siginfo_t, si_code) == 0x08);
static_assert(offsetof(siginfo_t, si_pid) == 0x10);
static_assert(offsetof(siginfo_t, si_uid) == 0x14);
static_assert(offsetof(siginfo_t, si_tid) == 0x10);
static_assert(offsetof(siginfo_t, si_overrun) == 0x14);
static_assert(offsetof(siginfo_t, si_status) == 0x18);
static_assert(offsetof(siginfo_t, si_utime) == 0x20);
static_assert(offsetof(siginfo_t, si_stime) == 0x28);
static_assert(offsetof(siginfo_t, si_value) == 0x18);
static_assert(offsetof(siginfo_t, si_int) == 0x18);
static_assert(offsetof(siginfo_t, si_ptr) == 0x18);
static_assert(offsetof(siginfo_t, si_addr) == 0x10);
static_assert(offsetof(siginfo_t, si_trapno) == 0x18);
static_assert(offsetof(siginfo_t, si_addr_lsb) == 0x18);
static_assert(offsetof(siginfo_t, si_lower) == 0x20);
static_assert(offsetof(siginfo_t, si_upper) == 0x28);
static_assert(offsetof(siginfo_t, si_pkey) == 0x20);
static_assert(offsetof(siginfo_t, si_perf_data) == 0x18);
static_assert(offsetof(siginfo_t, si_perf_type) == 0x20);
static_assert(offsetof(siginfo_t, si_band) == 0x10);
static_assert(offsetof(siginfo_t, si_fd) == 0x14);
...@@ -151,7 +151,7 @@ sparc_breakpoint (struct pt_regs *regs) ...@@ -151,7 +151,7 @@ sparc_breakpoint (struct pt_regs *regs)
#ifdef DEBUG_SPARC_BREAKPOINT #ifdef DEBUG_SPARC_BREAKPOINT
printk ("TRAP: Entering kernel PC=%x, nPC=%x\n", regs->pc, regs->npc); printk ("TRAP: Entering kernel PC=%x, nPC=%x\n", regs->pc, regs->npc);
#endif #endif
force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->pc, 0); force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->pc);
#ifdef DEBUG_SPARC_BREAKPOINT #ifdef DEBUG_SPARC_BREAKPOINT
printk ("TRAP: Returning to space: PC=%x nPC=%x\n", regs->pc, regs->npc); printk ("TRAP: Returning to space: PC=%x nPC=%x\n", regs->pc, regs->npc);
......
...@@ -514,7 +514,7 @@ asmlinkage void sparc_breakpoint(struct pt_regs *regs) ...@@ -514,7 +514,7 @@ asmlinkage void sparc_breakpoint(struct pt_regs *regs)
#ifdef DEBUG_SPARC_BREAKPOINT #ifdef DEBUG_SPARC_BREAKPOINT
printk ("TRAP: Entering kernel PC=%lx, nPC=%lx\n", regs->tpc, regs->tnpc); printk ("TRAP: Entering kernel PC=%lx, nPC=%lx\n", regs->tpc, regs->tnpc);
#endif #endif
force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->tpc, 0); force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->tpc);
#ifdef DEBUG_SPARC_BREAKPOINT #ifdef DEBUG_SPARC_BREAKPOINT
printk ("TRAP: Returning to space: PC=%lx nPC=%lx\n", regs->tpc, regs->tnpc); printk ("TRAP: Returning to space: PC=%lx nPC=%lx\n", regs->tpc, regs->tnpc);
#endif #endif
......
...@@ -102,7 +102,7 @@ void do_hw_interrupt(struct pt_regs *regs, unsigned long type) ...@@ -102,7 +102,7 @@ void do_hw_interrupt(struct pt_regs *regs, unsigned long type)
if(regs->psr & PSR_PS) if(regs->psr & PSR_PS)
die_if_kernel("Kernel bad trap", regs); die_if_kernel("Kernel bad trap", regs);
force_sig_fault(SIGILL, ILL_ILLTRP, force_sig_fault_trapno(SIGILL, ILL_ILLTRP,
(void __user *)regs->pc, type - 0x80); (void __user *)regs->pc, type - 0x80);
} }
...@@ -116,7 +116,7 @@ void do_illegal_instruction(struct pt_regs *regs, unsigned long pc, unsigned lon ...@@ -116,7 +116,7 @@ void do_illegal_instruction(struct pt_regs *regs, unsigned long pc, unsigned lon
regs->pc, *(unsigned long *)regs->pc); regs->pc, *(unsigned long *)regs->pc);
#endif #endif
send_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)pc, 0, current); send_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)pc, current);
} }
void do_priv_instruction(struct pt_regs *regs, unsigned long pc, unsigned long npc, void do_priv_instruction(struct pt_regs *regs, unsigned long pc, unsigned long npc,
...@@ -124,7 +124,7 @@ void do_priv_instruction(struct pt_regs *regs, unsigned long pc, unsigned long n ...@@ -124,7 +124,7 @@ void do_priv_instruction(struct pt_regs *regs, unsigned long pc, unsigned long n
{ {
if(psr & PSR_PS) if(psr & PSR_PS)
die_if_kernel("Penguin instruction from Penguin mode??!?!", regs); die_if_kernel("Penguin instruction from Penguin mode??!?!", regs);
send_sig_fault(SIGILL, ILL_PRVOPC, (void __user *)pc, 0, current); send_sig_fault(SIGILL, ILL_PRVOPC, (void __user *)pc, current);
} }
/* XXX User may want to be allowed to do this. XXX */ /* 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 ...@@ -145,7 +145,7 @@ void do_memaccess_unaligned(struct pt_regs *regs, unsigned long pc, unsigned lon
#endif #endif
send_sig_fault(SIGBUS, BUS_ADRALN, send_sig_fault(SIGBUS, BUS_ADRALN,
/* FIXME: Should dig out mna address */ (void *)0, /* FIXME: Should dig out mna address */ (void *)0,
0, current); current);
} }
static unsigned long init_fsr = 0x0UL; static unsigned long init_fsr = 0x0UL;
...@@ -291,7 +291,7 @@ void do_fpe_trap(struct pt_regs *regs, unsigned long pc, unsigned long npc, ...@@ -291,7 +291,7 @@ void do_fpe_trap(struct pt_regs *regs, unsigned long pc, unsigned long npc,
else if (fsr & 0x01) else if (fsr & 0x01)
code = FPE_FLTRES; code = FPE_FLTRES;
} }
send_sig_fault(SIGFPE, code, (void __user *)pc, 0, fpt); send_sig_fault(SIGFPE, code, (void __user *)pc, fpt);
#ifndef CONFIG_SMP #ifndef CONFIG_SMP
last_task_used_math = NULL; last_task_used_math = NULL;
#endif #endif
...@@ -305,7 +305,7 @@ void handle_tag_overflow(struct pt_regs *regs, unsigned long pc, unsigned long n ...@@ -305,7 +305,7 @@ void handle_tag_overflow(struct pt_regs *regs, unsigned long pc, unsigned long n
{ {
if(psr & PSR_PS) if(psr & PSR_PS)
die_if_kernel("Penguin overflow trap from kernel mode", regs); die_if_kernel("Penguin overflow trap from kernel mode", regs);
send_sig_fault(SIGEMT, EMT_TAGOVF, (void __user *)pc, 0, current); send_sig_fault(SIGEMT, EMT_TAGOVF, (void __user *)pc, current);
} }
void handle_watchpoint(struct pt_regs *regs, unsigned long pc, unsigned long npc, 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 ...@@ -327,13 +327,13 @@ void handle_reg_access(struct pt_regs *regs, unsigned long pc, unsigned long npc
printk("Register Access Exception at PC %08lx NPC %08lx PSR %08lx\n", printk("Register Access Exception at PC %08lx NPC %08lx PSR %08lx\n",
pc, npc, psr); pc, npc, psr);
#endif #endif
force_sig_fault(SIGBUS, BUS_OBJERR, (void __user *)pc, 0); force_sig_fault(SIGBUS, BUS_OBJERR, (void __user *)pc);
} }
void handle_cp_disabled(struct pt_regs *regs, unsigned long pc, unsigned long npc, void handle_cp_disabled(struct pt_regs *regs, unsigned long pc, unsigned long npc,
unsigned long psr) unsigned long psr)
{ {
send_sig_fault(SIGILL, ILL_COPROC, (void __user *)pc, 0, current); send_sig_fault(SIGILL, ILL_COPROC, (void __user *)pc, current);
} }
void handle_cp_exception(struct pt_regs *regs, unsigned long pc, unsigned long npc, 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 ...@@ -343,13 +343,13 @@ void handle_cp_exception(struct pt_regs *regs, unsigned long pc, unsigned long n
printk("Co-Processor Exception at PC %08lx NPC %08lx PSR %08lx\n", printk("Co-Processor Exception at PC %08lx NPC %08lx PSR %08lx\n",
pc, npc, psr); pc, npc, psr);
#endif #endif
send_sig_fault(SIGILL, ILL_COPROC, (void __user *)pc, 0, current); send_sig_fault(SIGILL, ILL_COPROC, (void __user *)pc, current);
} }
void handle_hw_divzero(struct pt_regs *regs, unsigned long pc, unsigned long npc, void handle_hw_divzero(struct pt_regs *regs, unsigned long pc, unsigned long npc,
unsigned long psr) unsigned long psr)
{ {
send_sig_fault(SIGFPE, FPE_INTDIV, (void __user *)pc, 0, current); send_sig_fault(SIGFPE, FPE_INTDIV, (void __user *)pc, current);
} }
#ifdef CONFIG_DEBUG_BUGVERBOSE #ifdef CONFIG_DEBUG_BUGVERBOSE
......
...@@ -107,7 +107,7 @@ void bad_trap(struct pt_regs *regs, long lvl) ...@@ -107,7 +107,7 @@ void bad_trap(struct pt_regs *regs, long lvl)
regs->tpc &= 0xffffffff; regs->tpc &= 0xffffffff;
regs->tnpc &= 0xffffffff; regs->tnpc &= 0xffffffff;
} }
force_sig_fault(SIGILL, ILL_ILLTRP, force_sig_fault_trapno(SIGILL, ILL_ILLTRP,
(void __user *)regs->tpc, lvl); (void __user *)regs->tpc, lvl);
} }
...@@ -201,8 +201,7 @@ void spitfire_insn_access_exception(struct pt_regs *regs, unsigned long sfsr, un ...@@ -201,8 +201,7 @@ void spitfire_insn_access_exception(struct pt_regs *regs, unsigned long sfsr, un
regs->tpc &= 0xffffffff; regs->tpc &= 0xffffffff;
regs->tnpc &= 0xffffffff; regs->tnpc &= 0xffffffff;
} }
force_sig_fault(SIGSEGV, SEGV_MAPERR, force_sig_fault(SIGSEGV, SEGV_MAPERR, (void __user *)regs->tpc);
(void __user *)regs->tpc, 0);
out: out:
exception_exit(prev_state); exception_exit(prev_state);
} }
...@@ -237,7 +236,7 @@ void sun4v_insn_access_exception(struct pt_regs *regs, unsigned long addr, unsig ...@@ -237,7 +236,7 @@ void sun4v_insn_access_exception(struct pt_regs *regs, unsigned long addr, unsig
regs->tpc &= 0xffffffff; regs->tpc &= 0xffffffff;
regs->tnpc &= 0xffffffff; regs->tnpc &= 0xffffffff;
} }
force_sig_fault(SIGSEGV, SEGV_MAPERR, (void __user *) addr, 0); force_sig_fault(SIGSEGV, SEGV_MAPERR, (void __user *) addr);
} }
void sun4v_insn_access_exception_tl1(struct pt_regs *regs, unsigned long addr, unsigned long type_ctx) 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 ...@@ -321,7 +320,7 @@ void spitfire_data_access_exception(struct pt_regs *regs, unsigned long sfsr, un
if (is_no_fault_exception(regs)) if (is_no_fault_exception(regs))
return; return;
force_sig_fault(SIGSEGV, SEGV_MAPERR, (void __user *)sfar, 0); force_sig_fault(SIGSEGV, SEGV_MAPERR, (void __user *)sfar);
out: out:
exception_exit(prev_state); exception_exit(prev_state);
} }
...@@ -385,13 +384,13 @@ void sun4v_data_access_exception(struct pt_regs *regs, unsigned long addr, unsig ...@@ -385,13 +384,13 @@ void sun4v_data_access_exception(struct pt_regs *regs, unsigned long addr, unsig
*/ */
switch (type) { switch (type) {
case HV_FAULT_TYPE_INV_ASI: case HV_FAULT_TYPE_INV_ASI:
force_sig_fault(SIGILL, ILL_ILLADR, (void __user *)addr, 0); force_sig_fault(SIGILL, ILL_ILLADR, (void __user *)addr);
break; break;
case HV_FAULT_TYPE_MCD_DIS: case HV_FAULT_TYPE_MCD_DIS:
force_sig_fault(SIGSEGV, SEGV_ACCADI, (void __user *)addr, 0); force_sig_fault(SIGSEGV, SEGV_ACCADI, (void __user *)addr);
break; break;
default: default:
force_sig_fault(SIGSEGV, SEGV_MAPERR, (void __user *)addr, 0); force_sig_fault(SIGSEGV, SEGV_MAPERR, (void __user *)addr);
break; break;
} }
} }
...@@ -568,7 +567,7 @@ static void spitfire_ue_log(unsigned long afsr, unsigned long afar, unsigned lon ...@@ -568,7 +567,7 @@ static void spitfire_ue_log(unsigned long afsr, unsigned long afar, unsigned lon
regs->tpc &= 0xffffffff; regs->tpc &= 0xffffffff;
regs->tnpc &= 0xffffffff; regs->tnpc &= 0xffffffff;
} }
force_sig_fault(SIGBUS, BUS_OBJERR, (void *)0, 0); force_sig_fault(SIGBUS, BUS_OBJERR, (void *)0);
} }
void spitfire_access_error(struct pt_regs *regs, unsigned long status_encoded, unsigned long afar) 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) ...@@ -2069,8 +2068,7 @@ void do_mcd_err(struct pt_regs *regs, struct sun4v_error_entry ent)
/* Send SIGSEGV to the userspace process with the right signal /* Send SIGSEGV to the userspace process with the right signal
* code * code
*/ */
force_sig_fault(SIGSEGV, SEGV_ADIDERR, (void __user *)ent.err_raddr, force_sig_fault(SIGSEGV, SEGV_ADIDERR, (void __user *)ent.err_raddr);
0);
} }
/* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate. /* 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, ...@@ -2184,7 +2182,7 @@ bool sun4v_nonresum_error_user_handled(struct pt_regs *regs,
} }
if (attrs & SUN4V_ERR_ATTRS_PIO) { if (attrs & SUN4V_ERR_ATTRS_PIO) {
force_sig_fault(SIGBUS, BUS_ADRERR, force_sig_fault(SIGBUS, BUS_ADRERR,
(void __user *)sun4v_get_vaddr(regs), 0); (void __user *)sun4v_get_vaddr(regs));
return true; return true;
} }
...@@ -2340,8 +2338,7 @@ static void do_fpe_common(struct pt_regs *regs) ...@@ -2340,8 +2338,7 @@ static void do_fpe_common(struct pt_regs *regs)
else if (fsr & 0x01) else if (fsr & 0x01)
code = FPE_FLTRES; code = FPE_FLTRES;
} }
force_sig_fault(SIGFPE, code, force_sig_fault(SIGFPE, code, (void __user *)regs->tpc);
(void __user *)regs->tpc, 0);
} }
} }
...@@ -2395,8 +2392,7 @@ void do_tof(struct pt_regs *regs) ...@@ -2395,8 +2392,7 @@ void do_tof(struct pt_regs *regs)
regs->tpc &= 0xffffffff; regs->tpc &= 0xffffffff;
regs->tnpc &= 0xffffffff; regs->tnpc &= 0xffffffff;
} }
force_sig_fault(SIGEMT, EMT_TAGOVF, force_sig_fault(SIGEMT, EMT_TAGOVF, (void __user *)regs->tpc);
(void __user *)regs->tpc, 0);
out: out:
exception_exit(prev_state); exception_exit(prev_state);
} }
...@@ -2415,8 +2411,7 @@ void do_div0(struct pt_regs *regs) ...@@ -2415,8 +2411,7 @@ void do_div0(struct pt_regs *regs)
regs->tpc &= 0xffffffff; regs->tpc &= 0xffffffff;
regs->tnpc &= 0xffffffff; regs->tnpc &= 0xffffffff;
} }
force_sig_fault(SIGFPE, FPE_INTDIV, force_sig_fault(SIGFPE, FPE_INTDIV, (void __user *)regs->tpc);
(void __user *)regs->tpc, 0);
out: out:
exception_exit(prev_state); exception_exit(prev_state);
} }
...@@ -2612,7 +2607,7 @@ void do_illegal_instruction(struct pt_regs *regs) ...@@ -2612,7 +2607,7 @@ void do_illegal_instruction(struct pt_regs *regs)
} }
} }
} }
force_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)pc, 0); force_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)pc);
out: out:
exception_exit(prev_state); exception_exit(prev_state);
} }
...@@ -2632,7 +2627,7 @@ void mem_address_unaligned(struct pt_regs *regs, unsigned long sfar, unsigned lo ...@@ -2632,7 +2627,7 @@ void mem_address_unaligned(struct pt_regs *regs, unsigned long sfar, unsigned lo
if (is_no_fault_exception(regs)) if (is_no_fault_exception(regs))
return; return;
force_sig_fault(SIGBUS, BUS_ADRALN, (void __user *)sfar, 0); force_sig_fault(SIGBUS, BUS_ADRALN, (void __user *)sfar);
out: out:
exception_exit(prev_state); exception_exit(prev_state);
} }
...@@ -2650,7 +2645,7 @@ void sun4v_do_mna(struct pt_regs *regs, unsigned long addr, unsigned long type_c ...@@ -2650,7 +2645,7 @@ void sun4v_do_mna(struct pt_regs *regs, unsigned long addr, unsigned long type_c
if (is_no_fault_exception(regs)) if (is_no_fault_exception(regs))
return; return;
force_sig_fault(SIGBUS, BUS_ADRALN, (void __user *) addr, 0); force_sig_fault(SIGBUS, BUS_ADRALN, (void __user *) addr);
} }
/* sun4v_mem_corrupt_detect_precise() - Handle precise exception on an ADI /* 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, ...@@ -2697,7 +2692,7 @@ void sun4v_mem_corrupt_detect_precise(struct pt_regs *regs, unsigned long addr,
regs->tpc &= 0xffffffff; regs->tpc &= 0xffffffff;
regs->tnpc &= 0xffffffff; regs->tnpc &= 0xffffffff;
} }
force_sig_fault(SIGSEGV, SEGV_ADIPERR, (void __user *)addr, 0); force_sig_fault(SIGSEGV, SEGV_ADIPERR, (void __user *)addr);
} }
void do_privop(struct pt_regs *regs) void do_privop(struct pt_regs *regs)
...@@ -2712,8 +2707,7 @@ void do_privop(struct pt_regs *regs) ...@@ -2712,8 +2707,7 @@ void do_privop(struct pt_regs *regs)
regs->tpc &= 0xffffffff; regs->tpc &= 0xffffffff;
regs->tnpc &= 0xffffffff; regs->tnpc &= 0xffffffff;
} }
force_sig_fault(SIGILL, ILL_PRVOPC, force_sig_fault(SIGILL, ILL_PRVOPC, (void __user *)regs->tpc);
(void __user *)regs->tpc, 0);
out: out:
exception_exit(prev_state); exception_exit(prev_state);
} }
......
...@@ -278,5 +278,5 @@ asmlinkage void user_unaligned_trap(struct pt_regs *regs, unsigned int insn) ...@@ -278,5 +278,5 @@ asmlinkage void user_unaligned_trap(struct pt_regs *regs, unsigned int insn)
{ {
send_sig_fault(SIGBUS, BUS_ADRALN, send_sig_fault(SIGBUS, BUS_ADRALN,
(void __user *)safe_compute_effective_address(regs, insn), (void __user *)safe_compute_effective_address(regs, insn),
0, current); current);
} }
...@@ -83,7 +83,7 @@ static void __do_fault_siginfo(int code, int sig, struct pt_regs *regs, ...@@ -83,7 +83,7 @@ static void __do_fault_siginfo(int code, int sig, struct pt_regs *regs,
show_signal_msg(regs, sig, code, show_signal_msg(regs, sig, code,
addr, current); addr, current);
force_sig_fault(sig, code, (void __user *) addr, 0); force_sig_fault(sig, code, (void __user *) addr);
} }
static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault) static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
......
...@@ -176,7 +176,7 @@ static void do_fault_siginfo(int code, int sig, struct pt_regs *regs, ...@@ -176,7 +176,7 @@ static void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
if (unlikely(show_unhandled_signals)) if (unlikely(show_unhandled_signals))
show_signal_msg(regs, sig, code, addr, current); show_signal_msg(regs, sig, code, addr, current);
force_sig_fault(sig, code, (void __user *) addr, 0); force_sig_fault(sig, code, (void __user *) addr);
} }
static unsigned int get_fault_insn(struct pt_regs *regs, unsigned int insn) static unsigned int get_fault_insn(struct pt_regs *regs, unsigned int insn)
......
...@@ -34,7 +34,13 @@ static inline void signal_compat_build_tests(void) ...@@ -34,7 +34,13 @@ static inline void signal_compat_build_tests(void)
BUILD_BUG_ON(NSIGSYS != 2); BUILD_BUG_ON(NSIGSYS != 2);
/* This is part of the ABI and can never change in size: */ /* This is part of the ABI and can never change in size: */
BUILD_BUG_ON(sizeof(siginfo_t) != 128);
BUILD_BUG_ON(sizeof(compat_siginfo_t) != 128); BUILD_BUG_ON(sizeof(compat_siginfo_t) != 128);
/* This is a part of the ABI and can never change in alignment */
BUILD_BUG_ON(__alignof__(siginfo_t) != 8);
BUILD_BUG_ON(__alignof__(compat_siginfo_t) != 4);
/* /*
* The offsets of all the (unioned) si_fields are fixed * The offsets of all the (unioned) si_fields are fixed
* in the ABI, of course. Make sure none of them ever * in the ABI, of course. Make sure none of them ever
......
...@@ -114,10 +114,10 @@ static int signalfd_copyinfo(struct signalfd_siginfo __user *uinfo, ...@@ -114,10 +114,10 @@ static int signalfd_copyinfo(struct signalfd_siginfo __user *uinfo,
break; break;
case SIL_FAULT_BNDERR: case SIL_FAULT_BNDERR:
case SIL_FAULT_PKUERR: case SIL_FAULT_PKUERR:
case SIL_PERF_EVENT: case SIL_FAULT_PERF_EVENT:
/* /*
* Fall through to the SIL_FAULT case. SIL_FAULT_BNDERR, * Fall through to the SIL_FAULT case. SIL_FAULT_BNDERR,
* SIL_FAULT_PKUERR, and SIL_PERF_EVENT are only * SIL_FAULT_PKUERR, and SIL_FAULT_PERF_EVENT are only
* generated by faults that deliver them synchronously to * generated by faults that deliver them synchronously to
* userspace. In case someone injects one of these signals * userspace. In case someone injects one of these signals
* and signalfd catches it treat it as SIL_FAULT. * and signalfd catches it treat it as SIL_FAULT.
......
...@@ -298,11 +298,6 @@ static inline void kernel_signal_stop(void) ...@@ -298,11 +298,6 @@ static inline void kernel_signal_stop(void)
schedule(); schedule();
} }
#ifdef __ARCH_SI_TRAPNO
# define ___ARCH_SI_TRAPNO(_a1) , _a1
#else
# define ___ARCH_SI_TRAPNO(_a1)
#endif
#ifdef __ia64__ #ifdef __ia64__
# define ___ARCH_SI_IA64(_a1, _a2, _a3) , _a1, _a2, _a3 # define ___ARCH_SI_IA64(_a1, _a2, _a3) , _a1, _a2, _a3
#else #else
...@@ -310,14 +305,11 @@ static inline void kernel_signal_stop(void) ...@@ -310,14 +305,11 @@ static inline void kernel_signal_stop(void)
#endif #endif
int force_sig_fault_to_task(int sig, int code, void __user *addr int force_sig_fault_to_task(int sig, int code, void __user *addr
___ARCH_SI_TRAPNO(int trapno)
___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr) ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr)
, struct task_struct *t); , struct task_struct *t);
int force_sig_fault(int sig, int code, void __user *addr int force_sig_fault(int sig, int code, void __user *addr
___ARCH_SI_TRAPNO(int trapno)
___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr)); ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr));
int send_sig_fault(int sig, int code, void __user *addr int send_sig_fault(int sig, int code, void __user *addr
___ARCH_SI_TRAPNO(int trapno)
___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr) ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr)
, struct task_struct *t); , struct task_struct *t);
...@@ -329,6 +321,9 @@ int force_sig_pkuerr(void __user *addr, u32 pkey); ...@@ -329,6 +321,9 @@ int force_sig_pkuerr(void __user *addr, u32 pkey);
int force_sig_perf(void __user *addr, u32 type, u64 sig_data); int force_sig_perf(void __user *addr, u32 type, u64 sig_data);
int force_sig_ptrace_errno_trap(int errno, void __user *addr); int force_sig_ptrace_errno_trap(int errno, void __user *addr);
int force_sig_fault_trapno(int sig, int code, void __user *addr, int trapno);
int send_sig_fault_trapno(int sig, int code, void __user *addr, int trapno,
struct task_struct *t);
extern int send_sig_info(int, struct kernel_siginfo *, struct task_struct *); extern int send_sig_info(int, struct kernel_siginfo *, struct task_struct *);
extern void force_sigsegv(int sig); extern void force_sigsegv(int sig);
......
...@@ -44,7 +44,7 @@ enum siginfo_layout { ...@@ -44,7 +44,7 @@ enum siginfo_layout {
SIL_FAULT_MCEERR, SIL_FAULT_MCEERR,
SIL_FAULT_BNDERR, SIL_FAULT_BNDERR,
SIL_FAULT_PKUERR, SIL_FAULT_PKUERR,
SIL_PERF_EVENT, SIL_FAULT_PERF_EVENT,
SIL_CHLD, SIL_CHLD,
SIL_RT, SIL_RT,
SIL_SYS, SIL_SYS,
......
...@@ -29,6 +29,11 @@ typedef union sigval { ...@@ -29,6 +29,11 @@ typedef union sigval {
#define __ARCH_SI_ATTRIBUTES #define __ARCH_SI_ATTRIBUTES
#endif #endif
/*
* Be careful when extending this union. On 32bit siginfo_t is 32bit
* aligned. Which means that a 64bit field or any other field that
* would increase the alignment of siginfo_t will break the ABI.
*/
union __sifields { union __sifields {
/* kill() */ /* kill() */
struct { struct {
......
...@@ -1213,7 +1213,7 @@ static inline bool has_si_pid_and_uid(struct kernel_siginfo *info) ...@@ -1213,7 +1213,7 @@ static inline bool has_si_pid_and_uid(struct kernel_siginfo *info)
case SIL_FAULT_MCEERR: case SIL_FAULT_MCEERR:
case SIL_FAULT_BNDERR: case SIL_FAULT_BNDERR:
case SIL_FAULT_PKUERR: case SIL_FAULT_PKUERR:
case SIL_PERF_EVENT: case SIL_FAULT_PERF_EVENT:
case SIL_SYS: case SIL_SYS:
ret = false; ret = false;
break; break;
...@@ -1666,7 +1666,6 @@ void force_sigsegv(int sig) ...@@ -1666,7 +1666,6 @@ void force_sigsegv(int sig)
} }
int force_sig_fault_to_task(int sig, int code, void __user *addr int force_sig_fault_to_task(int sig, int code, void __user *addr
___ARCH_SI_TRAPNO(int trapno)
___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr) ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr)
, struct task_struct *t) , struct task_struct *t)
{ {
...@@ -1677,9 +1676,6 @@ int force_sig_fault_to_task(int sig, int code, void __user *addr ...@@ -1677,9 +1676,6 @@ int force_sig_fault_to_task(int sig, int code, void __user *addr
info.si_errno = 0; info.si_errno = 0;
info.si_code = code; info.si_code = code;
info.si_addr = addr; info.si_addr = addr;
#ifdef __ARCH_SI_TRAPNO
info.si_trapno = trapno;
#endif
#ifdef __ia64__ #ifdef __ia64__
info.si_imm = imm; info.si_imm = imm;
info.si_flags = flags; info.si_flags = flags;
...@@ -1689,16 +1685,13 @@ int force_sig_fault_to_task(int sig, int code, void __user *addr ...@@ -1689,16 +1685,13 @@ int force_sig_fault_to_task(int sig, int code, void __user *addr
} }
int force_sig_fault(int sig, int code, void __user *addr int force_sig_fault(int sig, int code, void __user *addr
___ARCH_SI_TRAPNO(int trapno)
___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr)) ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr))
{ {
return force_sig_fault_to_task(sig, code, addr return force_sig_fault_to_task(sig, code, addr
___ARCH_SI_TRAPNO(trapno)
___ARCH_SI_IA64(imm, flags, isr), current); ___ARCH_SI_IA64(imm, flags, isr), current);
} }
int send_sig_fault(int sig, int code, void __user *addr int send_sig_fault(int sig, int code, void __user *addr
___ARCH_SI_TRAPNO(int trapno)
___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr) ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr)
, struct task_struct *t) , struct task_struct *t)
{ {
...@@ -1709,9 +1702,6 @@ int send_sig_fault(int sig, int code, void __user *addr ...@@ -1709,9 +1702,6 @@ int send_sig_fault(int sig, int code, void __user *addr
info.si_errno = 0; info.si_errno = 0;
info.si_code = code; info.si_code = code;
info.si_addr = addr; info.si_addr = addr;
#ifdef __ARCH_SI_TRAPNO
info.si_trapno = trapno;
#endif
#ifdef __ia64__ #ifdef __ia64__
info.si_imm = imm; info.si_imm = imm;
info.si_flags = flags; info.si_flags = flags;
...@@ -1808,6 +1798,39 @@ int force_sig_ptrace_errno_trap(int errno, void __user *addr) ...@@ -1808,6 +1798,39 @@ int force_sig_ptrace_errno_trap(int errno, void __user *addr)
return force_sig_info(&info); return force_sig_info(&info);
} }
/* For the rare architectures that include trap information using
* si_trapno.
*/
int force_sig_fault_trapno(int sig, int code, void __user *addr, int trapno)
{
struct kernel_siginfo info;
clear_siginfo(&info);
info.si_signo = sig;
info.si_errno = 0;
info.si_code = code;
info.si_addr = addr;
info.si_trapno = trapno;
return force_sig_info(&info);
}
/* For the rare architectures that include trap information using
* si_trapno.
*/
int send_sig_fault_trapno(int sig, int code, void __user *addr, int trapno,
struct task_struct *t)
{
struct kernel_siginfo info;
clear_siginfo(&info);
info.si_signo = sig;
info.si_errno = 0;
info.si_code = code;
info.si_addr = addr;
info.si_trapno = trapno;
return send_sig_info(info.si_signo, &info, t);
}
int kill_pgrp(struct pid *pid, int sig, int priv) int kill_pgrp(struct pid *pid, int sig, int priv)
{ {
int ret; int ret;
...@@ -2557,7 +2580,7 @@ static void hide_si_addr_tag_bits(struct ksignal *ksig) ...@@ -2557,7 +2580,7 @@ static void hide_si_addr_tag_bits(struct ksignal *ksig)
case SIL_FAULT_MCEERR: case SIL_FAULT_MCEERR:
case SIL_FAULT_BNDERR: case SIL_FAULT_BNDERR:
case SIL_FAULT_PKUERR: case SIL_FAULT_PKUERR:
case SIL_PERF_EVENT: case SIL_FAULT_PERF_EVENT:
ksig->info.si_addr = arch_untagged_si_addr( ksig->info.si_addr = arch_untagged_si_addr(
ksig->info.si_addr, ksig->sig, ksig->info.si_code); ksig->info.si_addr, ksig->sig, ksig->info.si_code);
break; break;
...@@ -3242,11 +3265,14 @@ enum siginfo_layout siginfo_layout(unsigned sig, int si_code) ...@@ -3242,11 +3265,14 @@ enum siginfo_layout siginfo_layout(unsigned sig, int si_code)
layout = SIL_FAULT_PKUERR; layout = SIL_FAULT_PKUERR;
#endif #endif
else if ((sig == SIGTRAP) && (si_code == TRAP_PERF)) else if ((sig == SIGTRAP) && (si_code == TRAP_PERF))
layout = SIL_PERF_EVENT; layout = SIL_FAULT_PERF_EVENT;
#ifdef __ARCH_SI_TRAPNO else if (IS_ENABLED(CONFIG_SPARC) &&
else if (layout == SIL_FAULT) (sig == SIGILL) && (si_code == ILL_ILLTRP))
layout = SIL_FAULT_TRAPNO;
else if (IS_ENABLED(CONFIG_ALPHA) &&
((sig == SIGFPE) ||
((sig == SIGTRAP) && (si_code == TRAP_UNK))))
layout = SIL_FAULT_TRAPNO; layout = SIL_FAULT_TRAPNO;
#endif
} }
else if (si_code <= NSIGPOLL) else if (si_code <= NSIGPOLL)
layout = SIL_POLL; layout = SIL_POLL;
...@@ -3368,7 +3394,7 @@ void copy_siginfo_to_external32(struct compat_siginfo *to, ...@@ -3368,7 +3394,7 @@ void copy_siginfo_to_external32(struct compat_siginfo *to,
to->si_addr = ptr_to_compat(from->si_addr); to->si_addr = ptr_to_compat(from->si_addr);
to->si_pkey = from->si_pkey; to->si_pkey = from->si_pkey;
break; break;
case SIL_PERF_EVENT: case SIL_FAULT_PERF_EVENT:
to->si_addr = ptr_to_compat(from->si_addr); to->si_addr = ptr_to_compat(from->si_addr);
to->si_perf_data = from->si_perf_data; to->si_perf_data = from->si_perf_data;
to->si_perf_type = from->si_perf_type; to->si_perf_type = from->si_perf_type;
...@@ -3445,7 +3471,7 @@ static int post_copy_siginfo_from_user32(kernel_siginfo_t *to, ...@@ -3445,7 +3471,7 @@ static int post_copy_siginfo_from_user32(kernel_siginfo_t *to,
to->si_addr = compat_ptr(from->si_addr); to->si_addr = compat_ptr(from->si_addr);
to->si_pkey = from->si_pkey; to->si_pkey = from->si_pkey;
break; break;
case SIL_PERF_EVENT: case SIL_FAULT_PERF_EVENT:
to->si_addr = compat_ptr(from->si_addr); to->si_addr = compat_ptr(from->si_addr);
to->si_perf_data = from->si_perf_data; to->si_perf_data = from->si_perf_data;
to->si_perf_type = from->si_perf_type; to->si_perf_type = from->si_perf_type;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment