summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-01-30 17:18:52 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-01-30 17:18:52 -0500
commitd4173023e63cb85ec02eda02d1789bf078719f00 (patch)
treea07f5e8d8a98f99c576fedb95035e5289c64276c
parent0aebc6a440b942df6221a7765f077f02217e0114 (diff)
parentc0f45555b82450a56c0da11866163b764aeb1a21 (diff)
Merge branch 'siginfo-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace
Pull siginfo cleanups from Eric Biederman: "Long ago when 2.4 was just a testing release copy_siginfo_to_user was made to copy individual fields to userspace, possibly for efficiency and to ensure initialized values were not copied to userspace. Unfortunately the design was complex, it's assumptions unstated, and humans are fallible and so while it worked much of the time that design failed to ensure unitialized memory is not copied to userspace. This set of changes is part of a new design to clean up siginfo and simplify things, and hopefully make the siginfo handling robust enough that a simple inspection of the code can be made to ensure we don't copy any unitializied fields to userspace. The design is to unify struct siginfo and struct compat_siginfo into a single definition that is shared between all architectures so that anyone adding to the set of information shared with struct siginfo can see the whole picture. Hopefully ensuring all future si_code assignments are arch independent. The design is to unify copy_siginfo_to_user32 and copy_siginfo_from_user32 so that those function are complete and cope with all of the different cases documented in signinfo_layout. I don't think there was a single implementation of either of those functions that was complete and correct before my changes unified them. The design is to introduce a series of helpers including force_siginfo_fault that take the values that are needed in struct siginfo and build the siginfo structure for their callers. Ensuring struct siginfo is built correctly. The remaining work for 4.17 (unless someone thinks it is post -rc1 material) is to push usage of those helpers down into the architectures so that architecture specific code will not need to deal with the fiddly work of intializing struct siginfo, and then when struct siginfo is guaranteed to be fully initialized change copy siginfo_to_user into a simple wrapper around copy_to_user. Further there is work in progress on the issues that have been documented requires arch specific knowledge to sort out. The changes below fix or at least document all of the issues that have been found with siginfo generation. Then proceed to unify struct siginfo the 32 bit helpers that copy siginfo to and from userspace, and generally clean up anything that is not arch specific with regards to siginfo generation. It is a lot but with the unification you can of siginfo you can already see the code reduction in the kernel" * 'siginfo-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace: (45 commits) signal/memory-failure: Use force_sig_mceerr and send_sig_mceerr mm/memory_failure: Remove unused trapno from memory_failure signal/ptrace: Add force_sig_ptrace_errno_trap and use it where needed signal/powerpc: Remove unnecessary signal_code parameter of do_send_trap signal: Helpers for faults with specialized siginfo layouts signal: Add send_sig_fault and force_sig_fault signal: Replace memset(info,...) with clear_siginfo for clarity signal: Don't use structure initializers for struct siginfo signal/arm64: Better isolate the COMPAT_TASK portion of ptrace_hbptriggered ptrace: Use copy_siginfo in setsiginfo and getsiginfo signal: Unify and correct copy_siginfo_to_user32 signal: Remove the code to clear siginfo before calling copy_siginfo_from_user32 signal: Unify and correct copy_siginfo_from_user32 signal/blackfin: Remove pointless UID16_SIGINFO_COMPAT_NEEDED signal/blackfin: Move the blackfin specific si_codes to asm-generic/siginfo.h signal/tile: Move the tile specific si_codes to asm-generic/siginfo.h signal/frv: Move the frv specific si_codes to asm-generic/siginfo.h signal/ia64: Move the ia64 specific si_codes to asm-generic/siginfo.h signal/powerpc: Remove redefinition of NSIGTRAP on powerpc signal: Move addr_lsb into the _sigfault union for clarity ...
-rw-r--r--arch/arc/kernel/traps.c14
-rw-r--r--arch/arm/include/uapi/asm/siginfo.h13
-rw-r--r--arch/arm/kernel/ptrace.c8
-rw-r--r--arch/arm/vfp/vfpmodule.c2
-rw-r--r--arch/arm64/include/asm/compat.h64
-rw-r--r--arch/arm64/include/uapi/asm/siginfo.h21
-rw-r--r--arch/arm64/kernel/debug-monitors.c13
-rw-r--r--arch/arm64/kernel/fpsimd.c2
-rw-r--r--arch/arm64/kernel/ptrace.c42
-rw-r--r--arch/arm64/kernel/signal32.c80
-rw-r--r--arch/arm64/mm/fault.c114
-rw-r--r--arch/blackfin/include/uapi/asm/siginfo.h34
-rw-r--r--arch/frv/include/uapi/asm/Kbuild1
-rw-r--r--arch/frv/include/uapi/asm/siginfo.h13
-rw-r--r--arch/ia64/include/uapi/asm/siginfo.h96
-rw-r--r--arch/ia64/kernel/signal.c52
-rw-r--r--arch/m68k/mm/fault.c3
-rw-r--r--arch/metag/include/uapi/asm/siginfo.h7
-rw-r--r--arch/metag/kernel/traps.c2
-rw-r--r--arch/mips/include/asm/compat.h73
-rw-r--r--arch/mips/include/uapi/asm/siginfo.h86
-rw-r--r--arch/mips/kernel/signal32.c67
-rw-r--r--arch/mips/kernel/traps.c29
-rw-r--r--arch/mn10300/mm/misalignment.c2
-rw-r--r--arch/openrisc/kernel/traps.c10
-rw-r--r--arch/parisc/include/asm/compat.h64
-rw-r--r--arch/parisc/include/uapi/asm/siginfo.h7
-rw-r--r--arch/parisc/kernel/pdt.c2
-rw-r--r--arch/parisc/kernel/signal32.c106
-rw-r--r--arch/parisc/kernel/signal32.h3
-rw-r--r--arch/parisc/kernel/traps.c2
-rw-r--r--arch/powerpc/include/asm/compat.h65
-rw-r--r--arch/powerpc/include/asm/debug.h2
-rw-r--r--arch/powerpc/include/uapi/asm/siginfo.h16
-rw-r--r--arch/powerpc/kernel/mce.c2
-rw-r--r--arch/powerpc/kernel/process.c13
-rw-r--r--arch/powerpc/kernel/signal_32.c66
-rw-r--r--arch/powerpc/kernel/traps.c22
-rw-r--r--arch/powerpc/platforms/powernv/opal-memory-errors.c2
-rw-r--r--arch/s390/include/asm/compat.h73
-rw-r--r--arch/s390/kernel/compat_signal.c100
-rw-r--r--arch/sh/kernel/traps_32.c3
-rw-r--r--arch/sparc/include/asm/compat.h59
-rw-r--r--arch/sparc/kernel/signal32.c69
-rw-r--r--arch/tile/include/asm/compat.h62
-rw-r--r--arch/tile/include/uapi/asm/siginfo.h8
-rw-r--r--arch/tile/kernel/compat_signal.c73
-rw-r--r--arch/tile/kernel/single_step.c24
-rw-r--r--arch/tile/kernel/traps.c4
-rw-r--r--arch/tile/kernel/unaligned.c46
-rw-r--r--arch/um/kernel/trap.c2
-rw-r--r--arch/x86/include/asm/compat.h86
-rw-r--r--arch/x86/include/asm/fpu/signal.h6
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce.c6
-rw-r--r--arch/x86/kernel/signal_compat.c123
-rw-r--r--arch/xtensa/kernel/ptrace.c8
-rw-r--r--drivers/acpi/apei/ghes.c2
-rw-r--r--drivers/base/memory.c2
-rw-r--r--drivers/ras/cec.c2
-rw-r--r--drivers/usb/core/devio.c4
-rw-r--r--fs/fcntl.c1
-rw-r--r--include/linux/compat.h100
-rw-r--r--include/linux/mm.h4
-rw-r--r--include/linux/sched/signal.h28
-rw-r--r--include/linux/signal.h15
-rw-r--r--include/uapi/asm-generic/siginfo.h109
-rw-r--r--ipc/mqueue.c1
-rw-r--r--kernel/debug/kdb/kdb_main.c10
-rw-r--r--kernel/debug/kdb/kdb_private.h2
-rw-r--r--kernel/ptrace.c5
-rw-r--r--kernel/seccomp.c2
-rw-r--r--kernel/signal.c350
-rw-r--r--kernel/time/posix-timers.c2
-rw-r--r--mm/hwpoison-inject.c2
-rw-r--r--mm/madvise.c2
-rw-r--r--mm/memory-failure.c48
76 files changed, 855 insertions, 1808 deletions
diff --git a/arch/arc/kernel/traps.c b/arch/arc/kernel/traps.c
index 133a4dae41fe..b123558bf0bb 100644
--- a/arch/arc/kernel/traps.c
+++ b/arch/arc/kernel/traps.c
@@ -65,12 +65,14 @@ unhandled_exception(const char *str, struct pt_regs *regs, siginfo_t *info)
65#define DO_ERROR_INFO(signr, str, name, sicode) \ 65#define DO_ERROR_INFO(signr, str, name, sicode) \
66int name(unsigned long address, struct pt_regs *regs) \ 66int name(unsigned long address, struct pt_regs *regs) \
67{ \ 67{ \
68 siginfo_t info = { \ 68 siginfo_t info; \
69 .si_signo = signr, \ 69 \
70 .si_errno = 0, \ 70 clear_siginfo(&info); \
71 .si_code = sicode, \ 71 info.si_signo = signr; \
72 .si_addr = (void __user *)address, \ 72 info.si_errno = 0; \
73 }; \ 73 info.si_code = sicode; \
74 info.si_addr = (void __user *)address; \
75 \
74 return unhandled_exception(str, regs, &info);\ 76 return unhandled_exception(str, regs, &info);\
75} 77}
76 78
diff --git a/arch/arm/include/uapi/asm/siginfo.h b/arch/arm/include/uapi/asm/siginfo.h
new file mode 100644
index 000000000000..d0513880be21
--- /dev/null
+++ b/arch/arm/include/uapi/asm/siginfo.h
@@ -0,0 +1,13 @@
1#ifndef __ASM_SIGINFO_H
2#define __ASM_SIGINFO_H
3
4#include <asm-generic/siginfo.h>
5
6/*
7 * SIGFPE si_codes
8 */
9#ifdef __KERNEL__
10#define FPE_FIXME 0 /* Broken dup of SI_USER */
11#endif /* __KERNEL__ */
12
13#endif
diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
index 58e3771e4c5b..7724b0f661b3 100644
--- a/arch/arm/kernel/ptrace.c
+++ b/arch/arm/kernel/ptrace.c
@@ -390,7 +390,6 @@ static void ptrace_hbptriggered(struct perf_event *bp,
390 struct arch_hw_breakpoint *bkpt = counter_arch_bp(bp); 390 struct arch_hw_breakpoint *bkpt = counter_arch_bp(bp);
391 long num; 391 long num;
392 int i; 392 int i;
393 siginfo_t info;
394 393
395 for (i = 0; i < ARM_MAX_HBP_SLOTS; ++i) 394 for (i = 0; i < ARM_MAX_HBP_SLOTS; ++i)
396 if (current->thread.debug.hbp[i] == bp) 395 if (current->thread.debug.hbp[i] == bp)
@@ -398,12 +397,7 @@ static void ptrace_hbptriggered(struct perf_event *bp,
398 397
399 num = (i == ARM_MAX_HBP_SLOTS) ? 0 : ptrace_hbp_idx_to_num(i); 398 num = (i == ARM_MAX_HBP_SLOTS) ? 0 : ptrace_hbp_idx_to_num(i);
400 399
401 info.si_signo = SIGTRAP; 400 force_sig_ptrace_errno_trap((int)num, (void __user *)(bkpt->trigger));
402 info.si_errno = (int)num;
403 info.si_code = TRAP_HWBKPT;
404 info.si_addr = (void __user *)(bkpt->trigger);
405
406 force_sig_info(SIGTRAP, &info, current);
407} 401}
408 402
409/* 403/*
diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c
index a71a48e71fff..03c6a3c72f9c 100644
--- a/arch/arm/vfp/vfpmodule.c
+++ b/arch/arm/vfp/vfpmodule.c
@@ -257,7 +257,7 @@ static void vfp_raise_exceptions(u32 exceptions, u32 inst, u32 fpscr, struct pt_
257 257
258 if (exceptions == VFP_EXCEPTION_ERROR) { 258 if (exceptions == VFP_EXCEPTION_ERROR) {
259 vfp_panic("unhandled bounce", inst); 259 vfp_panic("unhandled bounce", inst);
260 vfp_raise_sigfpe(0, regs); 260 vfp_raise_sigfpe(FPE_FIXME, regs);
261 return; 261 return;
262 } 262 }
263 263
diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h
index a3c7f271ad4c..c00c62e1a4a3 100644
--- a/arch/arm64/include/asm/compat.h
+++ b/arch/arm64/include/asm/compat.h
@@ -150,70 +150,6 @@ typedef u32 compat_old_sigset_t;
150 150
151typedef u32 compat_sigset_word; 151typedef u32 compat_sigset_word;
152 152
153typedef union compat_sigval {
154 compat_int_t sival_int;
155 compat_uptr_t sival_ptr;
156} compat_sigval_t;
157
158typedef struct compat_siginfo {
159 int si_signo;
160 int si_errno;
161 int si_code;
162
163 union {
164 int _pad[128/sizeof(int) - 3];
165
166 /* kill() */
167 struct {
168 compat_pid_t _pid; /* sender's pid */
169 __compat_uid32_t _uid; /* sender's uid */
170 } _kill;
171
172 /* POSIX.1b timers */
173 struct {
174 compat_timer_t _tid; /* timer id */
175 int _overrun; /* overrun count */
176 compat_sigval_t _sigval; /* same as below */
177 int _sys_private; /* not to be passed to user */
178 } _timer;
179
180 /* POSIX.1b signals */
181 struct {
182 compat_pid_t _pid; /* sender's pid */
183 __compat_uid32_t _uid; /* sender's uid */
184 compat_sigval_t _sigval;
185 } _rt;
186
187 /* SIGCHLD */
188 struct {
189 compat_pid_t _pid; /* which child */
190 __compat_uid32_t _uid; /* sender's uid */
191 int _status; /* exit code */
192 compat_clock_t _utime;
193 compat_clock_t _stime;
194 } _sigchld;
195
196 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
197 struct {
198 compat_uptr_t _addr; /* faulting insn/memory ref. */
199 short _addr_lsb; /* LSB of the reported address */
200 } _sigfault;
201
202 /* SIGPOLL */
203 struct {
204 compat_long_t _band; /* POLL_IN, POLL_OUT, POLL_MSG */
205 int _fd;
206 } _sigpoll;
207
208 /* SIGSYS */
209 struct {
210 compat_uptr_t _call_addr; /* calling user insn */
211 int _syscall; /* triggering system call number */
212 compat_uint_t _arch; /* AUDIT_ARCH_* of syscall */
213 } _sigsys;
214 } _sifields;
215} compat_siginfo_t;
216
217#define COMPAT_OFF_T_MAX 0x7fffffff 153#define COMPAT_OFF_T_MAX 0x7fffffff
218 154
219/* 155/*
diff --git a/arch/arm64/include/uapi/asm/siginfo.h b/arch/arm64/include/uapi/asm/siginfo.h
index 574d12f86039..9b4d91277742 100644
--- a/arch/arm64/include/uapi/asm/siginfo.h
+++ b/arch/arm64/include/uapi/asm/siginfo.h
@@ -21,4 +21,25 @@
21 21
22#include <asm-generic/siginfo.h> 22#include <asm-generic/siginfo.h>
23 23
24/*
25 * SIGFPE si_codes
26 */
27#ifdef __KERNEL__
28#define FPE_FIXME 0 /* Broken dup of SI_USER */
29#endif /* __KERNEL__ */
30
31/*
32 * SIGBUS si_codes
33 */
34#ifdef __KERNEL__
35#define BUS_FIXME 0 /* Broken dup of SI_USER */
36#endif /* __KERNEL__ */
37
38/*
39 * SIGTRAP si_codes
40 */
41#ifdef __KERNEL__
42#define TRAP_FIXME 0 /* Broken dup of SI_USER */
43#endif /* __KERNEL__ */
44
24#endif 45#endif
diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
index a88b6ccebbb4..53781f5687c5 100644
--- a/arch/arm64/kernel/debug-monitors.c
+++ b/arch/arm64/kernel/debug-monitors.c
@@ -209,12 +209,13 @@ NOKPROBE_SYMBOL(call_step_hook);
209static void send_user_sigtrap(int si_code) 209static void send_user_sigtrap(int si_code)
210{ 210{
211 struct pt_regs *regs = current_pt_regs(); 211 struct pt_regs *regs = current_pt_regs();
212 siginfo_t info = { 212 siginfo_t info;
213 .si_signo = SIGTRAP, 213
214 .si_errno = 0, 214 clear_siginfo(&info);
215 .si_code = si_code, 215 info.si_signo = SIGTRAP;
216 .si_addr = (void __user *)instruction_pointer(regs), 216 info.si_errno = 0;
217 }; 217 info.si_code = si_code;
218 info.si_addr = (void __user *)instruction_pointer(regs);
218 219
219 if (WARN_ON(!user_mode(regs))) 220 if (WARN_ON(!user_mode(regs)))
220 return; 221 return;
diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
index 55fb544072f6..e7226c4c7493 100644
--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
@@ -867,7 +867,7 @@ asmlinkage void do_fpsimd_acc(unsigned int esr, struct pt_regs *regs)
867asmlinkage void do_fpsimd_exc(unsigned int esr, struct pt_regs *regs) 867asmlinkage void do_fpsimd_exc(unsigned int esr, struct pt_regs *regs)
868{ 868{
869 siginfo_t info; 869 siginfo_t info;
870 unsigned int si_code = 0; 870 unsigned int si_code = FPE_FIXME;
871 871
872 if (esr & FPEXC_IOF) 872 if (esr & FPEXC_IOF)
873 si_code = FPE_FLTINV; 873 si_code = FPE_FLTINV;
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index 7c44658b316d..6618036ae6d4 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -180,34 +180,34 @@ static void ptrace_hbptriggered(struct perf_event *bp,
180 struct pt_regs *regs) 180 struct pt_regs *regs)
181{ 181{
182 struct arch_hw_breakpoint *bkpt = counter_arch_bp(bp); 182 struct arch_hw_breakpoint *bkpt = counter_arch_bp(bp);
183 siginfo_t info = { 183 siginfo_t info;
184 .si_signo = SIGTRAP,
185 .si_errno = 0,
186 .si_code = TRAP_HWBKPT,
187 .si_addr = (void __user *)(bkpt->trigger),
188 };
189 184
190#ifdef CONFIG_COMPAT 185 clear_siginfo(&info);
191 int i; 186 info.si_signo = SIGTRAP;
187 info.si_errno = 0;
188 info.si_code = TRAP_HWBKPT;
189 info.si_addr = (void __user *)(bkpt->trigger);
192 190
193 if (!is_compat_task()) 191#ifdef CONFIG_COMPAT
194 goto send_sig; 192 if (is_compat_task()) {
193 int si_errno = 0;
194 int i;
195 195
196 for (i = 0; i < ARM_MAX_BRP; ++i) { 196 for (i = 0; i < ARM_MAX_BRP; ++i) {
197 if (current->thread.debug.hbp_break[i] == bp) { 197 if (current->thread.debug.hbp_break[i] == bp) {
198 info.si_errno = (i << 1) + 1; 198 si_errno = (i << 1) + 1;
199 break; 199 break;
200 }
200 } 201 }
201 }
202 202
203 for (i = 0; i < ARM_MAX_WRP; ++i) { 203 for (i = 0; i < ARM_MAX_WRP; ++i) {
204 if (current->thread.debug.hbp_watch[i] == bp) { 204 if (current->thread.debug.hbp_watch[i] == bp) {
205 info.si_errno = -((i << 1) + 1); 205 si_errno = -((i << 1) + 1);
206 break; 206 break;
207 }
207 } 208 }
209 force_sig_ptrace_errno_trap(si_errno, (void __user *)bkpt->trigger);
208 } 210 }
209
210send_sig:
211#endif 211#endif
212 force_sig_info(SIGTRAP, &info, current); 212 force_sig_info(SIGTRAP, &info, current);
213} 213}
diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c
index a124140c0926..79feb861929b 100644
--- a/arch/arm64/kernel/signal32.c
+++ b/arch/arm64/kernel/signal32.c
@@ -125,86 +125,6 @@ static inline int get_sigset_t(sigset_t *set,
125 return 0; 125 return 0;
126} 126}
127 127
128int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from)
129{
130 int err;
131
132 if (!access_ok(VERIFY_WRITE, to, sizeof(*to)))
133 return -EFAULT;
134
135 /* If you change siginfo_t structure, please be sure
136 * this code is fixed accordingly.
137 * It should never copy any pad contained in the structure
138 * to avoid security leaks, but must copy the generic
139 * 3 ints plus the relevant union member.
140 * This routine must convert siginfo from 64bit to 32bit as well
141 * at the same time.
142 */
143 err = __put_user(from->si_signo, &to->si_signo);
144 err |= __put_user(from->si_errno, &to->si_errno);
145 err |= __put_user(from->si_code, &to->si_code);
146 if (from->si_code < 0)
147 err |= __copy_to_user(&to->_sifields._pad, &from->_sifields._pad,
148 SI_PAD_SIZE);
149 else switch (siginfo_layout(from->si_signo, from->si_code)) {
150 case SIL_KILL:
151 err |= __put_user(from->si_pid, &to->si_pid);
152 err |= __put_user(from->si_uid, &to->si_uid);
153 break;
154 case SIL_TIMER:
155 err |= __put_user(from->si_tid, &to->si_tid);
156 err |= __put_user(from->si_overrun, &to->si_overrun);
157 err |= __put_user(from->si_int, &to->si_int);
158 break;
159 case SIL_POLL:
160 err |= __put_user(from->si_band, &to->si_band);
161 err |= __put_user(from->si_fd, &to->si_fd);
162 break;
163 case SIL_FAULT:
164 err |= __put_user((compat_uptr_t)(unsigned long)from->si_addr,
165 &to->si_addr);
166#ifdef BUS_MCEERR_AO
167 /*
168 * Other callers might not initialize the si_lsb field,
169 * so check explicitly for the right codes here.
170 */
171 if (from->si_signo == SIGBUS &&
172 (from->si_code == BUS_MCEERR_AR || from->si_code == BUS_MCEERR_AO))
173 err |= __put_user(from->si_addr_lsb, &to->si_addr_lsb);
174#endif
175 break;
176 case SIL_CHLD:
177 err |= __put_user(from->si_pid, &to->si_pid);
178 err |= __put_user(from->si_uid, &to->si_uid);
179 err |= __put_user(from->si_status, &to->si_status);
180 err |= __put_user(from->si_utime, &to->si_utime);
181 err |= __put_user(from->si_stime, &to->si_stime);
182 break;
183 case SIL_RT:
184 err |= __put_user(from->si_pid, &to->si_pid);
185 err |= __put_user(from->si_uid, &to->si_uid);
186 err |= __put_user(from->si_int, &to->si_int);
187 break;
188 case SIL_SYS:
189 err |= __put_user((compat_uptr_t)(unsigned long)
190 from->si_call_addr, &to->si_call_addr);
191 err |= __put_user(from->si_syscall, &to->si_syscall);
192 err |= __put_user(from->si_arch, &to->si_arch);
193 break;
194 }
195 return err;
196}
197
198int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
199{
200 if (copy_from_user(to, from, __ARCH_SI_PREAMBLE_SIZE) ||
201 copy_from_user(to->_sifields._pad,
202 from->_sifields._pad, SI_PAD_SIZE))
203 return -EFAULT;
204
205 return 0;
206}
207
208/* 128/*
209 * VFP save/restore code. 129 * VFP save/restore code.
210 * 130 *
diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index 6c30cf92f492..ce441d29e7f6 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -596,7 +596,7 @@ static int do_sea(unsigned long addr, unsigned int esr, struct pt_regs *regs)
596 596
597 info.si_signo = SIGBUS; 597 info.si_signo = SIGBUS;
598 info.si_errno = 0; 598 info.si_errno = 0;
599 info.si_code = 0; 599 info.si_code = BUS_FIXME;
600 if (esr & ESR_ELx_FnV) 600 if (esr & ESR_ELx_FnV)
601 info.si_addr = NULL; 601 info.si_addr = NULL;
602 else 602 else
@@ -607,70 +607,70 @@ static int do_sea(unsigned long addr, unsigned int esr, struct pt_regs *regs)
607} 607}
608 608
609static const struct fault_info fault_info[] = { 609static const struct fault_info fault_info[] = {
610 { do_bad, SIGBUS, 0, "ttbr address size fault" }, 610 { do_bad, SIGBUS, BUS_FIXME, "ttbr address size fault" },
611 { do_bad, SIGBUS, 0, "level 1 address size fault" }, 611 { do_bad, SIGBUS, BUS_FIXME, "level 1 address size fault" },
612 { do_bad, SIGBUS, 0, "level 2 address size fault" }, 612 { do_bad, SIGBUS, BUS_FIXME, "level 2 address size fault" },
613 { do_bad, SIGBUS, 0, "level 3 address size fault" }, 613 { do_bad, SIGBUS, BUS_FIXME, "level 3 address size fault" },
614 { do_translation_fault, SIGSEGV, SEGV_MAPERR, "level 0 translation fault" }, 614 { do_translation_fault, SIGSEGV, SEGV_MAPERR, "level 0 translation fault" },
615 { do_translation_fault, SIGSEGV, SEGV_MAPERR, "level 1 translation fault" }, 615 { do_translation_fault, SIGSEGV, SEGV_MAPERR, "level 1 translation fault" },
616 { do_translation_fault, SIGSEGV, SEGV_MAPERR, "level 2 translation fault" }, 616 { do_translation_fault, SIGSEGV, SEGV_MAPERR, "level 2 translation fault" },
617 { do_translation_fault, SIGSEGV, SEGV_MAPERR, "level 3 translation fault" }, 617 { do_translation_fault, SIGSEGV, SEGV_MAPERR, "level 3 translation fault" },
618 { do_bad, SIGBUS, 0, "unknown 8" }, 618 { do_bad, SIGBUS, BUS_FIXME, "unknown 8" },
619 { do_page_fault, SIGSEGV, SEGV_ACCERR, "level 1 access flag fault" }, 619 { do_page_fault, SIGSEGV, SEGV_ACCERR, "level 1 access flag fault" },
620 { do_page_fault, SIGSEGV, SEGV_ACCERR, "level 2 access flag fault" }, 620 { do_page_fault, SIGSEGV, SEGV_ACCERR, "level 2 access flag fault" },
621 { do_page_fault, SIGSEGV, SEGV_ACCERR, "level 3 access flag fault" }, 621 { do_page_fault, SIGSEGV, SEGV_ACCERR, "level 3 access flag fault" },
622 { do_bad, SIGBUS, 0, "unknown 12" }, 622 { do_bad, SIGBUS, BUS_FIXME, "unknown 12" },
623 { do_page_fault, SIGSEGV, SEGV_ACCERR, "level 1 permission fault" }, 623 { do_page_fault, SIGSEGV, SEGV_ACCERR, "level 1 permission fault" },
624 { do_page_fault, SIGSEGV, SEGV_ACCERR, "level 2 permission fault" }, 624 { do_page_fault, SIGSEGV, SEGV_ACCERR, "level 2 permission fault" },
625 { do_page_fault, SIGSEGV, SEGV_ACCERR, "level 3 permission fault" }, 625 { do_page_fault, SIGSEGV, SEGV_ACCERR, "level 3 permission fault" },
626 { do_sea, SIGBUS, 0, "synchronous external abort" }, 626 { do_sea, SIGBUS, BUS_FIXME, "synchronous external abort" },
627 { do_bad, SIGBUS, 0, "unknown 17" }, 627 { do_bad, SIGBUS, BUS_FIXME, "unknown 17" },
628 { do_bad, SIGBUS, 0, "unknown 18" }, 628 { do_bad, SIGBUS, BUS_FIXME, "unknown 18" },
629 { do_bad, SIGBUS, 0, "unknown 19" }, 629 { do_bad, SIGBUS, BUS_FIXME, "unknown 19" },
630 { do_sea, SIGBUS, 0, "level 0 (translation table walk)" }, 630 { do_sea, SIGBUS, BUS_FIXME, "level 0 (translation table walk)" },
631 { do_sea, SIGBUS, 0, "level 1 (translation table walk)" }, 631 { do_sea, SIGBUS, BUS_FIXME, "level 1 (translation table walk)" },
632 { do_sea, SIGBUS, 0, "level 2 (translation table walk)" }, 632 { do_sea, SIGBUS, BUS_FIXME, "level 2 (translation table walk)" },
633 { do_sea, SIGBUS, 0, "level 3 (translation table walk)" }, 633 { do_sea, SIGBUS, BUS_FIXME, "level 3 (translation table walk)" },
634 { do_sea, SIGBUS, 0, "synchronous parity or ECC error" }, // Reserved when RAS is implemented 634 { do_sea, SIGBUS, BUS_FIXME, "synchronous parity or ECC error" }, // Reserved when RAS is implemented
635 { do_bad, SIGBUS, 0, "unknown 25" }, 635 { do_bad, SIGBUS, BUS_FIXME, "unknown 25" },
636 { do_bad, SIGBUS, 0, "unknown 26" }, 636 { do_bad, SIGBUS, BUS_FIXME, "unknown 26" },
637 { do_bad, SIGBUS, 0, "unknown 27" }, 637 { do_bad, SIGBUS, BUS_FIXME, "unknown 27" },
638 { do_sea, SIGBUS, 0, "level 0 synchronous parity error (translation table walk)" }, // Reserved when RAS is implemented 638 { do_sea, SIGBUS, BUS_FIXME, "level 0 synchronous parity error (translation table walk)" }, // Reserved when RAS is implemented
639 { do_sea, SIGBUS, 0, "level 1 synchronous parity error (translation table walk)" }, // Reserved when RAS is implemented 639 { do_sea, SIGBUS, BUS_FIXME, "level 1 synchronous parity error (translation table walk)" }, // Reserved when RAS is implemented
640 { do_sea, SIGBUS, 0, "level 2 synchronous parity error (translation table walk)" }, // Reserved when RAS is implemented 640 { do_sea, SIGBUS, BUS_FIXME, "level 2 synchronous parity error (translation table walk)" }, // Reserved when RAS is implemented
641 { do_sea, SIGBUS, 0, "level 3 synchronous parity error (translation table walk)" }, // Reserved when RAS is implemented 641 { do_sea, SIGBUS, BUS_FIXME, "level 3 synchronous parity error (translation table walk)" }, // Reserved when RAS is implemented
642 { do_bad, SIGBUS, 0, "unknown 32" }, 642 { do_bad, SIGBUS, BUS_FIXME, "unknown 32" },
643 { do_alignment_fault, SIGBUS, BUS_ADRALN, "alignment fault" }, 643 { do_alignment_fault, SIGBUS, BUS_ADRALN, "alignment fault" },
644 { do_bad, SIGBUS, 0, "unknown 34" }, 644 { do_bad, SIGBUS, BUS_FIXME, "unknown 34" },
645 { do_bad, SIGBUS, 0, "unknown 35" }, 645 { do_bad, SIGBUS, BUS_FIXME, "unknown 35" },
646 { do_bad, SIGBUS, 0, "unknown 36" }, 646 { do_bad, SIGBUS, BUS_FIXME, "unknown 36" },
647 { do_bad, SIGBUS, 0, "unknown 37" }, 647 { do_bad, SIGBUS, BUS_FIXME, "unknown 37" },
648 { do_bad, SIGBUS, 0, "unknown 38" }, 648 { do_bad, SIGBUS, BUS_FIXME, "unknown 38" },
649 { do_bad, SIGBUS, 0, "unknown 39" }, 649 { do_bad, SIGBUS, BUS_FIXME, "unknown 39" },
650 { do_bad, SIGBUS, 0, "unknown 40" }, 650 { do_bad, SIGBUS, BUS_FIXME, "unknown 40" },
651 { do_bad, SIGBUS, 0, "unknown 41" }, 651 { do_bad, SIGBUS, BUS_FIXME, "unknown 41" },
652 { do_bad, SIGBUS, 0, "unknown 42" }, 652 { do_bad, SIGBUS, BUS_FIXME, "unknown 42" },
653 { do_bad, SIGBUS, 0, "unknown 43" }, 653 { do_bad, SIGBUS, BUS_FIXME, "unknown 43" },
654 { do_bad, SIGBUS, 0, "unknown 44" }, 654 { do_bad, SIGBUS, BUS_FIXME, "unknown 44" },
655 { do_bad, SIGBUS, 0, "unknown 45" }, 655 { do_bad, SIGBUS, BUS_FIXME, "unknown 45" },
656 { do_bad, SIGBUS, 0, "unknown 46" }, 656 { do_bad, SIGBUS, BUS_FIXME, "unknown 46" },
657 { do_bad, SIGBUS, 0, "unknown 47" }, 657 { do_bad, SIGBUS, BUS_FIXME, "unknown 47" },
658 { do_bad, SIGBUS, 0, "TLB conflict abort" }, 658 { do_bad, SIGBUS, BUS_FIXME, "TLB conflict abort" },
659 { do_bad, SIGBUS, 0, "Unsupported atomic hardware update fault" }, 659 { do_bad, SIGBUS, BUS_FIXME, "Unsupported atomic hardware update fault" },
660 { do_bad, SIGBUS, 0, "unknown 50" }, 660 { do_bad, SIGBUS, BUS_FIXME, "unknown 50" },
661 { do_bad, SIGBUS, 0, "unknown 51" }, 661 { do_bad, SIGBUS, BUS_FIXME, "unknown 51" },
662 { do_bad, SIGBUS, 0, "implementation fault (lockdown abort)" }, 662 { do_bad, SIGBUS, BUS_FIXME, "implementation fault (lockdown abort)" },
663 { do_bad, SIGBUS, 0, "implementation fault (unsupported exclusive)" }, 663 { do_bad, SIGBUS, BUS_FIXME, "implementation fault (unsupported exclusive)" },
664 { do_bad, SIGBUS, 0, "unknown 54" }, 664 { do_bad, SIGBUS, BUS_FIXME, "unknown 54" },
665 { do_bad, SIGBUS, 0, "unknown 55" }, 665 { do_bad, SIGBUS, BUS_FIXME, "unknown 55" },
666 { do_bad, SIGBUS, 0, "unknown 56" }, 666 { do_bad, SIGBUS, BUS_FIXME, "unknown 56" },
667 { do_bad, SIGBUS, 0, "unknown 57" }, 667 { do_bad, SIGBUS, BUS_FIXME, "unknown 57" },
668 { do_bad, SIGBUS, 0, "unknown 58" }, 668 { do_bad, SIGBUS, BUS_FIXME, "unknown 58" },
669 { do_bad, SIGBUS, 0, "unknown 59" }, 669 { do_bad, SIGBUS, BUS_FIXME, "unknown 59" },
670 { do_bad, SIGBUS, 0, "unknown 60" }, 670 { do_bad, SIGBUS, BUS_FIXME, "unknown 60" },
671 { do_bad, SIGBUS, 0, "section domain fault" }, 671 { do_bad, SIGBUS, BUS_FIXME, "section domain fault" },
672 { do_bad, SIGBUS, 0, "page domain fault" }, 672 { do_bad, SIGBUS, BUS_FIXME, "page domain fault" },
673 { do_bad, SIGBUS, 0, "unknown 63" }, 673 { do_bad, SIGBUS, BUS_FIXME, "unknown 63" },
674}; 674};
675 675
676int handle_guest_sea(phys_addr_t addr, unsigned int esr) 676int handle_guest_sea(phys_addr_t addr, unsigned int esr)
@@ -756,11 +756,11 @@ static struct fault_info __refdata debug_fault_info[] = {
756 { do_bad, SIGTRAP, TRAP_HWBKPT, "hardware breakpoint" }, 756 { do_bad, SIGTRAP, TRAP_HWBKPT, "hardware breakpoint" },
757 { do_bad, SIGTRAP, TRAP_HWBKPT, "hardware single-step" }, 757 { do_bad, SIGTRAP, TRAP_HWBKPT, "hardware single-step" },
758 { do_bad, SIGTRAP, TRAP_HWBKPT, "hardware watchpoint" }, 758 { do_bad, SIGTRAP, TRAP_HWBKPT, "hardware watchpoint" },
759 { do_bad, SIGBUS, 0, "unknown 3" }, 759 { do_bad, SIGBUS, BUS_FIXME, "unknown 3" },
760 { do_bad, SIGTRAP, TRAP_BRKPT, "aarch32 BKPT" }, 760 { do_bad, SIGTRAP, TRAP_BRKPT, "aarch32 BKPT" },
761 { do_bad, SIGTRAP, 0, "aarch32 vector catch" }, 761 { do_bad, SIGTRAP, TRAP_FIXME, "aarch32 vector catch" },
762 { early_brk64, SIGTRAP, TRAP_BRKPT, "aarch64 BRK" }, 762 { early_brk64, SIGTRAP, TRAP_BRKPT, "aarch64 BRK" },
763 { do_bad, SIGBUS, 0, "unknown 7" }, 763 { do_bad, SIGBUS, BUS_FIXME, "unknown 7" },
764}; 764};
765 765
766void __init hook_debug_fault_code(int nr, 766void __init hook_debug_fault_code(int nr,
diff --git a/arch/blackfin/include/uapi/asm/siginfo.h b/arch/blackfin/include/uapi/asm/siginfo.h
index b1db506c8d2e..2dd8c9c39248 100644
--- a/arch/blackfin/include/uapi/asm/siginfo.h
+++ b/arch/blackfin/include/uapi/asm/siginfo.h
@@ -11,40 +11,6 @@
11#include <linux/types.h> 11#include <linux/types.h>
12#include <asm-generic/siginfo.h> 12#include <asm-generic/siginfo.h>
13 13
14#define UID16_SIGINFO_COMPAT_NEEDED
15
16#define si_uid16 _sifields._kill._uid 14#define si_uid16 _sifields._kill._uid
17 15
18#define ILL_ILLPARAOP 2 /* illegal opcode combine ********** */
19#define ILL_ILLEXCPT 4 /* unrecoverable exception ********** */
20#define ILL_CPLB_VI 9 /* D/I CPLB protect violation ******** */
21#define ILL_CPLB_MISS 10 /* D/I CPLB miss ******** */
22#define ILL_CPLB_MULHIT 11 /* D/I CPLB multiple hit ******** */
23#undef NSIGILL
24#define NSIGILL 11
25
26/*
27 * SIGBUS si_codes
28 */
29#define BUS_OPFETCH 4 /* error from instruction fetch ******** */
30#undef NSIGBUS
31#define NSIGBUS 4
32
33/*
34 * SIGTRAP si_codes
35 */
36#define TRAP_STEP 1 /* single-step breakpoint************* */
37#define TRAP_TRACEFLOW 2 /* trace buffer overflow ************* */
38#define TRAP_WATCHPT 3 /* watchpoint match ************* */
39#define TRAP_ILLTRAP 4 /* illegal trap ************* */
40#undef NSIGTRAP
41#define NSIGTRAP 4
42
43/*
44 * SIGSEGV si_codes
45 */
46#define SEGV_STACKFLOW 3 /* stack overflow */
47#undef NSIGSEGV
48#define NSIGSEGV 3
49
50#endif /* _UAPI_BFIN_SIGINFO_H */ 16#endif /* _UAPI_BFIN_SIGINFO_H */
diff --git a/arch/frv/include/uapi/asm/Kbuild b/arch/frv/include/uapi/asm/Kbuild
index 14a2e9af97e9..5354b0f84d41 100644
--- a/arch/frv/include/uapi/asm/Kbuild
+++ b/arch/frv/include/uapi/asm/Kbuild
@@ -1,4 +1,5 @@
1# UAPI Header export list 1# UAPI Header export list
2include include/uapi/asm-generic/Kbuild.asm 2include include/uapi/asm-generic/Kbuild.asm
3 3
4generic-y += siginfo.h
4generic-y += bpf_perf_event.h 5generic-y += bpf_perf_event.h
diff --git a/arch/frv/include/uapi/asm/siginfo.h b/arch/frv/include/uapi/asm/siginfo.h
deleted file mode 100644
index 4c8c975747ac..000000000000
--- a/arch/frv/include/uapi/asm/siginfo.h
+++ /dev/null
@@ -1,13 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2#ifndef _ASM_SIGINFO_H
3#define _ASM_SIGINFO_H
4
5#include <linux/types.h>
6#include <asm-generic/siginfo.h>
7
8#define FPE_MDAOVF 9 /* media overflow */
9#undef NSIGFPE
10#define NSIGFPE 9
11
12#endif
13
diff --git a/arch/ia64/include/uapi/asm/siginfo.h b/arch/ia64/include/uapi/asm/siginfo.h
index f3a02a10c3a3..5aa454ed89db 100644
--- a/arch/ia64/include/uapi/asm/siginfo.h
+++ b/arch/ia64/include/uapi/asm/siginfo.h
@@ -11,77 +11,8 @@
11 11
12#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int)) 12#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
13 13
14#define HAVE_ARCH_SIGINFO_T
15#define HAVE_ARCH_COPY_SIGINFO_TO_USER
16
17#include <asm-generic/siginfo.h> 14#include <asm-generic/siginfo.h>
18 15
19typedef struct siginfo {
20 int si_signo;
21 int si_errno;
22 int si_code;
23 int __pad0;
24
25 union {
26 int _pad[SI_PAD_SIZE];
27
28 /* kill() */
29 struct {
30 pid_t _pid; /* sender's pid */
31 uid_t _uid; /* sender's uid */
32 } _kill;
33
34 /* POSIX.1b timers */
35 struct {
36 timer_t _tid; /* timer id */
37 int _overrun; /* overrun count */
38 char _pad[sizeof(__ARCH_SI_UID_T) - sizeof(int)];
39 sigval_t _sigval; /* must overlay ._rt._sigval! */
40 int _sys_private; /* not to be passed to user */
41 } _timer;
42
43 /* POSIX.1b signals */
44 struct {
45 pid_t _pid; /* sender's pid */
46 uid_t _uid; /* sender's uid */
47 sigval_t _sigval;
48 } _rt;
49
50 /* SIGCHLD */
51 struct {
52 pid_t _pid; /* which child */
53 uid_t _uid; /* sender's uid */
54 int _status; /* exit code */
55 clock_t _utime;
56 clock_t _stime;
57 } _sigchld;
58
59 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
60 struct {
61 void __user *_addr; /* faulting insn/memory ref. */
62 int _imm; /* immediate value for "break" */
63 unsigned int _flags; /* see below */
64 unsigned long _isr; /* isr */
65 short _addr_lsb; /* lsb of faulting address */
66 union {
67 /* used when si_code=SEGV_BNDERR */
68 struct {
69 void __user *_lower;
70 void __user *_upper;
71 } _addr_bnd;
72 /* used when si_code=SEGV_PKUERR */
73 __u32 _pkey;
74 };
75 } _sigfault;
76
77 /* SIGPOLL */
78 struct {
79 long _band; /* POLL_IN, POLL_OUT, POLL_MSG (XPG requires a "long") */
80 int _fd;
81 } _sigpoll;
82 } _sifields;
83} siginfo_t;
84
85#define si_imm _sifields._sigfault._imm /* as per UNIX SysV ABI spec */ 16#define si_imm _sifields._sigfault._imm /* as per UNIX SysV ABI spec */
86#define si_flags _sifields._sigfault._flags 17#define si_flags _sifields._sigfault._flags
87/* 18/*
@@ -97,37 +28,10 @@ typedef struct siginfo {
97#define __ISR_VALID (1 << __ISR_VALID_BIT) 28#define __ISR_VALID (1 << __ISR_VALID_BIT)
98 29
99/* 30/*
100 * SIGILL si_codes
101 */
102#define ILL_BADIADDR 9 /* unimplemented instruction address */
103#define __ILL_BREAK 10 /* illegal break */
104#define __ILL_BNDMOD 11 /* bundle-update (modification) in progress */
105#undef NSIGILL
106#define NSIGILL 11
107
108/*
109 * SIGFPE si_codes 31 * SIGFPE si_codes
110 */ 32 */
111#ifdef __KERNEL__ 33#ifdef __KERNEL__
112#define FPE_FIXME 0 /* Broken dup of SI_USER */ 34#define FPE_FIXME 0 /* Broken dup of SI_USER */
113#endif /* __KERNEL__ */ 35#endif /* __KERNEL__ */
114#define __FPE_DECOVF 9 /* decimal overflow */
115#define __FPE_DECDIV 10 /* decimal division by zero */
116#define __FPE_DECERR 11 /* packed decimal error */
117#define __FPE_INVASC 12 /* invalid ASCII digit */
118#define __FPE_INVDEC 13 /* invalid decimal digit */
119#undef NSIGFPE
120#define NSIGFPE 13
121
122/*
123 * SIGSEGV si_codes
124 */
125#define __SEGV_PSTKOVF 4 /* paragraph stack overflow */
126#undef NSIGSEGV
127#define NSIGSEGV 4
128
129#undef NSIGTRAP
130#define NSIGTRAP 4
131
132 36
133#endif /* _UAPI_ASM_IA64_SIGINFO_H */ 37#endif /* _UAPI_ASM_IA64_SIGINFO_H */
diff --git a/arch/ia64/kernel/signal.c b/arch/ia64/kernel/signal.c
index a254cc98f95c..54547c7cf8a2 100644
--- a/arch/ia64/kernel/signal.c
+++ b/arch/ia64/kernel/signal.c
@@ -105,58 +105,6 @@ restore_sigcontext (struct sigcontext __user *sc, struct sigscratch *scr)
105 return err; 105 return err;
106} 106}
107 107
108int
109copy_siginfo_to_user (siginfo_t __user *to, const siginfo_t *from)
110{
111 if (!access_ok(VERIFY_WRITE, to, sizeof(siginfo_t)))
112 return -EFAULT;
113 if (from->si_code < 0) {
114 if (__copy_to_user(to, from, sizeof(siginfo_t)))
115 return -EFAULT;
116 return 0;
117 } else {
118 int err;
119
120 /*
121 * If you change siginfo_t structure, please be sure this code is fixed
122 * accordingly. It should never copy any pad contained in the structure
123 * to avoid security leaks, but must copy the generic 3 ints plus the
124 * relevant union member.
125 */
126 err = __put_user(from->si_signo, &to->si_signo);
127 err |= __put_user(from->si_errno, &to->si_errno);
128 err |= __put_user(from->si_code, &to->si_code);
129 switch (siginfo_layout(from->si_signo, from->si_code)) {
130 case SIL_FAULT:
131 err |= __put_user(from->si_flags, &to->si_flags);
132 err |= __put_user(from->si_isr, &to->si_isr);
133 case SIL_POLL:
134 err |= __put_user(from->si_addr, &to->si_addr);
135 err |= __put_user(from->si_imm, &to->si_imm);
136 break;
137 case SIL_TIMER:
138 err |= __put_user(from->si_tid, &to->si_tid);
139 err |= __put_user(from->si_overrun, &to->si_overrun);
140 err |= __put_user(from->si_ptr, &to->si_ptr);
141 break;
142 case SIL_RT:
143 err |= __put_user(from->si_uid, &to->si_uid);
144 err |= __put_user(from->si_pid, &to->si_pid);
145 err |= __put_user(from->si_ptr, &to->si_ptr);
146 break;
147 case SIL_CHLD:
148 err |= __put_user(from->si_utime, &to->si_utime);
149 err |= __put_user(from->si_stime, &to->si_stime);
150 err |= __put_user(from->si_status, &to->si_status);
151 case SIL_KILL:
152 err |= __put_user(from->si_uid, &to->si_uid);
153 err |= __put_user(from->si_pid, &to->si_pid);
154 break;
155 }
156 return err;
157 }
158}
159
160long 108long
161ia64_rt_sigreturn (struct sigscratch *scr) 109ia64_rt_sigreturn (struct sigscratch *scr)
162{ 110{
diff --git a/arch/m68k/mm/fault.c b/arch/m68k/mm/fault.c
index 127d7c1f2090..03253c4f8e6a 100644
--- a/arch/m68k/mm/fault.c
+++ b/arch/m68k/mm/fault.c
@@ -21,8 +21,9 @@ extern void die_if_kernel(char *, struct pt_regs *, long);
21 21
22int send_fault_sig(struct pt_regs *regs) 22int send_fault_sig(struct pt_regs *regs)
23{ 23{
24 siginfo_t siginfo = { 0, 0, 0, }; 24 siginfo_t siginfo;
25 25
26 clear_siginfo(&siginfo);
26 siginfo.si_signo = current->thread.signo; 27 siginfo.si_signo = current->thread.signo;
27 siginfo.si_code = current->thread.code; 28 siginfo.si_code = current->thread.code;
28 siginfo.si_addr = (void *)current->thread.faddr; 29 siginfo.si_addr = (void *)current->thread.faddr;
diff --git a/arch/metag/include/uapi/asm/siginfo.h b/arch/metag/include/uapi/asm/siginfo.h
index b54ef7186ca3..9a3f6cde9487 100644
--- a/arch/metag/include/uapi/asm/siginfo.h
+++ b/arch/metag/include/uapi/asm/siginfo.h
@@ -6,4 +6,11 @@
6 6
7#include <asm-generic/siginfo.h> 7#include <asm-generic/siginfo.h>
8 8
9/*
10 * SIGFPE si_codes
11 */
12#ifdef __KERNEL__
13#define FPE_FIXME 0 /* Broken dup of SI_USER */
14#endif /* __KERNEL__ */
15
9#endif 16#endif
diff --git a/arch/metag/kernel/traps.c b/arch/metag/kernel/traps.c
index 444851e510d5..3b62b1b0c0b5 100644
--- a/arch/metag/kernel/traps.c
+++ b/arch/metag/kernel/traps.c
@@ -735,7 +735,7 @@ TBIRES fpe_handler(TBIRES State, int SigNum, int Triggers, int Inst, PTBI pTBI)
735 else if (error_state & TXSTAT_FPE_INEXACT_BIT) 735 else if (error_state & TXSTAT_FPE_INEXACT_BIT)
736 info.si_code = FPE_FLTRES; 736 info.si_code = FPE_FLTRES;
737 else 737 else
738 info.si_code = 0; 738 info.si_code = FPE_FIXME;
739 info.si_errno = 0; 739 info.si_errno = 0;
740 info.si_addr = (__force void __user *)regs->ctx.CurrPC; 740 info.si_addr = (__force void __user *)regs->ctx.CurrPC;
741 force_sig_info(SIGFPE, &info, current); 741 force_sig_info(SIGFPE, &info, current);
diff --git a/arch/mips/include/asm/compat.h b/arch/mips/include/asm/compat.h
index 49691331ada4..946681db8dc3 100644
--- a/arch/mips/include/asm/compat.h
+++ b/arch/mips/include/asm/compat.h
@@ -126,79 +126,6 @@ typedef u32 compat_old_sigset_t; /* at least 32 bits */
126 126
127typedef u32 compat_sigset_word; 127typedef u32 compat_sigset_word;
128 128
129typedef union compat_sigval {
130 compat_int_t sival_int;
131 compat_uptr_t sival_ptr;
132} compat_sigval_t;
133
134/* Can't use the generic version because si_code and si_errno are swapped */
135
136#define SI_PAD_SIZE32 (128/sizeof(int) - 3)
137
138typedef struct compat_siginfo {
139 int si_signo;
140 int si_code;
141 int si_errno;
142
143 union {
144 int _pad[128 / sizeof(int) - 3];
145
146 /* kill() */
147 struct {
148 compat_pid_t _pid; /* sender's pid */
149 __compat_uid32_t _uid; /* sender's uid */
150 } _kill;
151
152 /* POSIX.1b timers */
153 struct {
154 compat_timer_t _tid; /* timer id */
155 int _overrun; /* overrun count */
156 compat_sigval_t _sigval; /* same as below */
157 } _timer;
158
159 /* POSIX.1b signals */
160 struct {
161 compat_pid_t _pid; /* sender's pid */
162 __compat_uid32_t _uid; /* sender's uid */
163 compat_sigval_t _sigval;
164 } _rt;
165
166 /* SIGCHLD */
167 struct {
168 compat_pid_t _pid; /* which child */
169 __compat_uid32_t _uid; /* sender's uid */
170 int _status; /* exit code */
171 compat_clock_t _utime;
172 compat_clock_t _stime;
173 } _sigchld;
174
175 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
176 struct {
177 compat_uptr_t _addr; /* faulting insn/memory ref. */
178#ifdef __ARCH_SI_TRAPNO
179 int _trapno; /* TRAP # which caused the signal */
180#endif
181 short _addr_lsb; /* LSB of the reported address */
182 struct {
183 compat_uptr_t _lower;
184 compat_uptr_t _upper;
185 } _addr_bnd;
186 } _sigfault;
187
188 /* SIGPOLL */
189 struct {
190 compat_long_t _band; /* POLL_IN, POLL_OUT, POLL_MSG */
191 int _fd;
192 } _sigpoll;
193
194 struct {
195 compat_uptr_t _call_addr; /* calling insn */
196 int _syscall; /* triggering system call number */
197 compat_uint_t _arch; /* AUDIT_ARCH_* of syscall */
198 } _sigsys;
199 } _sifields;
200} compat_siginfo_t;
201
202#define COMPAT_OFF_T_MAX 0x7fffffff 129#define COMPAT_OFF_T_MAX 0x7fffffff
203 130
204/* 131/*
diff --git a/arch/mips/include/uapi/asm/siginfo.h b/arch/mips/include/uapi/asm/siginfo.h
index f17d8163dec6..262504bd59a5 100644
--- a/arch/mips/include/uapi/asm/siginfo.h
+++ b/arch/mips/include/uapi/asm/siginfo.h
@@ -14,8 +14,6 @@
14#define __ARCH_SIGEV_PREAMBLE_SIZE (sizeof(long) + 2*sizeof(int)) 14#define __ARCH_SIGEV_PREAMBLE_SIZE (sizeof(long) + 2*sizeof(int))
15#undef __ARCH_SI_TRAPNO /* exception code needs to fill this ... */ 15#undef __ARCH_SI_TRAPNO /* exception code needs to fill this ... */
16 16
17#define HAVE_ARCH_SIGINFO_T
18
19/* 17/*
20 * Careful to keep union _sifields from shifting ... 18 * Careful to keep union _sifields from shifting ...
21 */ 19 */
@@ -27,92 +25,10 @@
27#error _MIPS_SZLONG neither 32 nor 64 25#error _MIPS_SZLONG neither 32 nor 64
28#endif 26#endif
29 27
30#define __ARCH_SIGSYS 28#define __ARCH_HAS_SWAPPED_SIGINFO
31 29
32#include <asm-generic/siginfo.h> 30#include <asm-generic/siginfo.h>
33 31
34/* We can't use generic siginfo_t, because our si_code and si_errno are swapped */
35typedef struct siginfo {
36 int si_signo;
37 int si_code;
38 int si_errno;
39 int __pad0[SI_MAX_SIZE / sizeof(int) - SI_PAD_SIZE - 3];
40
41 union {
42 int _pad[SI_PAD_SIZE];
43
44 /* kill() */
45 struct {
46 __kernel_pid_t _pid; /* sender's pid */
47 __ARCH_SI_UID_T _uid; /* sender's uid */
48 } _kill;
49
50 /* POSIX.1b timers */
51 struct {
52 __kernel_timer_t _tid; /* timer id */
53 int _overrun; /* overrun count */
54 char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)];
55 sigval_t _sigval; /* same as below */
56 int _sys_private; /* not to be passed to user */
57 } _timer;
58
59 /* POSIX.1b signals */
60 struct {
61 __kernel_pid_t _pid; /* sender's pid */
62 __ARCH_SI_UID_T _uid; /* sender's uid */
63 sigval_t _sigval;
64 } _rt;
65
66 /* SIGCHLD */
67 struct {
68 __kernel_pid_t _pid; /* which child */
69 __ARCH_SI_UID_T _uid; /* sender's uid */
70 int _status; /* exit code */
71 __kernel_clock_t _utime;
72 __kernel_clock_t _stime;
73 } _sigchld;
74
75 /* IRIX SIGCHLD */
76 struct {
77 __kernel_pid_t _pid; /* which child */
78 __kernel_clock_t _utime;
79 int _status; /* exit code */
80 __kernel_clock_t _stime;
81 } _irix_sigchld;
82
83 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
84 struct {
85 void __user *_addr; /* faulting insn/memory ref. */
86#ifdef __ARCH_SI_TRAPNO
87 int _trapno; /* TRAP # which caused the signal */
88#endif
89 short _addr_lsb;
90 union {
91 /* used when si_code=SEGV_BNDERR */
92 struct {
93 void __user *_lower;
94 void __user *_upper;
95 } _addr_bnd;
96 /* used when si_code=SEGV_PKUERR */
97 __u32 _pkey;
98 };
99 } _sigfault;
100
101 /* SIGPOLL, SIGXFSZ (To do ...) */
102 struct {
103 __ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */
104 int _fd;
105 } _sigpoll;
106
107 /* SIGSYS */
108 struct {
109 void __user *_call_addr; /* calling user insn */
110 int _syscall; /* triggering system call number */
111 unsigned int _arch; /* AUDIT_ARCH_* of syscall */
112 } _sigsys;
113 } _sifields;
114} siginfo_t;
115
116/* 32/*
117 * si_code values 33 * si_code values
118 * Again these have been chosen to be IRIX compatible. 34 * Again these have been chosen to be IRIX compatible.
diff --git a/arch/mips/kernel/signal32.c b/arch/mips/kernel/signal32.c
index cf5c7c05e5a3..c4db910a8794 100644
--- a/arch/mips/kernel/signal32.c
+++ b/arch/mips/kernel/signal32.c
@@ -76,70 +76,3 @@ SYSCALL_DEFINE3(32_sigaction, long, sig, const struct compat_sigaction __user *,
76 76
77 return ret; 77 return ret;
78} 78}
79
80int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from)
81{
82 int err;
83
84 if (!access_ok (VERIFY_WRITE, to, sizeof(compat_siginfo_t)))
85 return -EFAULT;
86
87 /* If you change siginfo_t structure, please be sure
88 this code is fixed accordingly.
89 It should never copy any pad contained in the structure
90 to avoid security leaks, but must copy the generic
91 3 ints plus the relevant union member.
92 This routine must convert siginfo from 64bit to 32bit as well
93 at the same time. */
94 err = __put_user(from->si_signo, &to->si_signo);
95 err |= __put_user(from->si_errno, &to->si_errno);
96 err |= __put_user(from->si_code, &to->si_code);
97 if (from->si_code < 0)
98 err |= __copy_to_user(&to->_sifields._pad, &from->_sifields._pad, SI_PAD_SIZE);
99 else {
100 switch (siginfo_layout(from->si_signo, from->si_code)) {
101 case SIL_TIMER:
102 err |= __put_user(from->si_tid, &to->si_tid);
103 err |= __put_user(from->si_overrun, &to->si_overrun);
104 err |= __put_user(from->si_int, &to->si_int);
105 break;
106 case SIL_CHLD:
107 err |= __put_user(from->si_utime, &to->si_utime);
108 err |= __put_user(from->si_stime, &to->si_stime);
109 err |= __put_user(from->si_status, &to->si_status);
110 case SIL_KILL:
111 err |= __put_user(from->si_pid, &to->si_pid);
112 err |= __put_user(from->si_uid, &to->si_uid);
113 break;
114 case SIL_FAULT:
115 err |= __put_user((unsigned long)from->si_addr, &to->si_addr);
116 break;
117 case SIL_POLL:
118 err |= __put_user(from->si_band, &to->si_band);
119 err |= __put_user(from->si_fd, &to->si_fd);
120 break;
121 case SIL_RT:
122 err |= __put_user(from->si_pid, &to->si_pid);
123 err |= __put_user(from->si_uid, &to->si_uid);
124 err |= __put_user(from->si_int, &to->si_int);
125 break;
126 case SIL_SYS:
127 err |= __copy_to_user(&to->si_call_addr, &from->si_call_addr,
128 sizeof(compat_uptr_t));
129 err |= __put_user(from->si_syscall, &to->si_syscall);
130 err |= __put_user(from->si_arch, &to->si_arch);
131 break;
132 }
133 }
134 return err;
135}
136
137int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
138{
139 if (copy_from_user(to, from, 3*sizeof(int)) ||
140 copy_from_user(to->_sifields._pad,
141 from->_sifields._pad, SI_PAD_SIZE32))
142 return -EFAULT;
143
144 return 0;
145}
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 5d19ed07e99d..0ae4a731cc12 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -699,11 +699,12 @@ static int simulate_sync(struct pt_regs *regs, unsigned int opcode)
699asmlinkage void do_ov(struct pt_regs *regs) 699asmlinkage void do_ov(struct pt_regs *regs)
700{ 700{
701 enum ctx_state prev_state; 701 enum ctx_state prev_state;
702 siginfo_t info = { 702 siginfo_t info;
703 .si_signo = SIGFPE, 703
704 .si_code = FPE_INTOVF, 704 clear_siginfo(&info);
705 .si_addr = (void __user *)regs->cp0_epc, 705 info.si_signo = SIGFPE;
706 }; 706 info.si_code = FPE_INTOVF;
707 info.si_addr = (void __user *)regs->cp0_epc;
707 708
708 prev_state = exception_enter(); 709 prev_state = exception_enter();
709 die_if_kernel("Integer overflow", regs); 710 die_if_kernel("Integer overflow", regs);
@@ -721,7 +722,11 @@ asmlinkage void do_ov(struct pt_regs *regs)
721void force_fcr31_sig(unsigned long fcr31, void __user *fault_addr, 722void force_fcr31_sig(unsigned long fcr31, void __user *fault_addr,
722 struct task_struct *tsk) 723 struct task_struct *tsk)
723{ 724{
724 struct siginfo si = { .si_addr = fault_addr, .si_signo = SIGFPE }; 725 struct siginfo si;
726
727 clear_siginfo(&si);
728 si.si_addr = fault_addr;
729 si.si_signo = SIGFPE;
725 730
726 if (fcr31 & FPU_CSR_INV_X) 731 if (fcr31 & FPU_CSR_INV_X)
727 si.si_code = FPE_FLTINV; 732 si.si_code = FPE_FLTINV;
@@ -739,9 +744,10 @@ void force_fcr31_sig(unsigned long fcr31, void __user *fault_addr,
739 744
740int process_fpemu_return(int sig, void __user *fault_addr, unsigned long fcr31) 745int process_fpemu_return(int sig, void __user *fault_addr, unsigned long fcr31)
741{ 746{
742 struct siginfo si = { 0 }; 747 struct siginfo si;
743 struct vm_area_struct *vma; 748 struct vm_area_struct *vma;
744 749
750 clear_siginfo(&si);
745 switch (sig) { 751 switch (sig) {
746 case 0: 752 case 0:
747 return 0; 753 return 0;
@@ -890,9 +896,10 @@ out:
890void do_trap_or_bp(struct pt_regs *regs, unsigned int code, int si_code, 896void do_trap_or_bp(struct pt_regs *regs, unsigned int code, int si_code,
891 const char *str) 897 const char *str)
892{ 898{
893 siginfo_t info = { 0 }; 899 siginfo_t info;
894 char b[40]; 900 char b[40];
895 901
902 clear_siginfo(&info);
896#ifdef CONFIG_KGDB_LOW_LEVEL_TRAP 903#ifdef CONFIG_KGDB_LOW_LEVEL_TRAP
897 if (kgdb_ll_trap(DIE_TRAP, str, regs, code, current->thread.trap_nr, 904 if (kgdb_ll_trap(DIE_TRAP, str, regs, code, current->thread.trap_nr,
898 SIGTRAP) == NOTIFY_STOP) 905 SIGTRAP) == NOTIFY_STOP)
@@ -1499,9 +1506,13 @@ asmlinkage void do_mdmx(struct pt_regs *regs)
1499 */ 1506 */
1500asmlinkage void do_watch(struct pt_regs *regs) 1507asmlinkage void do_watch(struct pt_regs *regs)
1501{ 1508{
1502 siginfo_t info = { .si_signo = SIGTRAP, .si_code = TRAP_HWBKPT }; 1509 siginfo_t info;
1503 enum ctx_state prev_state; 1510 enum ctx_state prev_state;
1504 1511
1512 clear_siginfo(&info);
1513 info.si_signo = SIGTRAP;
1514 info.si_code = TRAP_HWBKPT;
1515
1505 prev_state = exception_enter(); 1516 prev_state = exception_enter();
1506 /* 1517 /*
1507 * Clear WP (bit 22) bit of cause register so we don't loop 1518 * Clear WP (bit 22) bit of cause register so we don't loop
diff --git a/arch/mn10300/mm/misalignment.c b/arch/mn10300/mm/misalignment.c
index b39a388825ae..8ace89617c1c 100644
--- a/arch/mn10300/mm/misalignment.c
+++ b/arch/mn10300/mm/misalignment.c
@@ -437,7 +437,7 @@ transfer_failed:
437 437
438 info.si_signo = SIGSEGV; 438 info.si_signo = SIGSEGV;
439 info.si_errno = 0; 439 info.si_errno = 0;
440 info.si_code = 0; 440 info.si_code = SEGV_MAPERR;
441 info.si_addr = (void *) regs->pc; 441 info.si_addr = (void *) regs->pc;
442 force_sig_info(SIGSEGV, &info, current); 442 force_sig_info(SIGSEGV, &info, current);
443 return; 443 return;
diff --git a/arch/openrisc/kernel/traps.c b/arch/openrisc/kernel/traps.c
index 4085d72fa5ae..9e38dc66c9e4 100644
--- a/arch/openrisc/kernel/traps.c
+++ b/arch/openrisc/kernel/traps.c
@@ -266,12 +266,12 @@ asmlinkage void do_unaligned_access(struct pt_regs *regs, unsigned long address)
266 siginfo_t info; 266 siginfo_t info;
267 267
268 if (user_mode(regs)) { 268 if (user_mode(regs)) {
269 /* Send a SIGSEGV */ 269 /* Send a SIGBUS */
270 info.si_signo = SIGSEGV; 270 info.si_signo = SIGBUS;
271 info.si_errno = 0; 271 info.si_errno = 0;
272 /* info.si_code has been set above */ 272 info.si_code = BUS_ADRALN;
273 info.si_addr = (void *)address; 273 info.si_addr = (void __user *)address;
274 force_sig_info(SIGSEGV, &info, current); 274 force_sig_info(SIGBUS, &info, current);
275 } else { 275 } else {
276 printk("KERNEL: Unaligned Access 0x%.8lx\n", address); 276 printk("KERNEL: Unaligned Access 0x%.8lx\n", address);
277 show_registers(regs); 277 show_registers(regs);
diff --git a/arch/parisc/include/asm/compat.h b/arch/parisc/include/asm/compat.h
index acf8aa07cbe0..c22db5323244 100644
--- a/arch/parisc/include/asm/compat.h
+++ b/arch/parisc/include/asm/compat.h
@@ -130,70 +130,6 @@ typedef u32 compat_old_sigset_t; /* at least 32 bits */
130 130
131typedef u32 compat_sigset_word; 131typedef u32 compat_sigset_word;
132 132
133typedef union compat_sigval {
134 compat_int_t sival_int;
135 compat_uptr_t sival_ptr;
136} compat_sigval_t;
137
138typedef struct compat_siginfo {
139 int si_signo;
140 int si_errno;
141 int si_code;
142
143 union {
144 int _pad[128/sizeof(int) - 3];
145
146 /* kill() */
147 struct {
148 unsigned int _pid; /* sender's pid */
149 unsigned int _uid; /* sender's uid */
150 } _kill;
151
152 /* POSIX.1b timers */
153 struct {
154 compat_timer_t _tid; /* timer id */
155 int _overrun; /* overrun count */
156 char _pad[sizeof(unsigned int) - sizeof(int)];
157 compat_sigval_t _sigval; /* same as below */
158 int _sys_private; /* not to be passed to user */
159 } _timer;
160
161 /* POSIX.1b signals */
162 struct {
163 unsigned int _pid; /* sender's pid */
164 unsigned int _uid; /* sender's uid */
165 compat_sigval_t _sigval;
166 } _rt;
167
168 /* SIGCHLD */
169 struct {
170 unsigned int _pid; /* which child */
171 unsigned int _uid; /* sender's uid */
172 int _status; /* exit code */
173 compat_clock_t _utime;
174 compat_clock_t _stime;
175 } _sigchld;
176
177 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
178 struct {
179 unsigned int _addr; /* faulting insn/memory ref. */
180 } _sigfault;
181
182 /* SIGPOLL */
183 struct {
184 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
185 int _fd;
186 } _sigpoll;
187
188 /* SIGSYS */
189 struct {
190 compat_uptr_t _call_addr; /* calling user insn */
191 int _syscall; /* triggering system call number */
192 compat_uint_t _arch; /* AUDIT_ARCH_* of syscall */
193 } _sigsys;
194 } _sifields;
195} compat_siginfo_t;
196
197#define COMPAT_OFF_T_MAX 0x7fffffff 133#define COMPAT_OFF_T_MAX 0x7fffffff
198 134
199struct compat_ipc64_perm { 135struct compat_ipc64_perm {
diff --git a/arch/parisc/include/uapi/asm/siginfo.h b/arch/parisc/include/uapi/asm/siginfo.h
index 4a1062e05aaf..be40331f757d 100644
--- a/arch/parisc/include/uapi/asm/siginfo.h
+++ b/arch/parisc/include/uapi/asm/siginfo.h
@@ -8,4 +8,11 @@
8 8
9#include <asm-generic/siginfo.h> 9#include <asm-generic/siginfo.h>
10 10
11/*
12 * SIGFPE si_codes
13 */
14#ifdef __KERNEL__
15#define FPE_FIXME 0 /* Broken dup of SI_USER */
16#endif /* __KERNEL__ */
17
11#endif 18#endif
diff --git a/arch/parisc/kernel/pdt.c b/arch/parisc/kernel/pdt.c
index e07eb34c8750..36434d4da381 100644
--- a/arch/parisc/kernel/pdt.c
+++ b/arch/parisc/kernel/pdt.c
@@ -325,7 +325,7 @@ static int pdt_mainloop(void *unused)
325#ifdef CONFIG_MEMORY_FAILURE 325#ifdef CONFIG_MEMORY_FAILURE
326 if ((pde & PDT_ADDR_PERM_ERR) || 326 if ((pde & PDT_ADDR_PERM_ERR) ||
327 ((pde & PDT_ADDR_SINGLE_ERR) == 0)) 327 ((pde & PDT_ADDR_SINGLE_ERR) == 0))
328 memory_failure(pde >> PAGE_SHIFT, 0, 0); 328 memory_failure(pde >> PAGE_SHIFT, 0);
329 else 329 else
330 soft_offline_page( 330 soft_offline_page(
331 pfn_to_page(pde >> PAGE_SHIFT), 0); 331 pfn_to_page(pde >> PAGE_SHIFT), 0);
diff --git a/arch/parisc/kernel/signal32.c b/arch/parisc/kernel/signal32.c
index 41afa9cd1f55..e8ef3eb69449 100644
--- a/arch/parisc/kernel/signal32.c
+++ b/arch/parisc/kernel/signal32.c
@@ -260,109 +260,3 @@ setup_sigcontext32(struct compat_sigcontext __user *sc, struct compat_regfile __
260 260
261 return err; 261 return err;
262} 262}
263
264int
265copy_siginfo_from_user32 (siginfo_t *to, compat_siginfo_t __user *from)
266{
267 compat_uptr_t addr;
268 int err;
269
270 if (!access_ok(VERIFY_READ, from, sizeof(compat_siginfo_t)))
271 return -EFAULT;
272
273 err = __get_user(to->si_signo, &from->si_signo);
274 err |= __get_user(to->si_errno, &from->si_errno);
275 err |= __get_user(to->si_code, &from->si_code);
276
277 if (to->si_code < 0)
278 err |= __copy_from_user(&to->_sifields._pad, &from->_sifields._pad, SI_PAD_SIZE);
279 else {
280 switch (siginfo_layout(to->si_signo, to->si_code)) {
281 case SIL_CHLD:
282 err |= __get_user(to->si_utime, &from->si_utime);
283 err |= __get_user(to->si_stime, &from->si_stime);
284 err |= __get_user(to->si_status, &from->si_status);
285 default:
286 case SIL_KILL:
287 err |= __get_user(to->si_pid, &from->si_pid);
288 err |= __get_user(to->si_uid, &from->si_uid);
289 break;
290 case SIL_FAULT:
291 err |= __get_user(addr, &from->si_addr);
292 to->si_addr = compat_ptr(addr);
293 break;
294 case SIL_POLL:
295 err |= __get_user(to->si_band, &from->si_band);
296 err |= __get_user(to->si_fd, &from->si_fd);
297 break;
298 case SIL_RT:
299 err |= __get_user(to->si_pid, &from->si_pid);
300 err |= __get_user(to->si_uid, &from->si_uid);
301 err |= __get_user(to->si_int, &from->si_int);
302 break;
303 }
304 }
305 return err;
306}
307
308int
309copy_siginfo_to_user32 (compat_siginfo_t __user *to, const siginfo_t *from)
310{
311 compat_uptr_t addr;
312 compat_int_t val;
313 int err;
314
315 if (!access_ok(VERIFY_WRITE, to, sizeof(compat_siginfo_t)))
316 return -EFAULT;
317
318 /* If you change siginfo_t structure, please be sure
319 this code is fixed accordingly.
320 It should never copy any pad contained in the structure
321 to avoid security leaks, but must copy the generic
322 3 ints plus the relevant union member.
323 This routine must convert siginfo from 64bit to 32bit as well
324 at the same time. */
325 err = __put_user(from->si_signo, &to->si_signo);
326 err |= __put_user(from->si_errno, &to->si_errno);
327 err |= __put_user(from->si_code, &to->si_code);
328 if (from->si_code < 0)
329 err |= __copy_to_user(&to->_sifields._pad, &from->_sifields._pad, SI_PAD_SIZE);
330 else {
331 switch (siginfo_layout(from->si_signo, from->si_code)) {
332 case SIL_CHLD:
333 err |= __put_user(from->si_utime, &to->si_utime);
334 err |= __put_user(from->si_stime, &to->si_stime);
335 err |= __put_user(from->si_status, &to->si_status);
336 case SIL_KILL:
337 err |= __put_user(from->si_pid, &to->si_pid);
338 err |= __put_user(from->si_uid, &to->si_uid);
339 break;
340 case SIL_FAULT:
341 addr = ptr_to_compat(from->si_addr);
342 err |= __put_user(addr, &to->si_addr);
343 break;
344 case SIL_POLL:
345 err |= __put_user(from->si_band, &to->si_band);
346 err |= __put_user(from->si_fd, &to->si_fd);
347 break;
348 case SIL_TIMER:
349 err |= __put_user(from->si_tid, &to->si_tid);
350 err |= __put_user(from->si_overrun, &to->si_overrun);
351 val = (compat_int_t)from->si_int;
352 err |= __put_user(val, &to->si_int);
353 break;
354 case SIL_RT:
355 err |= __put_user(from->si_uid, &to->si_uid);
356 err |= __put_user(from->si_pid, &to->si_pid);
357 val = (compat_int_t)from->si_int;
358 err |= __put_user(val, &to->si_int);
359 break;
360 case SIL_SYS:
361 err |= __put_user(ptr_to_compat(from->si_call_addr), &to->si_call_addr);
362 err |= __put_user(from->si_syscall, &to->si_syscall);
363 err |= __put_user(from->si_arch, &to->si_arch);
364 break;
365 }
366 }
367 return err;
368}
diff --git a/arch/parisc/kernel/signal32.h b/arch/parisc/kernel/signal32.h
index 719e7417732c..a271dc0976ce 100644
--- a/arch/parisc/kernel/signal32.h
+++ b/arch/parisc/kernel/signal32.h
@@ -34,9 +34,6 @@ struct compat_ucontext {
34 34
35/* ELF32 signal handling */ 35/* ELF32 signal handling */
36 36
37int copy_siginfo_to_user32 (compat_siginfo_t __user *to, const siginfo_t *from);
38int copy_siginfo_from_user32 (siginfo_t *to, compat_siginfo_t __user *from);
39
40/* In a deft move of uber-hackery, we decide to carry the top half of all 37/* In a deft move of uber-hackery, we decide to carry the top half of all
41 * 64-bit registers in a non-portable, non-ABI, hidden structure. 38 * 64-bit registers in a non-portable, non-ABI, hidden structure.
42 * Userspace can read the hidden structure if it *wants* but is never 39 * Userspace can read the hidden structure if it *wants* but is never
diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
index 8453724b8009..c919e6c0a687 100644
--- a/arch/parisc/kernel/traps.c
+++ b/arch/parisc/kernel/traps.c
@@ -629,7 +629,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
629 si.si_signo = SIGFPE; 629 si.si_signo = SIGFPE;
630 /* Set to zero, and let the userspace app figure it out from 630 /* Set to zero, and let the userspace app figure it out from
631 the insn pointed to by si_addr */ 631 the insn pointed to by si_addr */
632 si.si_code = 0; 632 si.si_code = FPE_FIXME;
633 si.si_addr = (void __user *) regs->iaoq[0]; 633 si.si_addr = (void __user *) regs->iaoq[0];
634 force_sig_info(SIGFPE, &si, current); 634 force_sig_info(SIGFPE, &si, current);
635 return; 635 return;
diff --git a/arch/powerpc/include/asm/compat.h b/arch/powerpc/include/asm/compat.h
index 8a2aecfe9b02..62168e1158f1 100644
--- a/arch/powerpc/include/asm/compat.h
+++ b/arch/powerpc/include/asm/compat.h
@@ -119,71 +119,6 @@ typedef u32 compat_old_sigset_t;
119 119
120typedef u32 compat_sigset_word; 120typedef u32 compat_sigset_word;
121 121
122typedef union compat_sigval {
123 compat_int_t sival_int;
124 compat_uptr_t sival_ptr;
125} compat_sigval_t;
126
127#define SI_PAD_SIZE32 (128/sizeof(int) - 3)
128
129typedef struct compat_siginfo {
130 int si_signo;
131 int si_errno;
132 int si_code;
133
134 union {
135 int _pad[SI_PAD_SIZE32];
136
137 /* kill() */
138 struct {
139 compat_pid_t _pid; /* sender's pid */
140 __compat_uid_t _uid; /* sender's uid */
141 } _kill;
142
143 /* POSIX.1b timers */
144 struct {
145 compat_timer_t _tid; /* timer id */
146 int _overrun; /* overrun count */
147 compat_sigval_t _sigval; /* same as below */
148 int _sys_private; /* not to be passed to user */
149 } _timer;
150
151 /* POSIX.1b signals */
152 struct {
153 compat_pid_t _pid; /* sender's pid */
154 __compat_uid_t _uid; /* sender's uid */
155 compat_sigval_t _sigval;
156 } _rt;
157
158 /* SIGCHLD */
159 struct {
160 compat_pid_t _pid; /* which child */
161 __compat_uid_t _uid; /* sender's uid */
162 int _status; /* exit code */
163 compat_clock_t _utime;
164 compat_clock_t _stime;
165 } _sigchld;
166
167 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */
168 struct {
169 unsigned int _addr; /* faulting insn/memory ref. */
170 } _sigfault;
171
172 /* SIGPOLL */
173 struct {
174 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
175 int _fd;
176 } _sigpoll;
177
178 /* SIGSYS */
179 struct {
180 unsigned int _call_addr; /* calling insn */
181 int _syscall; /* triggering system call number */
182 unsigned int _arch; /* AUDIT_ARCH_* of syscall */
183 } _sigsys;
184 } _sifields;
185} compat_siginfo_t;
186
187#define COMPAT_OFF_T_MAX 0x7fffffff 122#define COMPAT_OFF_T_MAX 0x7fffffff
188 123
189/* 124/*
diff --git a/arch/powerpc/include/asm/debug.h b/arch/powerpc/include/asm/debug.h
index 14e71ff6579e..fc97404de0a3 100644
--- a/arch/powerpc/include/asm/debug.h
+++ b/arch/powerpc/include/asm/debug.h
@@ -49,7 +49,7 @@ void set_breakpoint(struct arch_hw_breakpoint *brk);
49void __set_breakpoint(struct arch_hw_breakpoint *brk); 49void __set_breakpoint(struct arch_hw_breakpoint *brk);
50#ifdef CONFIG_PPC_ADV_DEBUG_REGS 50#ifdef CONFIG_PPC_ADV_DEBUG_REGS
51extern void do_send_trap(struct pt_regs *regs, unsigned long address, 51extern void do_send_trap(struct pt_regs *regs, unsigned long address,
52 unsigned long error_code, int signal_code, int brkpt); 52 unsigned long error_code, int brkpt);
53#else 53#else
54 54
55extern void do_break(struct pt_regs *regs, unsigned long address, 55extern void do_break(struct pt_regs *regs, unsigned long address,
diff --git a/arch/powerpc/include/uapi/asm/siginfo.h b/arch/powerpc/include/uapi/asm/siginfo.h
index 1a691141e49f..9f142451a01f 100644
--- a/arch/powerpc/include/uapi/asm/siginfo.h
+++ b/arch/powerpc/include/uapi/asm/siginfo.h
@@ -15,7 +15,19 @@
15 15
16#include <asm-generic/siginfo.h> 16#include <asm-generic/siginfo.h>
17 17
18#undef NSIGTRAP 18/*
19#define NSIGTRAP 4 19 * SIGFPE si_codes
20 */
21#ifdef __KERNEL__
22#define FPE_FIXME 0 /* Broken dup of SI_USER */
23#endif /* __KERNEL__ */
24
25/*
26 * SIGTRAP si_codes
27 */
28#ifdef __KERNEL__
29#define TRAP_FIXME 0 /* Broken dup of SI_USER */
30#endif /* __KERNEL__ */
31
20 32
21#endif /* _ASM_POWERPC_SIGINFO_H */ 33#endif /* _ASM_POWERPC_SIGINFO_H */
diff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c
index 742e4658c5dc..71e8a1b8c86e 100644
--- a/arch/powerpc/kernel/mce.c
+++ b/arch/powerpc/kernel/mce.c
@@ -273,7 +273,7 @@ static void machine_process_ue_event(struct work_struct *work)
273 273
274 pfn = evt->u.ue_error.physical_address >> 274 pfn = evt->u.ue_error.physical_address >>
275 PAGE_SHIFT; 275 PAGE_SHIFT;
276 memory_failure(pfn, SIGBUS, 0); 276 memory_failure(pfn, 0);
277 } else 277 } else
278 pr_warn("Failed to identify bad address from " 278 pr_warn("Failed to identify bad address from "
279 "where the uncorrectable error (UE) " 279 "where the uncorrectable error (UE) "
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 72be0c32e902..4208cbe2fb7f 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -601,21 +601,16 @@ EXPORT_SYMBOL(flush_all_to_thread);
601 601
602#ifdef CONFIG_PPC_ADV_DEBUG_REGS 602#ifdef CONFIG_PPC_ADV_DEBUG_REGS
603void do_send_trap(struct pt_regs *regs, unsigned long address, 603void do_send_trap(struct pt_regs *regs, unsigned long address,
604 unsigned long error_code, int signal_code, int breakpt) 604 unsigned long error_code, int breakpt)
605{ 605{
606 siginfo_t info; 606 current->thread.trap_nr = TRAP_HWBKPT;
607
608 current->thread.trap_nr = signal_code;
609 if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code, 607 if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code,
610 11, SIGSEGV) == NOTIFY_STOP) 608 11, SIGSEGV) == NOTIFY_STOP)
611 return; 609 return;
612 610
613 /* Deliver the signal to userspace */ 611 /* Deliver the signal to userspace */
614 info.si_signo = SIGTRAP; 612 force_sig_ptrace_errno_trap(breakpt, /* breakpoint or watchpoint id */
615 info.si_errno = breakpt; /* breakpoint or watchpoint id */ 613 (void __user *)address);
616 info.si_code = signal_code;
617 info.si_addr = (void __user *)address;
618 force_sig_info(SIGTRAP, &info, current);
619} 614}
620#else /* !CONFIG_PPC_ADV_DEBUG_REGS */ 615#else /* !CONFIG_PPC_ADV_DEBUG_REGS */
621void do_break (struct pt_regs *regs, unsigned long address, 616void do_break (struct pt_regs *regs, unsigned long address,
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index 9ffd73296f64..aded81169648 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -873,75 +873,9 @@ static long restore_tm_user_regs(struct pt_regs *regs,
873#endif 873#endif
874 874
875#ifdef CONFIG_PPC64 875#ifdef CONFIG_PPC64
876int copy_siginfo_to_user32(struct compat_siginfo __user *d, const siginfo_t *s)
877{
878 int err;
879
880 if (!access_ok (VERIFY_WRITE, d, sizeof(*d)))
881 return -EFAULT;
882
883 /* If you change siginfo_t structure, please be sure
884 * this code is fixed accordingly.
885 * It should never copy any pad contained in the structure
886 * to avoid security leaks, but must copy the generic
887 * 3 ints plus the relevant union member.
888 * This routine must convert siginfo from 64bit to 32bit as well
889 * at the same time.
890 */
891 err = __put_user(s->si_signo, &d->si_signo);
892 err |= __put_user(s->si_errno, &d->si_errno);
893 err |= __put_user(s->si_code, &d->si_code);
894 if (s->si_code < 0)
895 err |= __copy_to_user(&d->_sifields._pad, &s->_sifields._pad,
896 SI_PAD_SIZE32);
897 else switch(siginfo_layout(s->si_signo, s->si_code)) {
898 case SIL_CHLD:
899 err |= __put_user(s->si_pid, &d->si_pid);
900 err |= __put_user(s->si_uid, &d->si_uid);
901 err |= __put_user(s->si_utime, &d->si_utime);
902 err |= __put_user(s->si_stime, &d->si_stime);
903 err |= __put_user(s->si_status, &d->si_status);
904 break;
905 case SIL_FAULT:
906 err |= __put_user((unsigned int)(unsigned long)s->si_addr,
907 &d->si_addr);
908 break;
909 case SIL_POLL:
910 err |= __put_user(s->si_band, &d->si_band);
911 err |= __put_user(s->si_fd, &d->si_fd);
912 break;
913 case SIL_TIMER:
914 err |= __put_user(s->si_tid, &d->si_tid);
915 err |= __put_user(s->si_overrun, &d->si_overrun);
916 err |= __put_user(s->si_int, &d->si_int);
917 break;
918 case SIL_SYS:
919 err |= __put_user(ptr_to_compat(s->si_call_addr), &d->si_call_addr);
920 err |= __put_user(s->si_syscall, &d->si_syscall);
921 err |= __put_user(s->si_arch, &d->si_arch);
922 break;
923 case SIL_RT:
924 err |= __put_user(s->si_int, &d->si_int);
925 /* fallthrough */
926 case SIL_KILL:
927 err |= __put_user(s->si_pid, &d->si_pid);
928 err |= __put_user(s->si_uid, &d->si_uid);
929 break;
930 }
931 return err;
932}
933 876
934#define copy_siginfo_to_user copy_siginfo_to_user32 877#define copy_siginfo_to_user copy_siginfo_to_user32
935 878
936int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from)
937{
938 if (copy_from_user(to, from, 3*sizeof(int)) ||
939 copy_from_user(to->_sifields._pad,
940 from->_sifields._pad, SI_PAD_SIZE32))
941 return -EFAULT;
942
943 return 0;
944}
945#endif /* CONFIG_PPC64 */ 879#endif /* CONFIG_PPC64 */
946 880
947/* 881/*
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index f3eb61be0d30..c93f1e6a9fff 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -917,7 +917,7 @@ void unknown_exception(struct pt_regs *regs)
917 printk("Bad trap at PC: %lx, SR: %lx, vector=%lx\n", 917 printk("Bad trap at PC: %lx, SR: %lx, vector=%lx\n",
918 regs->nip, regs->msr, regs->trap); 918 regs->nip, regs->msr, regs->trap);
919 919
920 _exception(SIGTRAP, regs, 0, 0); 920 _exception(SIGTRAP, regs, TRAP_FIXME, 0);
921 921
922 exception_exit(prev_state); 922 exception_exit(prev_state);
923} 923}
@@ -939,7 +939,7 @@ bail:
939 939
940void RunModeException(struct pt_regs *regs) 940void RunModeException(struct pt_regs *regs)
941{ 941{
942 _exception(SIGTRAP, regs, 0, 0); 942 _exception(SIGTRAP, regs, TRAP_FIXME, 0);
943} 943}
944 944
945void single_step_exception(struct pt_regs *regs) 945void single_step_exception(struct pt_regs *regs)
@@ -978,7 +978,7 @@ static void emulate_single_step(struct pt_regs *regs)
978 978
979static inline int __parse_fpscr(unsigned long fpscr) 979static inline int __parse_fpscr(unsigned long fpscr)
980{ 980{
981 int ret = 0; 981 int ret = FPE_FIXME;
982 982
983 /* Invalid operation */ 983 /* Invalid operation */
984 if ((fpscr & FPSCR_VE) && (fpscr & FPSCR_VX)) 984 if ((fpscr & FPSCR_VE) && (fpscr & FPSCR_VX))
@@ -1750,34 +1750,34 @@ static void handle_debug(struct pt_regs *regs, unsigned long debug_status)
1750#ifdef CONFIG_PPC_ADV_DEBUG_DAC_RANGE 1750#ifdef CONFIG_PPC_ADV_DEBUG_DAC_RANGE
1751 current->thread.debug.dbcr2 &= ~DBCR2_DAC12MODE; 1751 current->thread.debug.dbcr2 &= ~DBCR2_DAC12MODE;
1752#endif 1752#endif
1753 do_send_trap(regs, mfspr(SPRN_DAC1), debug_status, TRAP_HWBKPT, 1753 do_send_trap(regs, mfspr(SPRN_DAC1), debug_status,
1754 5); 1754 5);
1755 changed |= 0x01; 1755 changed |= 0x01;
1756 } else if (debug_status & (DBSR_DAC2R | DBSR_DAC2W)) { 1756 } else if (debug_status & (DBSR_DAC2R | DBSR_DAC2W)) {
1757 dbcr_dac(current) &= ~(DBCR_DAC2R | DBCR_DAC2W); 1757 dbcr_dac(current) &= ~(DBCR_DAC2R | DBCR_DAC2W);
1758 do_send_trap(regs, mfspr(SPRN_DAC2), debug_status, TRAP_HWBKPT, 1758 do_send_trap(regs, mfspr(SPRN_DAC2), debug_status,
1759 6); 1759 6);
1760 changed |= 0x01; 1760 changed |= 0x01;
1761 } else if (debug_status & DBSR_IAC1) { 1761 } else if (debug_status & DBSR_IAC1) {
1762 current->thread.debug.dbcr0 &= ~DBCR0_IAC1; 1762 current->thread.debug.dbcr0 &= ~DBCR0_IAC1;
1763 dbcr_iac_range(current) &= ~DBCR_IAC12MODE; 1763 dbcr_iac_range(current) &= ~DBCR_IAC12MODE;
1764 do_send_trap(regs, mfspr(SPRN_IAC1), debug_status, TRAP_HWBKPT, 1764 do_send_trap(regs, mfspr(SPRN_IAC1), debug_status,
1765 1); 1765 1);
1766 changed |= 0x01; 1766 changed |= 0x01;
1767 } else if (debug_status & DBSR_IAC2) { 1767 } else if (debug_status & DBSR_IAC2) {
1768 current->thread.debug.dbcr0 &= ~DBCR0_IAC2; 1768 current->thread.debug.dbcr0 &= ~DBCR0_IAC2;
1769 do_send_trap(regs, mfspr(SPRN_IAC2), debug_status, TRAP_HWBKPT, 1769 do_send_trap(regs, mfspr(SPRN_IAC2), debug_status,
1770 2); 1770 2);
1771 changed |= 0x01; 1771 changed |= 0x01;
1772 } else if (debug_status & DBSR_IAC3) { 1772 } else if (debug_status & DBSR_IAC3) {
1773 current->thread.debug.dbcr0 &= ~DBCR0_IAC3; 1773 current->thread.debug.dbcr0 &= ~DBCR0_IAC3;
1774 dbcr_iac_range(current) &= ~DBCR_IAC34MODE; 1774 dbcr_iac_range(current) &= ~DBCR_IAC34MODE;
1775 do_send_trap(regs, mfspr(SPRN_IAC3), debug_status, TRAP_HWBKPT, 1775 do_send_trap(regs, mfspr(SPRN_IAC3), debug_status,
1776 3); 1776 3);
1777 changed |= 0x01; 1777 changed |= 0x01;
1778 } else if (debug_status & DBSR_IAC4) { 1778 } else if (debug_status & DBSR_IAC4) {
1779 current->thread.debug.dbcr0 &= ~DBCR0_IAC4; 1779 current->thread.debug.dbcr0 &= ~DBCR0_IAC4;
1780 do_send_trap(regs, mfspr(SPRN_IAC4), debug_status, TRAP_HWBKPT, 1780 do_send_trap(regs, mfspr(SPRN_IAC4), debug_status,
1781 4); 1781 4);
1782 changed |= 0x01; 1782 changed |= 0x01;
1783 } 1783 }
@@ -1929,7 +1929,7 @@ void SPEFloatingPointException(struct pt_regs *regs)
1929 extern int do_spe_mathemu(struct pt_regs *regs); 1929 extern int do_spe_mathemu(struct pt_regs *regs);
1930 unsigned long spefscr; 1930 unsigned long spefscr;
1931 int fpexc_mode; 1931 int fpexc_mode;
1932 int code = 0; 1932 int code = FPE_FIXME;
1933 int err; 1933 int err;
1934 1934
1935 flush_spe_to_thread(current); 1935 flush_spe_to_thread(current);
@@ -1998,7 +1998,7 @@ void SPEFloatingPointRoundException(struct pt_regs *regs)
1998 printk(KERN_ERR "unrecognized spe instruction " 1998 printk(KERN_ERR "unrecognized spe instruction "
1999 "in %s at %lx\n", current->comm, regs->nip); 1999 "in %s at %lx\n", current->comm, regs->nip);
2000 } else { 2000 } else {
2001 _exception(SIGFPE, regs, 0, regs->nip); 2001 _exception(SIGFPE, regs, FPE_FIXME, regs->nip);
2002 return; 2002 return;
2003 } 2003 }
2004} 2004}
diff --git a/arch/powerpc/platforms/powernv/opal-memory-errors.c b/arch/powerpc/platforms/powernv/opal-memory-errors.c
index d9916ea62305..8ddc1accf199 100644
--- a/arch/powerpc/platforms/powernv/opal-memory-errors.c
+++ b/arch/powerpc/platforms/powernv/opal-memory-errors.c
@@ -60,7 +60,7 @@ static void handle_memory_error_event(struct OpalMemoryErrorData *merr_evt)
60 } 60 }
61 61
62 for (; paddr_start < paddr_end; paddr_start += PAGE_SIZE) { 62 for (; paddr_start < paddr_end; paddr_start += PAGE_SIZE) {
63 memory_failure(paddr_start >> PAGE_SHIFT, 0, 0); 63 memory_failure(paddr_start >> PAGE_SHIFT, 0);
64 } 64 }
65} 65}
66 66
diff --git a/arch/s390/include/asm/compat.h b/arch/s390/include/asm/compat.h
index 5e6a63641a5f..9830fb6b076e 100644
--- a/arch/s390/include/asm/compat.h
+++ b/arch/s390/include/asm/compat.h
@@ -189,79 +189,6 @@ typedef u32 compat_old_sigset_t; /* at least 32 bits */
189 189
190typedef u32 compat_sigset_word; 190typedef u32 compat_sigset_word;
191 191
192typedef union compat_sigval {
193 compat_int_t sival_int;
194 compat_uptr_t sival_ptr;
195} compat_sigval_t;
196
197typedef struct compat_siginfo {
198 int si_signo;
199 int si_errno;
200 int si_code;
201
202 union {
203 int _pad[128/sizeof(int) - 3];
204
205 /* kill() */
206 struct {
207 pid_t _pid; /* sender's pid */
208 uid_t _uid; /* sender's uid */
209 } _kill;
210
211 /* POSIX.1b timers */
212 struct {
213 compat_timer_t _tid; /* timer id */
214 int _overrun; /* overrun count */
215 compat_sigval_t _sigval; /* same as below */
216 int _sys_private; /* not to be passed to user */
217 } _timer;
218
219 /* POSIX.1b signals */
220 struct {
221 pid_t _pid; /* sender's pid */
222 uid_t _uid; /* sender's uid */
223 compat_sigval_t _sigval;
224 } _rt;
225
226 /* SIGCHLD */
227 struct {
228 pid_t _pid; /* which child */
229 uid_t _uid; /* sender's uid */
230 int _status;/* exit code */
231 compat_clock_t _utime;
232 compat_clock_t _stime;
233 } _sigchld;
234
235 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
236 struct {
237 __u32 _addr; /* faulting insn/memory ref. - pointer */
238 } _sigfault;
239
240 /* SIGPOLL */
241 struct {
242 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
243 int _fd;
244 } _sigpoll;
245 } _sifields;
246} compat_siginfo_t;
247
248/*
249 * How these fields are to be accessed.
250 */
251#define si_pid _sifields._kill._pid
252#define si_uid _sifields._kill._uid
253#define si_status _sifields._sigchld._status
254#define si_utime _sifields._sigchld._utime
255#define si_stime _sifields._sigchld._stime
256#define si_value _sifields._rt._sigval
257#define si_int _sifields._rt._sigval.sival_int
258#define si_ptr _sifields._rt._sigval.sival_ptr
259#define si_addr _sifields._sigfault._addr
260#define si_band _sifields._sigpoll._band
261#define si_fd _sifields._sigpoll._fd
262#define si_tid _sifields._timer._tid
263#define si_overrun _sifields._timer._overrun
264
265#define COMPAT_OFF_T_MAX 0x7fffffff 192#define COMPAT_OFF_T_MAX 0x7fffffff
266 193
267/* 194/*
diff --git a/arch/s390/kernel/compat_signal.c b/arch/s390/kernel/compat_signal.c
index ef246940b44c..18c1eeb847b2 100644
--- a/arch/s390/kernel/compat_signal.c
+++ b/arch/s390/kernel/compat_signal.c
@@ -50,106 +50,6 @@ typedef struct
50 struct ucontext32 uc; 50 struct ucontext32 uc;
51} rt_sigframe32; 51} rt_sigframe32;
52 52
53int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from)
54{
55 int err;
56
57 /* If you change siginfo_t structure, please be sure
58 this code is fixed accordingly.
59 It should never copy any pad contained in the structure
60 to avoid security leaks, but must copy the generic
61 3 ints plus the relevant union member.
62 This routine must convert siginfo from 64bit to 32bit as well
63 at the same time. */
64 err = __put_user(from->si_signo, &to->si_signo);
65 err |= __put_user(from->si_errno, &to->si_errno);
66 err |= __put_user(from->si_code, &to->si_code);
67 if (from->si_code < 0)
68 err |= __copy_to_user(&to->_sifields._pad, &from->_sifields._pad, SI_PAD_SIZE);
69 else {
70 switch (siginfo_layout(from->si_signo, from->si_code)) {
71 case SIL_RT:
72 err |= __put_user(from->si_int, &to->si_int);
73 /* fallthrough */
74 case SIL_KILL:
75 err |= __put_user(from->si_pid, &to->si_pid);
76 err |= __put_user(from->si_uid, &to->si_uid);
77 break;
78 case SIL_CHLD:
79 err |= __put_user(from->si_pid, &to->si_pid);
80 err |= __put_user(from->si_uid, &to->si_uid);
81 err |= __put_user(from->si_utime, &to->si_utime);
82 err |= __put_user(from->si_stime, &to->si_stime);
83 err |= __put_user(from->si_status, &to->si_status);
84 break;
85 case SIL_FAULT:
86 err |= __put_user((unsigned long) from->si_addr,
87 &to->si_addr);
88 break;
89 case SIL_POLL:
90 err |= __put_user(from->si_band, &to->si_band);
91 err |= __put_user(from->si_fd, &to->si_fd);
92 break;
93 case SIL_TIMER:
94 err |= __put_user(from->si_tid, &to->si_tid);
95 err |= __put_user(from->si_overrun, &to->si_overrun);
96 err |= __put_user(from->si_int, &to->si_int);
97 break;
98 default:
99 break;
100 }
101 }
102 return err ? -EFAULT : 0;
103}
104
105int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
106{
107 int err;
108 u32 tmp;
109
110 err = __get_user(to->si_signo, &from->si_signo);
111 err |= __get_user(to->si_errno, &from->si_errno);
112 err |= __get_user(to->si_code, &from->si_code);
113
114 if (to->si_code < 0)
115 err |= __copy_from_user(&to->_sifields._pad, &from->_sifields._pad, SI_PAD_SIZE);
116 else {
117 switch (siginfo_layout(to->si_signo, to->si_code)) {
118 case SIL_RT:
119 err |= __get_user(to->si_int, &from->si_int);
120 /* fallthrough */
121 case SIL_KILL:
122 err |= __get_user(to->si_pid, &from->si_pid);
123 err |= __get_user(to->si_uid, &from->si_uid);
124 break;
125 case SIL_CHLD:
126 err |= __get_user(to->si_pid, &from->si_pid);
127 err |= __get_user(to->si_uid, &from->si_uid);
128 err |= __get_user(to->si_utime, &from->si_utime);
129 err |= __get_user(to->si_stime, &from->si_stime);
130 err |= __get_user(to->si_status, &from->si_status);
131 break;
132 case SIL_FAULT:
133 err |= __get_user(tmp, &from->si_addr);
134 to->si_addr = (void __force __user *)
135 (u64) (tmp & PSW32_ADDR_INSN);
136 break;
137 case SIL_POLL:
138 err |= __get_user(to->si_band, &from->si_band);
139 err |= __get_user(to->si_fd, &from->si_fd);
140 break;
141 case SIL_TIMER:
142 err |= __get_user(to->si_tid, &from->si_tid);
143 err |= __get_user(to->si_overrun, &from->si_overrun);
144 err |= __get_user(to->si_int, &from->si_int);
145 break;
146 default:
147 break;
148 }
149 }
150 return err ? -EFAULT : 0;
151}
152
153/* Store registers needed to create the signal frame */ 53/* Store registers needed to create the signal frame */
154static void store_sigregs(void) 54static void store_sigregs(void)
155{ 55{
diff --git a/arch/sh/kernel/traps_32.c b/arch/sh/kernel/traps_32.c
index 57cff00cad17..b3770bb26211 100644
--- a/arch/sh/kernel/traps_32.c
+++ b/arch/sh/kernel/traps_32.c
@@ -609,7 +609,8 @@ asmlinkage void do_divide_error(unsigned long r4)
609 break; 609 break;
610 } 610 }
611 611
612 force_sig_info(SIGFPE, &info, current); 612 info.si_signo = SIGFPE;
613 force_sig_info(info.si_signo, &info, current);
613} 614}
614#endif 615#endif
615 616
diff --git a/arch/sparc/include/asm/compat.h b/arch/sparc/include/asm/compat.h
index fa38c78de0f0..615283e16f22 100644
--- a/arch/sparc/include/asm/compat.h
+++ b/arch/sparc/include/asm/compat.h
@@ -149,65 +149,6 @@ typedef u32 compat_old_sigset_t;
149 149
150typedef u32 compat_sigset_word; 150typedef u32 compat_sigset_word;
151 151
152typedef union compat_sigval {
153 compat_int_t sival_int;
154 compat_uptr_t sival_ptr;
155} compat_sigval_t;
156
157#define SI_PAD_SIZE32 (128/sizeof(int) - 3)
158
159typedef struct compat_siginfo {
160 int si_signo;
161 int si_errno;
162 int si_code;
163
164 union {
165 int _pad[SI_PAD_SIZE32];
166
167 /* kill() */
168 struct {
169 compat_pid_t _pid; /* sender's pid */
170 unsigned int _uid; /* sender's uid */
171 } _kill;
172
173 /* POSIX.1b timers */
174 struct {
175 compat_timer_t _tid; /* timer id */
176 int _overrun; /* overrun count */
177 compat_sigval_t _sigval; /* same as below */
178 int _sys_private; /* not to be passed to user */
179 } _timer;
180
181 /* POSIX.1b signals */
182 struct {
183 compat_pid_t _pid; /* sender's pid */
184 unsigned int _uid; /* sender's uid */
185 compat_sigval_t _sigval;
186 } _rt;
187
188 /* SIGCHLD */
189 struct {
190 compat_pid_t _pid; /* which child */
191 unsigned int _uid; /* sender's uid */
192 int _status; /* exit code */
193 compat_clock_t _utime;
194 compat_clock_t _stime;
195 } _sigchld;
196
197 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */
198 struct {
199 u32 _addr; /* faulting insn/memory ref. */
200 int _trapno;
201 } _sigfault;
202
203 /* SIGPOLL */
204 struct {
205 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
206 int _fd;
207 } _sigpoll;
208 } _sifields;
209} compat_siginfo_t;
210
211#define COMPAT_OFF_T_MAX 0x7fffffff 152#define COMPAT_OFF_T_MAX 0x7fffffff
212 153
213/* 154/*
diff --git a/arch/sparc/kernel/signal32.c b/arch/sparc/kernel/signal32.c
index 54a6159b9cd8..44d379db3f64 100644
--- a/arch/sparc/kernel/signal32.c
+++ b/arch/sparc/kernel/signal32.c
@@ -70,75 +70,6 @@ struct rt_signal_frame32 {
70 /* __siginfo_rwin_t * */u32 rwin_save; 70 /* __siginfo_rwin_t * */u32 rwin_save;
71} __attribute__((aligned(8))); 71} __attribute__((aligned(8)));
72 72
73int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from)
74{
75 int err;
76
77 if (!access_ok(VERIFY_WRITE, to, sizeof(compat_siginfo_t)))
78 return -EFAULT;
79
80 /* If you change siginfo_t structure, please be sure
81 this code is fixed accordingly.
82 It should never copy any pad contained in the structure
83 to avoid security leaks, but must copy the generic
84 3 ints plus the relevant union member.
85 This routine must convert siginfo from 64bit to 32bit as well
86 at the same time. */
87 err = __put_user(from->si_signo, &to->si_signo);
88 err |= __put_user(from->si_errno, &to->si_errno);
89 err |= __put_user(from->si_code, &to->si_code);
90 if (from->si_code < 0)
91 err |= __copy_to_user(&to->_sifields._pad, &from->_sifields._pad, SI_PAD_SIZE);
92 else {
93 switch (siginfo_layout(from->si_signo, from->si_code)) {
94 case SIL_TIMER:
95 err |= __put_user(from->si_tid, &to->si_tid);
96 err |= __put_user(from->si_overrun, &to->si_overrun);
97 err |= __put_user(from->si_int, &to->si_int);
98 break;
99 case SIL_CHLD:
100 err |= __put_user(from->si_utime, &to->si_utime);
101 err |= __put_user(from->si_stime, &to->si_stime);
102 err |= __put_user(from->si_status, &to->si_status);
103 default:
104 case SIL_KILL:
105 err |= __put_user(from->si_pid, &to->si_pid);
106 err |= __put_user(from->si_uid, &to->si_uid);
107 break;
108 case SIL_FAULT:
109 err |= __put_user(from->si_trapno, &to->si_trapno);
110 err |= __put_user((unsigned long)from->si_addr, &to->si_addr);
111 break;
112 case SIL_POLL:
113 err |= __put_user(from->si_band, &to->si_band);
114 err |= __put_user(from->si_fd, &to->si_fd);
115 break;
116 case SIL_RT:
117 err |= __put_user(from->si_pid, &to->si_pid);
118 err |= __put_user(from->si_uid, &to->si_uid);
119 err |= __put_user(from->si_int, &to->si_int);
120 break;
121 }
122 }
123 return err;
124}
125
126/* CAUTION: This is just a very minimalist implementation for the
127 * sake of compat_sys_rt_sigqueueinfo()
128 */
129int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
130{
131 if (!access_ok(VERIFY_WRITE, from, sizeof(compat_siginfo_t)))
132 return -EFAULT;
133
134 if (copy_from_user(to, from, 3*sizeof(int)) ||
135 copy_from_user(to->_sifields._pad, from->_sifields._pad,
136 SI_PAD_SIZE))
137 return -EFAULT;
138
139 return 0;
140}
141
142/* Checks if the fp is valid. We always build signal frames which are 73/* Checks if the fp is valid. We always build signal frames which are
143 * 16-byte aligned, therefore we can always enforce that the restore 74 * 16-byte aligned, therefore we can always enforce that the restore
144 * frame has that property as well. 75 * frame has that property as well.
diff --git a/arch/tile/include/asm/compat.h b/arch/tile/include/asm/compat.h
index 62a7b83025dd..769ff6ac0bf5 100644
--- a/arch/tile/include/asm/compat.h
+++ b/arch/tile/include/asm/compat.h
@@ -110,68 +110,6 @@ struct compat_flock64 {
110 110
111typedef u32 compat_sigset_word; 111typedef u32 compat_sigset_word;
112 112
113typedef union compat_sigval {
114 compat_int_t sival_int;
115 compat_uptr_t sival_ptr;
116} compat_sigval_t;
117
118#define COMPAT_SI_PAD_SIZE (128/sizeof(int) - 3)
119
120typedef struct compat_siginfo {
121 int si_signo;
122 int si_errno;
123 int si_code;
124
125 union {
126 int _pad[COMPAT_SI_PAD_SIZE];
127
128 /* kill() */
129 struct {
130 unsigned int _pid; /* sender's pid */
131 unsigned int _uid; /* sender's uid */
132 } _kill;
133
134 /* POSIX.1b timers */
135 struct {
136 compat_timer_t _tid; /* timer id */
137 int _overrun; /* overrun count */
138 compat_sigval_t _sigval; /* same as below */
139 int _sys_private; /* not to be passed to user */
140 int _overrun_incr; /* amount to add to overrun */
141 } _timer;
142
143 /* POSIX.1b signals */
144 struct {
145 unsigned int _pid; /* sender's pid */
146 unsigned int _uid; /* sender's uid */
147 compat_sigval_t _sigval;
148 } _rt;
149
150 /* SIGCHLD */
151 struct {
152 unsigned int _pid; /* which child */
153 unsigned int _uid; /* sender's uid */
154 int _status; /* exit code */
155 compat_clock_t _utime;
156 compat_clock_t _stime;
157 } _sigchld;
158
159 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
160 struct {
161 unsigned int _addr; /* faulting insn/memory ref. */
162#ifdef __ARCH_SI_TRAPNO
163 int _trapno; /* TRAP # which caused the signal */
164#endif
165 } _sigfault;
166
167 /* SIGPOLL */
168 struct {
169 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
170 int _fd;
171 } _sigpoll;
172 } _sifields;
173} compat_siginfo_t;
174
175#define COMPAT_OFF_T_MAX 0x7fffffff 113#define COMPAT_OFF_T_MAX 0x7fffffff
176 114
177struct compat_ipc64_perm { 115struct compat_ipc64_perm {
diff --git a/arch/tile/include/uapi/asm/siginfo.h b/arch/tile/include/uapi/asm/siginfo.h
index f234d24fff55..a812fcbf4267 100644
--- a/arch/tile/include/uapi/asm/siginfo.h
+++ b/arch/tile/include/uapi/asm/siginfo.h
@@ -24,12 +24,4 @@
24 24
25#include <asm-generic/siginfo.h> 25#include <asm-generic/siginfo.h>
26 26
27/*
28 * Additional Tile-specific SIGILL si_codes
29 */
30#define ILL_DBLFLT 9 /* double fault */
31#define ILL_HARDWALL 10 /* user networks hardwall violation */
32#undef NSIGILL
33#define NSIGILL 10
34
35#endif /* _ASM_TILE_SIGINFO_H */ 27#endif /* _ASM_TILE_SIGINFO_H */
diff --git a/arch/tile/kernel/compat_signal.c b/arch/tile/kernel/compat_signal.c
index 971d87a1d8cf..a703bd0e0488 100644
--- a/arch/tile/kernel/compat_signal.c
+++ b/arch/tile/kernel/compat_signal.c
@@ -50,79 +50,6 @@ struct compat_rt_sigframe {
50 struct compat_ucontext uc; 50 struct compat_ucontext uc;
51}; 51};
52 52
53int copy_siginfo_to_user32(struct compat_siginfo __user *to, const siginfo_t *from)
54{
55 int err;
56
57 if (!access_ok(VERIFY_WRITE, to, sizeof(struct compat_siginfo)))
58 return -EFAULT;
59
60 /* If you change siginfo_t structure, please make sure that
61 this code is fixed accordingly.
62 It should never copy any pad contained in the structure
63 to avoid security leaks, but must copy the generic
64 3 ints plus the relevant union member. */
65 err = __put_user(from->si_signo, &to->si_signo);
66 err |= __put_user(from->si_errno, &to->si_errno);
67 err |= __put_user(from->si_code, &to->si_code);
68
69 if (from->si_code < 0) {
70 err |= __put_user(from->si_pid, &to->si_pid);
71 err |= __put_user(from->si_uid, &to->si_uid);
72 err |= __put_user(from->si_int, &to->si_int);
73 } else {
74 /*
75 * First 32bits of unions are always present:
76 * si_pid === si_band === si_tid === si_addr(LS half)
77 */
78 err |= __put_user(from->_sifields._pad[0],
79 &to->_sifields._pad[0]);
80 switch (siginfo_layout(from->si_signo, from->si_code)) {
81 case SIL_FAULT:
82 break;
83 case SIL_CHLD:
84 err |= __put_user(from->si_utime, &to->si_utime);
85 err |= __put_user(from->si_stime, &to->si_stime);
86 err |= __put_user(from->si_status, &to->si_status);
87 /* FALL THROUGH */
88 default:
89 case SIL_KILL:
90 err |= __put_user(from->si_uid, &to->si_uid);
91 break;
92 case SIL_POLL:
93 err |= __put_user(from->si_fd, &to->si_fd);
94 break;
95 case SIL_TIMER:
96 err |= __put_user(from->si_overrun, &to->si_overrun);
97 err |= __put_user(from->si_int, &to->si_int);
98 break;
99 case SIL_RT:
100 err |= __put_user(from->si_uid, &to->si_uid);
101 err |= __put_user(from->si_int, &to->si_int);
102 break;
103 }
104 }
105 return err;
106}
107
108int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from)
109{
110 int err;
111
112 if (!access_ok(VERIFY_READ, from, sizeof(struct compat_siginfo)))
113 return -EFAULT;
114
115 err = __get_user(to->si_signo, &from->si_signo);
116 err |= __get_user(to->si_errno, &from->si_errno);
117 err |= __get_user(to->si_code, &from->si_code);
118
119 err |= __get_user(to->si_pid, &from->si_pid);
120 err |= __get_user(to->si_uid, &from->si_uid);
121 err |= __get_user(to->si_int, &from->si_int);
122
123 return err;
124}
125
126/* The assembly shim for this function arranges to ignore the return value. */ 53/* The assembly shim for this function arranges to ignore the return value. */
127long compat_sys_rt_sigreturn(void) 54long compat_sys_rt_sigreturn(void)
128{ 55{
diff --git a/arch/tile/kernel/single_step.c b/arch/tile/kernel/single_step.c
index de3eae813e52..479d8033a801 100644
--- a/arch/tile/kernel/single_step.c
+++ b/arch/tile/kernel/single_step.c
@@ -163,11 +163,13 @@ static tilepro_bundle_bits rewrite_load_store_unaligned(
163 * actual bad address in an SPR, which it doesn't. 163 * actual bad address in an SPR, which it doesn't.
164 */ 164 */
165 if (align_ctl == 0) { 165 if (align_ctl == 0) {
166 siginfo_t info = { 166 siginfo_t info;
167 .si_signo = SIGBUS, 167
168 .si_code = BUS_ADRALN, 168 clear_siginfo(&info);
169 .si_addr = addr 169 info.si_signo = SIGBUS;
170 }; 170 info.si_code = BUS_ADRALN;
171 info.si_addr = addr;
172
171 trace_unhandled_signal("unaligned trap", regs, 173 trace_unhandled_signal("unaligned trap", regs,
172 (unsigned long)addr, SIGBUS); 174 (unsigned long)addr, SIGBUS);
173 force_sig_info(info.si_signo, &info, current); 175 force_sig_info(info.si_signo, &info, current);
@@ -210,11 +212,13 @@ static tilepro_bundle_bits rewrite_load_store_unaligned(
210 } 212 }
211 213
212 if (err) { 214 if (err) {
213 siginfo_t info = { 215 siginfo_t info;
214 .si_signo = SIGBUS, 216
215 .si_code = BUS_ADRALN, 217 clear_siginfo(&info);
216 .si_addr = addr 218 info.si_signo = SIGBUS;
217 }; 219 info.si_code = BUS_ADRALN;
220 info.si_addr = addr;
221
218 trace_unhandled_signal("bad address for unaligned fixup", regs, 222 trace_unhandled_signal("bad address for unaligned fixup", regs,
219 (unsigned long)addr, SIGBUS); 223 (unsigned long)addr, SIGBUS);
220 force_sig_info(info.si_signo, &info, current); 224 force_sig_info(info.si_signo, &info, current);
diff --git a/arch/tile/kernel/traps.c b/arch/tile/kernel/traps.c
index 9b08c6055f15..83a7186198d7 100644
--- a/arch/tile/kernel/traps.c
+++ b/arch/tile/kernel/traps.c
@@ -256,12 +256,14 @@ static int do_bpt(struct pt_regs *regs)
256void __kprobes do_trap(struct pt_regs *regs, int fault_num, 256void __kprobes do_trap(struct pt_regs *regs, int fault_num,
257 unsigned long reason) 257 unsigned long reason)
258{ 258{
259 siginfo_t info = { 0 }; 259 siginfo_t info;
260 int signo, code; 260 int signo, code;
261 unsigned long address = 0; 261 unsigned long address = 0;
262 tile_bundle_bits instr; 262 tile_bundle_bits instr;
263 int is_kernel = !user_mode(regs); 263 int is_kernel = !user_mode(regs);
264 264
265 clear_siginfo(&info);
266
265 /* Handle breakpoints, etc. */ 267 /* Handle breakpoints, etc. */
266 if (is_kernel && fault_num == INT_ILL && do_bpt(regs)) 268 if (is_kernel && fault_num == INT_ILL && do_bpt(regs))
267 return; 269 return;
diff --git a/arch/tile/kernel/unaligned.c b/arch/tile/kernel/unaligned.c
index 8149c38f67b6..77a0b6b6a2a1 100644
--- a/arch/tile/kernel/unaligned.c
+++ b/arch/tile/kernel/unaligned.c
@@ -980,11 +980,13 @@ void jit_bundle_gen(struct pt_regs *regs, tilegx_bundle_bits bundle,
980 } 980 }
981 981
982 if ((align_ctl == 0) || unexpected) { 982 if ((align_ctl == 0) || unexpected) {
983 siginfo_t info = { 983 siginfo_t info;
984 .si_signo = SIGBUS, 984
985 .si_code = BUS_ADRALN, 985 clear_siginfo(&info);
986 .si_addr = (unsigned char __user *)0 986 info.si_signo = SIGBUS;
987 }; 987 info.si_code = BUS_ADRALN;
988 info.si_addr = (unsigned char __user *)0;
989
988 if (unaligned_printk) 990 if (unaligned_printk)
989 pr_info("Unalign bundle: unexp @%llx, %llx\n", 991 pr_info("Unalign bundle: unexp @%llx, %llx\n",
990 (unsigned long long)regs->pc, 992 (unsigned long long)regs->pc,
@@ -1396,11 +1398,12 @@ void jit_bundle_gen(struct pt_regs *regs, tilegx_bundle_bits bundle,
1396 &frag, sizeof(frag)); 1398 &frag, sizeof(frag));
1397 if (status) { 1399 if (status) {
1398 /* Fail to copy JIT into user land. send SIGSEGV. */ 1400 /* Fail to copy JIT into user land. send SIGSEGV. */
1399 siginfo_t info = { 1401 siginfo_t info;
1400 .si_signo = SIGSEGV, 1402
1401 .si_code = SEGV_MAPERR, 1403 clear_siginfo(&info);
1402 .si_addr = (void __user *)&jit_code_area[idx] 1404 info.si_signo = SIGSEGV;
1403 }; 1405 info.si_code = SEGV_MAPERR;
1406 info.si_addr = (void __user *)&jit_code_area[idx];
1404 1407
1405 pr_warn("Unalign fixup: pid=%d %s jit_code_area=%llx\n", 1408 pr_warn("Unalign fixup: pid=%d %s jit_code_area=%llx\n",
1406 current->pid, current->comm, 1409 current->pid, current->comm,
@@ -1511,11 +1514,12 @@ void do_unaligned(struct pt_regs *regs, int vecnum)
1511 * If so, we will trigger SIGBUS. 1514 * If so, we will trigger SIGBUS.
1512 */ 1515 */
1513 if ((regs->sp & 0x7) || (regs->ex1) || (align_ctl < 0)) { 1516 if ((regs->sp & 0x7) || (regs->ex1) || (align_ctl < 0)) {
1514 siginfo_t info = { 1517 siginfo_t info;
1515 .si_signo = SIGBUS, 1518
1516 .si_code = BUS_ADRALN, 1519 clear_siginfo(&info);
1517 .si_addr = (unsigned char __user *)0 1520 info.si_signo = SIGBUS;
1518 }; 1521 info.si_code = BUS_ADRALN;
1522 info.si_addr = (unsigned char __user *)0;
1519 1523
1520 if (unaligned_printk) 1524 if (unaligned_printk)
1521 pr_info("Unalign fixup: %d %llx @%llx\n", 1525 pr_info("Unalign fixup: %d %llx @%llx\n",
@@ -1535,11 +1539,13 @@ void do_unaligned(struct pt_regs *regs, int vecnum)
1535 pc = (tilegx_bundle_bits __user *)(regs->pc); 1539 pc = (tilegx_bundle_bits __user *)(regs->pc);
1536 if (get_user(bundle, pc) != 0) { 1540 if (get_user(bundle, pc) != 0) {
1537 /* Probably never be here since pc is valid user address.*/ 1541 /* Probably never be here since pc is valid user address.*/
1538 siginfo_t info = { 1542 siginfo_t info;
1539 .si_signo = SIGSEGV, 1543
1540 .si_code = SEGV_MAPERR, 1544 clear_siginfo(&info);
1541 .si_addr = (void __user *)pc 1545 info.si_signo = SIGSEGV;
1542 }; 1546 info.si_code = SEGV_MAPERR;
1547 info.si_addr = (void __user *)pc;
1548
1543 pr_err("Couldn't read instruction at %p trying to step\n", pc); 1549 pr_err("Couldn't read instruction at %p trying to step\n", pc);
1544 trace_unhandled_signal("segfault in unalign fixup", regs, 1550 trace_unhandled_signal("segfault in unalign fixup", regs,
1545 (unsigned long)info.si_addr, SIGSEGV); 1551 (unsigned long)info.si_addr, SIGSEGV);
diff --git a/arch/um/kernel/trap.c b/arch/um/kernel/trap.c
index 428644175956..b2b02df9896e 100644
--- a/arch/um/kernel/trap.c
+++ b/arch/um/kernel/trap.c
@@ -306,7 +306,7 @@ void relay_signal(int sig, struct siginfo *si, struct uml_pt_regs *regs)
306 306
307 arch_examine_signal(sig, regs); 307 arch_examine_signal(sig, regs);
308 308
309 memset(&clean_si, 0, sizeof(clean_si)); 309 clear_siginfo(&clean_si);
310 clean_si.si_signo = si->si_signo; 310 clean_si.si_signo = si->si_signo;
311 clean_si.si_errno = si->si_errno; 311 clean_si.si_errno = si->si_errno;
312 clean_si.si_code = si->si_code; 312 clean_si.si_code = si->si_code;
diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
index 2cbd75dd2fd3..e1c8dab86670 100644
--- a/arch/x86/include/asm/compat.h
+++ b/arch/x86/include/asm/compat.h
@@ -127,88 +127,6 @@ typedef u32 compat_old_sigset_t; /* at least 32 bits */
127 127
128typedef u32 compat_sigset_word; 128typedef u32 compat_sigset_word;
129 129
130typedef union compat_sigval {
131 compat_int_t sival_int;
132 compat_uptr_t sival_ptr;
133} compat_sigval_t;
134
135typedef struct compat_siginfo {
136 int si_signo;
137 int si_errno;
138 int si_code;
139
140 union {
141 int _pad[128/sizeof(int) - 3];
142
143 /* kill() */
144 struct {
145 unsigned int _pid; /* sender's pid */
146 unsigned int _uid; /* sender's uid */
147 } _kill;
148
149 /* POSIX.1b timers */
150 struct {
151 compat_timer_t _tid; /* timer id */
152 int _overrun; /* overrun count */
153 compat_sigval_t _sigval; /* same as below */
154 int _sys_private; /* not to be passed to user */
155 int _overrun_incr; /* amount to add to overrun */
156 } _timer;
157
158 /* POSIX.1b signals */
159 struct {
160 unsigned int _pid; /* sender's pid */
161 unsigned int _uid; /* sender's uid */
162 compat_sigval_t _sigval;
163 } _rt;
164
165 /* SIGCHLD */
166 struct {
167 unsigned int _pid; /* which child */
168 unsigned int _uid; /* sender's uid */
169 int _status; /* exit code */
170 compat_clock_t _utime;
171 compat_clock_t _stime;
172 } _sigchld;
173
174 /* SIGCHLD (x32 version) */
175 struct {
176 unsigned int _pid; /* which child */
177 unsigned int _uid; /* sender's uid */
178 int _status; /* exit code */
179 compat_s64 _utime;
180 compat_s64 _stime;
181 } _sigchld_x32;
182
183 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
184 struct {
185 unsigned int _addr; /* faulting insn/memory ref. */
186 short int _addr_lsb; /* Valid LSB of the reported address. */
187 union {
188 /* used when si_code=SEGV_BNDERR */
189 struct {
190 compat_uptr_t _lower;
191 compat_uptr_t _upper;
192 } _addr_bnd;
193 /* used when si_code=SEGV_PKUERR */
194 compat_u32 _pkey;
195 };
196 } _sigfault;
197
198 /* SIGPOLL */
199 struct {
200 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
201 int _fd;
202 } _sigpoll;
203
204 struct {
205 unsigned int _call_addr; /* calling insn */
206 int _syscall; /* triggering system call number */
207 unsigned int _arch; /* AUDIT_ARCH_* of syscall */
208 } _sigsys;
209 } _sifields;
210} compat_siginfo_t;
211
212#define COMPAT_OFF_T_MAX 0x7fffffff 130#define COMPAT_OFF_T_MAX 0x7fffffff
213 131
214struct compat_ipc64_perm { 132struct compat_ipc64_perm {
@@ -331,4 +249,8 @@ static inline bool in_compat_syscall(void)
331} 249}
332#define in_compat_syscall in_compat_syscall /* override the generic impl */ 250#define in_compat_syscall in_compat_syscall /* override the generic impl */
333 251
252struct compat_siginfo;
253int __copy_siginfo_to_user32(struct compat_siginfo __user *to,
254 const siginfo_t *from, bool x32_ABI);
255
334#endif /* _ASM_X86_COMPAT_H */ 256#endif /* _ASM_X86_COMPAT_H */
diff --git a/arch/x86/include/asm/fpu/signal.h b/arch/x86/include/asm/fpu/signal.h
index 4df2754ef380..44bbc39a57b3 100644
--- a/arch/x86/include/asm/fpu/signal.h
+++ b/arch/x86/include/asm/fpu/signal.h
@@ -20,12 +20,6 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
20# define ia32_setup_rt_frame __setup_rt_frame 20# define ia32_setup_rt_frame __setup_rt_frame
21#endif 21#endif
22 22
23#ifdef CONFIG_COMPAT
24int __copy_siginfo_to_user32(compat_siginfo_t __user *to,
25 const siginfo_t *from, bool x32_ABI);
26#endif
27
28
29extern void convert_from_fxsr(struct user_i387_ia32_struct *env, 23extern void convert_from_fxsr(struct user_i387_ia32_struct *env,
30 struct task_struct *tsk); 24 struct task_struct *tsk);
31extern void convert_to_fxsr(struct task_struct *tsk, 25extern void convert_to_fxsr(struct task_struct *tsk,
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index c3655e0fc156..ba1f9555fbc5 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -591,7 +591,7 @@ static int srao_decode_notifier(struct notifier_block *nb, unsigned long val,
591 591
592 if (mce_usable_address(mce) && (mce->severity == MCE_AO_SEVERITY)) { 592 if (mce_usable_address(mce) && (mce->severity == MCE_AO_SEVERITY)) {
593 pfn = mce->addr >> PAGE_SHIFT; 593 pfn = mce->addr >> PAGE_SHIFT;
594 memory_failure(pfn, MCE_VECTOR, 0); 594 memory_failure(pfn, 0);
595 } 595 }
596 596
597 return NOTIFY_OK; 597 return NOTIFY_OK;
@@ -1055,7 +1055,7 @@ static int do_memory_failure(struct mce *m)
1055 pr_err("Uncorrected hardware memory error in user-access at %llx", m->addr); 1055 pr_err("Uncorrected hardware memory error in user-access at %llx", m->addr);
1056 if (!(m->mcgstatus & MCG_STATUS_RIPV)) 1056 if (!(m->mcgstatus & MCG_STATUS_RIPV))
1057 flags |= MF_MUST_KILL; 1057 flags |= MF_MUST_KILL;
1058 ret = memory_failure(m->addr >> PAGE_SHIFT, MCE_VECTOR, flags); 1058 ret = memory_failure(m->addr >> PAGE_SHIFT, flags);
1059 if (ret) 1059 if (ret)
1060 pr_err("Memory error not recovered"); 1060 pr_err("Memory error not recovered");
1061 return ret; 1061 return ret;
@@ -1334,7 +1334,7 @@ out_ist:
1334EXPORT_SYMBOL_GPL(do_machine_check); 1334EXPORT_SYMBOL_GPL(do_machine_check);
1335 1335
1336#ifndef CONFIG_MEMORY_FAILURE 1336#ifndef CONFIG_MEMORY_FAILURE
1337int memory_failure(unsigned long pfn, int vector, int flags) 1337int memory_failure(unsigned long pfn, int flags)
1338{ 1338{
1339 /* mce_severity() should not hand us an ACTION_REQUIRED error */ 1339 /* mce_severity() should not hand us an ACTION_REQUIRED error */
1340 BUG_ON(flags & MF_ACTION_REQUIRED); 1340 BUG_ON(flags & MF_ACTION_REQUIRED);
diff --git a/arch/x86/kernel/signal_compat.c b/arch/x86/kernel/signal_compat.c
index 8c6da1a643da..ac057f9b0763 100644
--- a/arch/x86/kernel/signal_compat.c
+++ b/arch/x86/kernel/signal_compat.c
@@ -25,8 +25,8 @@ static inline void signal_compat_build_tests(void)
25 * limits also have to look at this code. Make sure any 25 * limits also have to look at this code. Make sure any
26 * new fields are handled in copy_siginfo_to_user32()! 26 * new fields are handled in copy_siginfo_to_user32()!
27 */ 27 */
28 BUILD_BUG_ON(NSIGILL != 8); 28 BUILD_BUG_ON(NSIGILL != 11);
29 BUILD_BUG_ON(NSIGFPE != 8); 29 BUILD_BUG_ON(NSIGFPE != 13);
30 BUILD_BUG_ON(NSIGSEGV != 4); 30 BUILD_BUG_ON(NSIGSEGV != 4);
31 BUILD_BUG_ON(NSIGBUS != 5); 31 BUILD_BUG_ON(NSIGBUS != 5);
32 BUILD_BUG_ON(NSIGTRAP != 4); 32 BUILD_BUG_ON(NSIGTRAP != 4);
@@ -64,7 +64,7 @@ static inline void signal_compat_build_tests(void)
64 CHECK_SI_SIZE (_kill, 2*sizeof(int)); 64 CHECK_SI_SIZE (_kill, 2*sizeof(int));
65 65
66 CHECK_CSI_OFFSET(_timer); 66 CHECK_CSI_OFFSET(_timer);
67 CHECK_CSI_SIZE (_timer, 5*sizeof(int)); 67 CHECK_CSI_SIZE (_timer, 3*sizeof(int));
68 CHECK_SI_SIZE (_timer, 6*sizeof(int)); 68 CHECK_SI_SIZE (_timer, 6*sizeof(int));
69 69
70 CHECK_CSI_OFFSET(_rt); 70 CHECK_CSI_OFFSET(_rt);
@@ -75,9 +75,11 @@ static inline void signal_compat_build_tests(void)
75 CHECK_CSI_SIZE (_sigchld, 5*sizeof(int)); 75 CHECK_CSI_SIZE (_sigchld, 5*sizeof(int));
76 CHECK_SI_SIZE (_sigchld, 8*sizeof(int)); 76 CHECK_SI_SIZE (_sigchld, 8*sizeof(int));
77 77
78#ifdef CONFIG_X86_X32_ABI
78 CHECK_CSI_OFFSET(_sigchld_x32); 79 CHECK_CSI_OFFSET(_sigchld_x32);
79 CHECK_CSI_SIZE (_sigchld_x32, 7*sizeof(int)); 80 CHECK_CSI_SIZE (_sigchld_x32, 7*sizeof(int));
80 /* no _sigchld_x32 in the generic siginfo_t */ 81 /* no _sigchld_x32 in the generic siginfo_t */
82#endif
81 83
82 CHECK_CSI_OFFSET(_sigfault); 84 CHECK_CSI_OFFSET(_sigfault);
83 CHECK_CSI_SIZE (_sigfault, 4*sizeof(int)); 85 CHECK_CSI_SIZE (_sigfault, 4*sizeof(int));
@@ -96,6 +98,8 @@ static inline void signal_compat_build_tests(void)
96 98
97void sigaction_compat_abi(struct k_sigaction *act, struct k_sigaction *oact) 99void sigaction_compat_abi(struct k_sigaction *act, struct k_sigaction *oact)
98{ 100{
101 signal_compat_build_tests();
102
99 /* Don't leak in-kernel non-uapi flags to user-space */ 103 /* Don't leak in-kernel non-uapi flags to user-space */
100 if (oact) 104 if (oact)
101 oact->sa.sa_flags &= ~(SA_IA32_ABI | SA_X32_ABI); 105 oact->sa.sa_flags &= ~(SA_IA32_ABI | SA_X32_ABI);
@@ -111,116 +115,3 @@ void sigaction_compat_abi(struct k_sigaction *act, struct k_sigaction *oact)
111 if (in_x32_syscall()) 115 if (in_x32_syscall())
112 act->sa.sa_flags |= SA_X32_ABI; 116 act->sa.sa_flags |= SA_X32_ABI;
113} 117}
114
115int __copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from,
116 bool x32_ABI)
117{
118 int err = 0;
119
120 signal_compat_build_tests();
121
122 if (!access_ok(VERIFY_WRITE, to, sizeof(compat_siginfo_t)))
123 return -EFAULT;
124
125 put_user_try {
126 /* If you change siginfo_t structure, please make sure that
127 this code is fixed accordingly.
128 It should never copy any pad contained in the structure
129 to avoid security leaks, but must copy the generic
130 3 ints plus the relevant union member. */
131 put_user_ex(from->si_signo, &to->si_signo);
132 put_user_ex(from->si_errno, &to->si_errno);
133 put_user_ex(from->si_code, &to->si_code);
134
135 if (from->si_code < 0) {
136 put_user_ex(from->si_pid, &to->si_pid);
137 put_user_ex(from->si_uid, &to->si_uid);
138 put_user_ex(ptr_to_compat(from->si_ptr), &to->si_ptr);
139 } else {
140 /*
141 * First 32bits of unions are always present:
142 * si_pid === si_band === si_tid === si_addr(LS half)
143 */
144 put_user_ex(from->_sifields._pad[0],
145 &to->_sifields._pad[0]);
146 switch (siginfo_layout(from->si_signo, from->si_code)) {
147 case SIL_FAULT:
148 if (from->si_signo == SIGBUS &&
149 (from->si_code == BUS_MCEERR_AR ||
150 from->si_code == BUS_MCEERR_AO))
151 put_user_ex(from->si_addr_lsb, &to->si_addr_lsb);
152
153 if (from->si_signo == SIGSEGV) {
154 if (from->si_code == SEGV_BNDERR) {
155 compat_uptr_t lower = (unsigned long)from->si_lower;
156 compat_uptr_t upper = (unsigned long)from->si_upper;
157 put_user_ex(lower, &to->si_lower);
158 put_user_ex(upper, &to->si_upper);
159 }
160 if (from->si_code == SEGV_PKUERR)
161 put_user_ex(from->si_pkey, &to->si_pkey);
162 }
163 break;
164 case SIL_SYS:
165 put_user_ex(from->si_syscall, &to->si_syscall);
166 put_user_ex(from->si_arch, &to->si_arch);
167 break;
168 case SIL_CHLD:
169 if (!x32_ABI) {
170 put_user_ex(from->si_utime, &to->si_utime);
171 put_user_ex(from->si_stime, &to->si_stime);
172 } else {
173 put_user_ex(from->si_utime, &to->_sifields._sigchld_x32._utime);
174 put_user_ex(from->si_stime, &to->_sifields._sigchld_x32._stime);
175 }
176 put_user_ex(from->si_status, &to->si_status);
177 /* FALL THROUGH */
178 case SIL_KILL:
179 put_user_ex(from->si_uid, &to->si_uid);
180 break;
181 case SIL_POLL:
182 put_user_ex(from->si_fd, &to->si_fd);
183 break;
184 case SIL_TIMER:
185 put_user_ex(from->si_overrun, &to->si_overrun);
186 put_user_ex(ptr_to_compat(from->si_ptr),
187 &to->si_ptr);
188 break;
189 case SIL_RT:
190 put_user_ex(from->si_uid, &to->si_uid);
191 put_user_ex(from->si_int, &to->si_int);
192 break;
193 }
194 }
195 } put_user_catch(err);
196
197 return err;
198}
199
200/* from syscall's path, where we know the ABI */
201int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from)
202{
203 return __copy_siginfo_to_user32(to, from, in_x32_syscall());
204}
205
206int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
207{
208 int err = 0;
209 u32 ptr32;
210
211 if (!access_ok(VERIFY_READ, from, sizeof(compat_siginfo_t)))
212 return -EFAULT;
213
214 get_user_try {
215 get_user_ex(to->si_signo, &from->si_signo);
216 get_user_ex(to->si_errno, &from->si_errno);
217 get_user_ex(to->si_code, &from->si_code);
218
219 get_user_ex(to->si_pid, &from->si_pid);
220 get_user_ex(to->si_uid, &from->si_uid);
221 get_user_ex(ptr32, &from->si_ptr);
222 to->si_ptr = compat_ptr(ptr32);
223 } get_user_catch(err);
224
225 return err;
226}
diff --git a/arch/xtensa/kernel/ptrace.c b/arch/xtensa/kernel/ptrace.c
index e2461968efb2..c0845cb1cbb9 100644
--- a/arch/xtensa/kernel/ptrace.c
+++ b/arch/xtensa/kernel/ptrace.c
@@ -278,7 +278,6 @@ static void ptrace_hbptriggered(struct perf_event *bp,
278 struct pt_regs *regs) 278 struct pt_regs *regs)
279{ 279{
280 int i; 280 int i;
281 siginfo_t info;
282 struct arch_hw_breakpoint *bkpt = counter_arch_bp(bp); 281 struct arch_hw_breakpoint *bkpt = counter_arch_bp(bp);
283 282
284 if (bp->attr.bp_type & HW_BREAKPOINT_X) { 283 if (bp->attr.bp_type & HW_BREAKPOINT_X) {
@@ -293,12 +292,7 @@ static void ptrace_hbptriggered(struct perf_event *bp,
293 i = (i << 1) | 1; 292 i = (i << 1) | 1;
294 } 293 }
295 294
296 info.si_signo = SIGTRAP; 295 force_sig_ptrace_errno_trap(i, (void __user *)bkpt->address);
297 info.si_errno = i;
298 info.si_code = TRAP_HWBKPT;
299 info.si_addr = (void __user *)bkpt->address;
300
301 force_sig_info(SIGTRAP, &info, current);
302} 296}
303 297
304static struct perf_event *ptrace_hbp_create(struct task_struct *tsk, int type) 298static struct perf_event *ptrace_hbp_create(struct task_struct *tsk, int type)
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 16c4a10b7506..1efefe919555 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -410,7 +410,7 @@ static void ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata, int
410 flags = 0; 410 flags = 0;
411 411
412 if (flags != -1) 412 if (flags != -1)
413 memory_failure_queue(pfn, 0, flags); 413 memory_failure_queue(pfn, flags);
414#endif 414#endif
415} 415}
416 416
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 1d60b58a8c19..fe4b24f05f6a 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -569,7 +569,7 @@ store_hard_offline_page(struct device *dev,
569 if (kstrtoull(buf, 0, &pfn) < 0) 569 if (kstrtoull(buf, 0, &pfn) < 0)
570 return -EINVAL; 570 return -EINVAL;
571 pfn >>= PAGE_SHIFT; 571 pfn >>= PAGE_SHIFT;
572 ret = memory_failure(pfn, 0, 0); 572 ret = memory_failure(pfn, 0);
573 return ret ? ret : count; 573 return ret ? ret : count;
574} 574}
575 575
diff --git a/drivers/ras/cec.c b/drivers/ras/cec.c
index ca44e6977cf2..2d9ec378a8bc 100644
--- a/drivers/ras/cec.c
+++ b/drivers/ras/cec.c
@@ -327,7 +327,7 @@ int cec_add_elem(u64 pfn)
327 } else { 327 } else {
328 /* We have reached max count for this page, soft-offline it. */ 328 /* We have reached max count for this page, soft-offline it. */
329 pr_err("Soft-offlining pfn: 0x%llx\n", pfn); 329 pr_err("Soft-offlining pfn: 0x%llx\n", pfn);
330 memory_failure_queue(pfn, 0, MF_SOFT_OFFLINE); 330 memory_failure_queue(pfn, MF_SOFT_OFFLINE);
331 ca->pfns_poisoned++; 331 ca->pfns_poisoned++;
332 } 332 }
333 333
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index a3fad4ec9870..3f9bd3e4c373 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -595,7 +595,7 @@ static void async_completed(struct urb *urb)
595 as->status = urb->status; 595 as->status = urb->status;
596 signr = as->signr; 596 signr = as->signr;
597 if (signr) { 597 if (signr) {
598 memset(&sinfo, 0, sizeof(sinfo)); 598 clear_siginfo(&sinfo);
599 sinfo.si_signo = as->signr; 599 sinfo.si_signo = as->signr;
600 sinfo.si_errno = as->status; 600 sinfo.si_errno = as->status;
601 sinfo.si_code = SI_ASYNCIO; 601 sinfo.si_code = SI_ASYNCIO;
@@ -2613,7 +2613,7 @@ static void usbdev_remove(struct usb_device *udev)
2613 wake_up_all(&ps->wait); 2613 wake_up_all(&ps->wait);
2614 list_del_init(&ps->list); 2614 list_del_init(&ps->list);
2615 if (ps->discsignr) { 2615 if (ps->discsignr) {
2616 memset(&sinfo, 0, sizeof(sinfo)); 2616 clear_siginfo(&sinfo);
2617 sinfo.si_signo = ps->discsignr; 2617 sinfo.si_signo = ps->discsignr;
2618 sinfo.si_errno = EPIPE; 2618 sinfo.si_errno = EPIPE;
2619 sinfo.si_code = SI_ASYNCIO; 2619 sinfo.si_code = SI_ASYNCIO;
diff --git a/fs/fcntl.c b/fs/fcntl.c
index 0522e283a4f4..c17369659f4a 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -737,6 +737,7 @@ static void send_sigio_to_task(struct task_struct *p,
737 delivered even if we can't queue. Failure to 737 delivered even if we can't queue. Failure to
738 queue in this case _should_ be reported; we fall 738 queue in this case _should_ be reported; we fall
739 back to SIGIO in that case. --sct */ 739 back to SIGIO in that case. --sct */
740 clear_siginfo(&si);
740 si.si_signo = signum; 741 si.si_signo = signum;
741 si.si_errno = 0; 742 si.si_errno = 0;
742 si.si_code = reason; 743 si.si_code = reason;
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 0fc36406f32c..8a9643857c4a 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -157,6 +157,104 @@ struct compat_sigaction {
157 compat_sigset_t sa_mask __packed; 157 compat_sigset_t sa_mask __packed;
158}; 158};
159 159
160typedef union compat_sigval {
161 compat_int_t sival_int;
162 compat_uptr_t sival_ptr;
163} compat_sigval_t;
164
165typedef struct compat_siginfo {
166 int si_signo;
167#ifndef __ARCH_HAS_SWAPPED_SIGINFO
168 int si_errno;
169 int si_code;
170#else
171 int si_code;
172 int si_errno;
173#endif
174
175 union {
176 int _pad[128/sizeof(int) - 3];
177
178 /* kill() */
179 struct {
180 compat_pid_t _pid; /* sender's pid */
181 __compat_uid32_t _uid; /* sender's uid */
182 } _kill;
183
184 /* POSIX.1b timers */
185 struct {
186 compat_timer_t _tid; /* timer id */
187 int _overrun; /* overrun count */
188 compat_sigval_t _sigval; /* same as below */
189 } _timer;
190
191 /* POSIX.1b signals */
192 struct {
193 compat_pid_t _pid; /* sender's pid */
194 __compat_uid32_t _uid; /* sender's uid */
195 compat_sigval_t _sigval;
196 } _rt;
197
198 /* SIGCHLD */
199 struct {
200 compat_pid_t _pid; /* which child */
201 __compat_uid32_t _uid; /* sender's uid */
202 int _status; /* exit code */
203 compat_clock_t _utime;
204 compat_clock_t _stime;
205 } _sigchld;
206
207#ifdef CONFIG_X86_X32_ABI
208 /* SIGCHLD (x32 version) */
209 struct {
210 compat_pid_t _pid; /* which child */
211 __compat_uid32_t _uid; /* sender's uid */
212 int _status; /* exit code */
213 compat_s64 _utime;
214 compat_s64 _stime;
215 } _sigchld_x32;
216#endif
217
218 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGTRAP, SIGEMT */
219 struct {
220 compat_uptr_t _addr; /* faulting insn/memory ref. */
221#ifdef __ARCH_SI_TRAPNO
222 int _trapno; /* TRAP # which caused the signal */
223#endif
224 union {
225 /*
226 * used when si_code=BUS_MCEERR_AR or
227 * used when si_code=BUS_MCEERR_AO
228 */
229 short int _addr_lsb; /* Valid LSB of the reported address. */
230 /* used when si_code=SEGV_BNDERR */
231 struct {
232 short _dummy_bnd;
233 compat_uptr_t _lower;
234 compat_uptr_t _upper;
235 } _addr_bnd;
236 /* used when si_code=SEGV_PKUERR */
237 struct {
238 short _dummy_pkey;
239 u32 _pkey;
240 } _addr_pkey;
241 };
242 } _sigfault;
243
244 /* SIGPOLL */
245 struct {
246 compat_long_t _band; /* POLL_IN, POLL_OUT, POLL_MSG */
247 int _fd;
248 } _sigpoll;
249
250 struct {
251 compat_uptr_t _call_addr; /* calling user insn */
252 int _syscall; /* triggering system call number */
253 unsigned int _arch; /* AUDIT_ARCH_* of syscall */
254 } _sigsys;
255 } _sifields;
256} compat_siginfo_t;
257
160/* 258/*
161 * These functions operate on 32- or 64-bit specs depending on 259 * These functions operate on 32- or 64-bit specs depending on
162 * COMPAT_USE_64BIT_TIME, hence the void user pointer arguments. 260 * COMPAT_USE_64BIT_TIME, hence the void user pointer arguments.
@@ -412,7 +510,7 @@ long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask,
412 unsigned long bitmap_size); 510 unsigned long bitmap_size);
413long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask, 511long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
414 unsigned long bitmap_size); 512 unsigned long bitmap_size);
415int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from); 513int copy_siginfo_from_user32(siginfo_t *to, const struct compat_siginfo __user *from);
416int copy_siginfo_to_user32(struct compat_siginfo __user *to, const siginfo_t *from); 514int copy_siginfo_to_user32(struct compat_siginfo __user *to, const siginfo_t *from);
417int get_compat_sigevent(struct sigevent *event, 515int get_compat_sigevent(struct sigevent *event,
418 const struct compat_sigevent __user *u_event); 516 const struct compat_sigevent __user *u_event);
diff --git a/include/linux/mm.h b/include/linux/mm.h
index ea818ff739cd..7fc92384977e 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2570,8 +2570,8 @@ enum mf_flags {
2570 MF_MUST_KILL = 1 << 2, 2570 MF_MUST_KILL = 1 << 2,
2571 MF_SOFT_OFFLINE = 1 << 3, 2571 MF_SOFT_OFFLINE = 1 << 3,
2572}; 2572};
2573extern int memory_failure(unsigned long pfn, int trapno, int flags); 2573extern int memory_failure(unsigned long pfn, int flags);
2574extern void memory_failure_queue(unsigned long pfn, int trapno, int flags); 2574extern void memory_failure_queue(unsigned long pfn, int flags);
2575extern int unpoison_memory(unsigned long pfn); 2575extern int unpoison_memory(unsigned long pfn);
2576extern int get_hwpoison_page(struct page *page); 2576extern int get_hwpoison_page(struct page *page);
2577#define put_hwpoison_page(page) put_page(page) 2577#define put_hwpoison_page(page) put_page(page)
diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h
index 0aa4548fb492..23b4f9cb82db 100644
--- a/include/linux/sched/signal.h
+++ b/include/linux/sched/signal.h
@@ -285,6 +285,34 @@ static inline void kernel_signal_stop(void)
285 285
286 schedule(); 286 schedule();
287} 287}
288#ifdef __ARCH_SI_TRAPNO
289# define ___ARCH_SI_TRAPNO(_a1) , _a1
290#else
291# define ___ARCH_SI_TRAPNO(_a1)
292#endif
293#ifdef __ia64__
294# define ___ARCH_SI_IA64(_a1, _a2, _a3) , _a1, _a2, _a3
295#else
296# define ___ARCH_SI_IA64(_a1, _a2, _a3)
297#endif
298
299int force_sig_fault(int sig, int code, void __user *addr
300 ___ARCH_SI_TRAPNO(int trapno)
301 ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr)
302 , struct task_struct *t);
303int send_sig_fault(int sig, int code, void __user *addr
304 ___ARCH_SI_TRAPNO(int trapno)
305 ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr)
306 , struct task_struct *t);
307
308int force_sig_mceerr(int code, void __user *, short, struct task_struct *);
309int send_sig_mceerr(int code, void __user *, short, struct task_struct *);
310
311int force_sig_bnderr(void __user *addr, void __user *lower, void __user *upper);
312int force_sig_pkuerr(void __user *addr, u32 pkey);
313
314int force_sig_ptrace_errno_trap(int errno, void __user *addr);
315
288extern int send_sig_info(int, struct siginfo *, struct task_struct *); 316extern int send_sig_info(int, struct siginfo *, struct task_struct *);
289extern int force_sigsegv(int, struct task_struct *); 317extern int force_sigsegv(int, struct task_struct *);
290extern int force_sig_info(int, struct siginfo *, struct task_struct *); 318extern int force_sig_info(int, struct siginfo *, struct task_struct *);
diff --git a/include/linux/signal.h b/include/linux/signal.h
index 042968dd98f0..a9bc7e1b077e 100644
--- a/include/linux/signal.h
+++ b/include/linux/signal.h
@@ -11,13 +11,14 @@ struct task_struct;
11/* for sysctl */ 11/* for sysctl */
12extern int print_fatal_signals; 12extern int print_fatal_signals;
13 13
14static inline void copy_siginfo(struct siginfo *to, struct siginfo *from) 14static inline void copy_siginfo(struct siginfo *to, const struct siginfo *from)
15{ 15{
16 if (from->si_code < 0) 16 memcpy(to, from, sizeof(*to));
17 memcpy(to, from, sizeof(*to)); 17}
18 else 18
19 /* _sigchld is currently the largest know union member */ 19static inline void clear_siginfo(struct siginfo *info)
20 memcpy(to, from, __ARCH_SI_PREAMBLE_SIZE + sizeof(from->_sifields._sigchld)); 20{
21 memset(info, 0, sizeof(*info));
21} 22}
22 23
23int copy_siginfo_to_user(struct siginfo __user *to, const struct siginfo *from); 24int copy_siginfo_to_user(struct siginfo __user *to, const struct siginfo *from);
@@ -29,9 +30,7 @@ enum siginfo_layout {
29 SIL_FAULT, 30 SIL_FAULT,
30 SIL_CHLD, 31 SIL_CHLD,
31 SIL_RT, 32 SIL_RT,
32#ifdef __ARCH_SIGSYS
33 SIL_SYS, 33 SIL_SYS,
34#endif
35}; 34};
36 35
37enum siginfo_layout siginfo_layout(int sig, int si_code); 36enum siginfo_layout siginfo_layout(int sig, int si_code);
diff --git a/include/uapi/asm-generic/siginfo.h b/include/uapi/asm-generic/siginfo.h
index e447283b8f52..254afc31e3be 100644
--- a/include/uapi/asm-generic/siginfo.h
+++ b/include/uapi/asm-generic/siginfo.h
@@ -23,10 +23,6 @@ typedef union sigval {
23#define SI_PAD_SIZE ((SI_MAX_SIZE - __ARCH_SI_PREAMBLE_SIZE) / sizeof(int)) 23#define SI_PAD_SIZE ((SI_MAX_SIZE - __ARCH_SI_PREAMBLE_SIZE) / sizeof(int))
24#endif 24#endif
25 25
26#ifndef __ARCH_SI_UID_T
27#define __ARCH_SI_UID_T __kernel_uid32_t
28#endif
29
30/* 26/*
31 * The default "si_band" type is "long", as specified by POSIX. 27 * The default "si_band" type is "long", as specified by POSIX.
32 * However, some architectures want to override this to "int" 28 * However, some architectures want to override this to "int"
@@ -44,12 +40,15 @@ typedef union sigval {
44#define __ARCH_SI_ATTRIBUTES 40#define __ARCH_SI_ATTRIBUTES
45#endif 41#endif
46 42
47#ifndef HAVE_ARCH_SIGINFO_T
48
49typedef struct siginfo { 43typedef struct siginfo {
50 int si_signo; 44 int si_signo;
45#ifndef __ARCH_HAS_SWAPPED_SIGINFO
51 int si_errno; 46 int si_errno;
52 int si_code; 47 int si_code;
48#else
49 int si_code;
50 int si_errno;
51#endif
53 52
54 union { 53 union {
55 int _pad[SI_PAD_SIZE]; 54 int _pad[SI_PAD_SIZE];
@@ -57,14 +56,13 @@ typedef struct siginfo {
57 /* kill() */ 56 /* kill() */
58 struct { 57 struct {
59 __kernel_pid_t _pid; /* sender's pid */ 58 __kernel_pid_t _pid; /* sender's pid */
60 __ARCH_SI_UID_T _uid; /* sender's uid */ 59 __kernel_uid32_t _uid; /* sender's uid */
61 } _kill; 60 } _kill;
62 61
63 /* POSIX.1b timers */ 62 /* POSIX.1b timers */
64 struct { 63 struct {
65 __kernel_timer_t _tid; /* timer id */ 64 __kernel_timer_t _tid; /* timer id */
66 int _overrun; /* overrun count */ 65 int _overrun; /* overrun count */
67 char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)];
68 sigval_t _sigval; /* same as below */ 66 sigval_t _sigval; /* same as below */
69 int _sys_private; /* not to be passed to user */ 67 int _sys_private; /* not to be passed to user */
70 } _timer; 68 } _timer;
@@ -72,34 +70,47 @@ typedef struct siginfo {
72 /* POSIX.1b signals */ 70 /* POSIX.1b signals */
73 struct { 71 struct {
74 __kernel_pid_t _pid; /* sender's pid */ 72 __kernel_pid_t _pid; /* sender's pid */
75 __ARCH_SI_UID_T _uid; /* sender's uid */ 73 __kernel_uid32_t _uid; /* sender's uid */
76 sigval_t _sigval; 74 sigval_t _sigval;
77 } _rt; 75 } _rt;
78 76
79 /* SIGCHLD */ 77 /* SIGCHLD */
80 struct { 78 struct {
81 __kernel_pid_t _pid; /* which child */ 79 __kernel_pid_t _pid; /* which child */
82 __ARCH_SI_UID_T _uid; /* sender's uid */ 80 __kernel_uid32_t _uid; /* sender's uid */
83 int _status; /* exit code */ 81 int _status; /* exit code */
84 __ARCH_SI_CLOCK_T _utime; 82 __ARCH_SI_CLOCK_T _utime;
85 __ARCH_SI_CLOCK_T _stime; 83 __ARCH_SI_CLOCK_T _stime;
86 } _sigchld; 84 } _sigchld;
87 85
88 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ 86 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGTRAP, SIGEMT */
89 struct { 87 struct {
90 void __user *_addr; /* faulting insn/memory ref. */ 88 void __user *_addr; /* faulting insn/memory ref. */
91#ifdef __ARCH_SI_TRAPNO 89#ifdef __ARCH_SI_TRAPNO
92 int _trapno; /* TRAP # which caused the signal */ 90 int _trapno; /* TRAP # which caused the signal */
93#endif 91#endif
94 short _addr_lsb; /* LSB of the reported address */ 92#ifdef __ia64__
93 int _imm; /* immediate value for "break" */
94 unsigned int _flags; /* see ia64 si_flags */
95 unsigned long _isr; /* isr */
96#endif
95 union { 97 union {
98 /*
99 * used when si_code=BUS_MCEERR_AR or
100 * used when si_code=BUS_MCEERR_AO
101 */
102 short _addr_lsb; /* LSB of the reported address */
96 /* used when si_code=SEGV_BNDERR */ 103 /* used when si_code=SEGV_BNDERR */
97 struct { 104 struct {
105 short _dummy_bnd;
98 void __user *_lower; 106 void __user *_lower;
99 void __user *_upper; 107 void __user *_upper;
100 } _addr_bnd; 108 } _addr_bnd;
101 /* used when si_code=SEGV_PKUERR */ 109 /* used when si_code=SEGV_PKUERR */
102 __u32 _pkey; 110 struct {
111 short _dummy_pkey;
112 __u32 _pkey;
113 } _addr_pkey;
103 }; 114 };
104 } _sigfault; 115 } _sigfault;
105 116
@@ -118,10 +129,6 @@ typedef struct siginfo {
118 } _sifields; 129 } _sifields;
119} __ARCH_SI_ATTRIBUTES siginfo_t; 130} __ARCH_SI_ATTRIBUTES siginfo_t;
120 131
121/* If the arch shares siginfo, then it has SIGSYS. */
122#define __ARCH_SIGSYS
123#endif
124
125/* 132/*
126 * How these fields are to be accessed. 133 * How these fields are to be accessed.
127 */ 134 */
@@ -143,14 +150,12 @@ typedef struct siginfo {
143#define si_addr_lsb _sifields._sigfault._addr_lsb 150#define si_addr_lsb _sifields._sigfault._addr_lsb
144#define si_lower _sifields._sigfault._addr_bnd._lower 151#define si_lower _sifields._sigfault._addr_bnd._lower
145#define si_upper _sifields._sigfault._addr_bnd._upper 152#define si_upper _sifields._sigfault._addr_bnd._upper
146#define si_pkey _sifields._sigfault._pkey 153#define si_pkey _sifields._sigfault._addr_pkey._pkey
147#define si_band _sifields._sigpoll._band 154#define si_band _sifields._sigpoll._band
148#define si_fd _sifields._sigpoll._fd 155#define si_fd _sifields._sigpoll._fd
149#ifdef __ARCH_SIGSYS
150#define si_call_addr _sifields._sigsys._call_addr 156#define si_call_addr _sifields._sigsys._call_addr
151#define si_syscall _sifields._sigsys._syscall 157#define si_syscall _sifields._sigsys._syscall
152#define si_arch _sifields._sigsys._arch 158#define si_arch _sifields._sigsys._arch
153#endif
154 159
155/* 160/*
156 * si_code values 161 * si_code values
@@ -165,6 +170,7 @@ typedef struct siginfo {
165#define SI_SIGIO -5 /* sent by queued SIGIO */ 170#define SI_SIGIO -5 /* sent by queued SIGIO */
166#define SI_TKILL -6 /* sent by tkill system call */ 171#define SI_TKILL -6 /* sent by tkill system call */
167#define SI_DETHREAD -7 /* sent by execve() killing subsidiary threads */ 172#define SI_DETHREAD -7 /* sent by execve() killing subsidiary threads */
173#define SI_ASYNCNL -60 /* sent by glibc async name lookup completion */
168 174
169#define SI_FROMUSER(siptr) ((siptr)->si_code <= 0) 175#define SI_FROMUSER(siptr) ((siptr)->si_code <= 0)
170#define SI_FROMKERNEL(siptr) ((siptr)->si_code > 0) 176#define SI_FROMKERNEL(siptr) ((siptr)->si_code > 0)
@@ -173,14 +179,34 @@ typedef struct siginfo {
173 * SIGILL si_codes 179 * SIGILL si_codes
174 */ 180 */
175#define ILL_ILLOPC 1 /* illegal opcode */ 181#define ILL_ILLOPC 1 /* illegal opcode */
182#ifdef __bfin__
183# define ILL_ILLPARAOP 2 /* illegal opcode combine */
184#endif
176#define ILL_ILLOPN 2 /* illegal operand */ 185#define ILL_ILLOPN 2 /* illegal operand */
177#define ILL_ILLADR 3 /* illegal addressing mode */ 186#define ILL_ILLADR 3 /* illegal addressing mode */
178#define ILL_ILLTRP 4 /* illegal trap */ 187#define ILL_ILLTRP 4 /* illegal trap */
188#ifdef __bfin__
189# define ILL_ILLEXCPT 4 /* unrecoverable exception */
190#endif
179#define ILL_PRVOPC 5 /* privileged opcode */ 191#define ILL_PRVOPC 5 /* privileged opcode */
180#define ILL_PRVREG 6 /* privileged register */ 192#define ILL_PRVREG 6 /* privileged register */
181#define ILL_COPROC 7 /* coprocessor error */ 193#define ILL_COPROC 7 /* coprocessor error */
182#define ILL_BADSTK 8 /* internal stack error */ 194#define ILL_BADSTK 8 /* internal stack error */
183#define NSIGILL 8 195#ifdef __bfin__
196# define ILL_CPLB_VI 9 /* D/I CPLB protect violation */
197# define ILL_CPLB_MISS 10 /* D/I CPLB miss */
198# define ILL_CPLB_MULHIT 11 /* D/I CPLB multiple hit */
199#endif
200#ifdef __tile__
201# define ILL_DBLFLT 9 /* double fault */
202# define ILL_HARDWALL 10 /* user networks hardwall violation */
203#endif
204#ifdef __ia64__
205# define ILL_BADIADDR 9 /* unimplemented instruction address */
206# define __ILL_BREAK 10 /* illegal break */
207# define __ILL_BNDMOD 11 /* bundle-update (modification) in progress */
208#endif
209#define NSIGILL 11
184 210
185/* 211/*
186 * SIGFPE si_codes 212 * SIGFPE si_codes
@@ -193,15 +219,33 @@ typedef struct siginfo {
193#define FPE_FLTRES 6 /* floating point inexact result */ 219#define FPE_FLTRES 6 /* floating point inexact result */
194#define FPE_FLTINV 7 /* floating point invalid operation */ 220#define FPE_FLTINV 7 /* floating point invalid operation */
195#define FPE_FLTSUB 8 /* subscript out of range */ 221#define FPE_FLTSUB 8 /* subscript out of range */
196#define NSIGFPE 8 222#ifdef __frv__
223# define FPE_MDAOVF 9 /* media overflow */
224#endif
225#ifdef __ia64__
226# define __FPE_DECOVF 9 /* decimal overflow */
227# define __FPE_DECDIV 10 /* decimal division by zero */
228# define __FPE_DECERR 11 /* packed decimal error */
229# define __FPE_INVASC 12 /* invalid ASCII digit */
230# define __FPE_INVDEC 13 /* invalid decimal digit */
231#endif
232#define NSIGFPE 13
197 233
198/* 234/*
199 * SIGSEGV si_codes 235 * SIGSEGV si_codes
200 */ 236 */
201#define SEGV_MAPERR 1 /* address not mapped to object */ 237#define SEGV_MAPERR 1 /* address not mapped to object */
202#define SEGV_ACCERR 2 /* invalid permissions for mapped object */ 238#define SEGV_ACCERR 2 /* invalid permissions for mapped object */
203#define SEGV_BNDERR 3 /* failed address bound checks */ 239#ifdef __bfin__
204#define SEGV_PKUERR 4 /* failed protection key checks */ 240# define SEGV_STACKFLOW 3 /* stack overflow */
241#else
242# define SEGV_BNDERR 3 /* failed address bound checks */
243#endif
244#ifdef __ia64__
245# define __SEGV_PSTKOVF 4 /* paragraph stack overflow */
246#else
247# define SEGV_PKUERR 4 /* failed protection key checks */
248#endif
205#define NSIGSEGV 4 249#define NSIGSEGV 4
206 250
207/* 251/*
@@ -210,8 +254,12 @@ typedef struct siginfo {
210#define BUS_ADRALN 1 /* invalid address alignment */ 254#define BUS_ADRALN 1 /* invalid address alignment */
211#define BUS_ADRERR 2 /* non-existent physical address */ 255#define BUS_ADRERR 2 /* non-existent physical address */
212#define BUS_OBJERR 3 /* object specific hardware error */ 256#define BUS_OBJERR 3 /* object specific hardware error */
257#ifdef __bfin__
258# define BUS_OPFETCH 4 /* error from instruction fetch */
259#else
213/* hardware memory error consumed on a machine check: action required */ 260/* hardware memory error consumed on a machine check: action required */
214#define BUS_MCEERR_AR 4 261# define BUS_MCEERR_AR 4
262#endif
215/* hardware memory error detected in process but not consumed: action optional*/ 263/* hardware memory error detected in process but not consumed: action optional*/
216#define BUS_MCEERR_AO 5 264#define BUS_MCEERR_AO 5
217#define NSIGBUS 5 265#define NSIGBUS 5
@@ -223,9 +271,20 @@ typedef struct siginfo {
223#define TRAP_TRACE 2 /* process trace trap */ 271#define TRAP_TRACE 2 /* process trace trap */
224#define TRAP_BRANCH 3 /* process taken branch trap */ 272#define TRAP_BRANCH 3 /* process taken branch trap */
225#define TRAP_HWBKPT 4 /* hardware breakpoint/watchpoint */ 273#define TRAP_HWBKPT 4 /* hardware breakpoint/watchpoint */
274#ifdef __bfin__
275# define TRAP_STEP 1 /* single-step breakpoint */
276# define TRAP_TRACEFLOW 2 /* trace buffer overflow */
277# define TRAP_WATCHPT 3 /* watchpoint match */
278# define TRAP_ILLTRAP 4 /* illegal trap */
279#endif
226#define NSIGTRAP 4 280#define NSIGTRAP 4
227 281
228/* 282/*
283 * There are an additional set of SIGTRAP si_codes used by ptrace
284 * that of the form: ((PTRACE_EVENT_XXX << 8) | SIGTRAP)
285 */
286
287/*
229 * SIGCHLD si_codes 288 * SIGCHLD si_codes
230 */ 289 */
231#define CLD_EXITED 1 /* child has exited */ 290#define CLD_EXITED 1 /* child has exited */
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 9649ecd8a73a..17bc8b874d92 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -639,6 +639,7 @@ static void __do_notify(struct mqueue_inode_info *info)
639 case SIGEV_SIGNAL: 639 case SIGEV_SIGNAL:
640 /* sends signal */ 640 /* sends signal */
641 641
642 clear_siginfo(&sig_i);
642 sig_i.si_signo = info->notify.sigev_signo; 643 sig_i.si_signo = info->notify.sigev_signo;
643 sig_i.si_errno = 0; 644 sig_i.si_errno = 0;
644 sig_i.si_code = SI_MESGQ; 645 sig_i.si_code = SI_MESGQ;
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index c8146d53ca67..dbb0781a0533 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -2441,7 +2441,6 @@ static int kdb_kill(int argc, const char **argv)
2441 long sig, pid; 2441 long sig, pid;
2442 char *endp; 2442 char *endp;
2443 struct task_struct *p; 2443 struct task_struct *p;
2444 struct siginfo info;
2445 2444
2446 if (argc != 2) 2445 if (argc != 2)
2447 return KDB_ARGCOUNT; 2446 return KDB_ARGCOUNT;
@@ -2449,7 +2448,7 @@ static int kdb_kill(int argc, const char **argv)
2449 sig = simple_strtol(argv[1], &endp, 0); 2448 sig = simple_strtol(argv[1], &endp, 0);
2450 if (*endp) 2449 if (*endp)
2451 return KDB_BADINT; 2450 return KDB_BADINT;
2452 if (sig >= 0) { 2451 if ((sig >= 0) || !valid_signal(-sig)) {
2453 kdb_printf("Invalid signal parameter.<-signal>\n"); 2452 kdb_printf("Invalid signal parameter.<-signal>\n");
2454 return 0; 2453 return 0;
2455 } 2454 }
@@ -2470,12 +2469,7 @@ static int kdb_kill(int argc, const char **argv)
2470 return 0; 2469 return 0;
2471 } 2470 }
2472 p = p->group_leader; 2471 p = p->group_leader;
2473 info.si_signo = sig; 2472 kdb_send_sig(p, sig);
2474 info.si_errno = 0;
2475 info.si_code = SI_USER;
2476 info.si_pid = pid; /* same capabilities as process being signalled */
2477 info.si_uid = 0; /* kdb has root authority */
2478 kdb_send_sig_info(p, &info);
2479 return 0; 2473 return 0;
2480} 2474}
2481 2475
diff --git a/kernel/debug/kdb/kdb_private.h b/kernel/debug/kdb/kdb_private.h
index fc224fbcf954..1e5a502ba4a7 100644
--- a/kernel/debug/kdb/kdb_private.h
+++ b/kernel/debug/kdb/kdb_private.h
@@ -208,7 +208,7 @@ extern unsigned long kdb_task_state(const struct task_struct *p,
208extern void kdb_ps_suppressed(void); 208extern void kdb_ps_suppressed(void);
209extern void kdb_ps1(const struct task_struct *p); 209extern void kdb_ps1(const struct task_struct *p);
210extern void kdb_print_nameval(const char *name, unsigned long val); 210extern void kdb_print_nameval(const char *name, unsigned long val);
211extern void kdb_send_sig_info(struct task_struct *p, struct siginfo *info); 211extern void kdb_send_sig(struct task_struct *p, int sig);
212extern void kdb_meminfo_proc_show(void); 212extern void kdb_meminfo_proc_show(void);
213extern char *kdb_getstr(char *, size_t, const char *); 213extern char *kdb_getstr(char *, size_t, const char *);
214extern void kdb_gdb_state_pass(char *buf); 214extern void kdb_gdb_state_pass(char *buf);
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 84b1367935e4..f3c82e26b995 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -659,7 +659,7 @@ static int ptrace_getsiginfo(struct task_struct *child, siginfo_t *info)
659 if (lock_task_sighand(child, &flags)) { 659 if (lock_task_sighand(child, &flags)) {
660 error = -EINVAL; 660 error = -EINVAL;
661 if (likely(child->last_siginfo != NULL)) { 661 if (likely(child->last_siginfo != NULL)) {
662 *info = *child->last_siginfo; 662 copy_siginfo(info, child->last_siginfo);
663 error = 0; 663 error = 0;
664 } 664 }
665 unlock_task_sighand(child, &flags); 665 unlock_task_sighand(child, &flags);
@@ -675,7 +675,7 @@ static int ptrace_setsiginfo(struct task_struct *child, const siginfo_t *info)
675 if (lock_task_sighand(child, &flags)) { 675 if (lock_task_sighand(child, &flags)) {
676 error = -EINVAL; 676 error = -EINVAL;
677 if (likely(child->last_siginfo != NULL)) { 677 if (likely(child->last_siginfo != NULL)) {
678 *child->last_siginfo = *info; 678 copy_siginfo(child->last_siginfo, info);
679 error = 0; 679 error = 0;
680 } 680 }
681 unlock_task_sighand(child, &flags); 681 unlock_task_sighand(child, &flags);
@@ -1226,7 +1226,6 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
1226 break; 1226 break;
1227 1227
1228 case PTRACE_SETSIGINFO: 1228 case PTRACE_SETSIGINFO:
1229 memset(&siginfo, 0, sizeof siginfo);
1230 if (copy_siginfo_from_user32( 1229 if (copy_siginfo_from_user32(
1231 &siginfo, (struct compat_siginfo __user *) datap)) 1230 &siginfo, (struct compat_siginfo __user *) datap))
1232 ret = -EFAULT; 1231 ret = -EFAULT;
diff --git a/kernel/seccomp.c b/kernel/seccomp.c
index 5f0dfb2abb8d..3153c9ea51bf 100644
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -515,7 +515,7 @@ void put_seccomp_filter(struct task_struct *tsk)
515 515
516static void seccomp_init_siginfo(siginfo_t *info, int syscall, int reason) 516static void seccomp_init_siginfo(siginfo_t *info, int syscall, int reason)
517{ 517{
518 memset(info, 0, sizeof(*info)); 518 clear_siginfo(info);
519 info->si_signo = SIGSYS; 519 info->si_signo = SIGSYS;
520 info->si_code = SYS_SECCOMP; 520 info->si_code = SYS_SECCOMP;
521 info->si_call_addr = (void __user *)KSTK_EIP(current); 521 info->si_call_addr = (void __user *)KSTK_EIP(current);
diff --git a/kernel/signal.c b/kernel/signal.c
index 9558664bd9ec..e549174c0831 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -549,6 +549,7 @@ still_pending:
549 * a fast-pathed signal or we must have been 549 * a fast-pathed signal or we must have been
550 * out of queue space. So zero out the info. 550 * out of queue space. So zero out the info.
551 */ 551 */
552 clear_siginfo(info);
552 info->si_signo = sig; 553 info->si_signo = sig;
553 info->si_errno = 0; 554 info->si_errno = 0;
554 info->si_code = SI_USER; 555 info->si_code = SI_USER;
@@ -642,6 +643,9 @@ int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info)
642 spin_unlock(&tsk->sighand->siglock); 643 spin_unlock(&tsk->sighand->siglock);
643 posixtimer_rearm(info); 644 posixtimer_rearm(info);
644 spin_lock(&tsk->sighand->siglock); 645 spin_lock(&tsk->sighand->siglock);
646
647 /* Don't expose the si_sys_private value to userspace */
648 info->si_sys_private = 0;
645 } 649 }
646#endif 650#endif
647 return signr; 651 return signr;
@@ -1043,6 +1047,7 @@ static int __send_signal(int sig, struct siginfo *info, struct task_struct *t,
1043 list_add_tail(&q->list, &pending->list); 1047 list_add_tail(&q->list, &pending->list);
1044 switch ((unsigned long) info) { 1048 switch ((unsigned long) info) {
1045 case (unsigned long) SEND_SIG_NOINFO: 1049 case (unsigned long) SEND_SIG_NOINFO:
1050 clear_siginfo(&q->info);
1046 q->info.si_signo = sig; 1051 q->info.si_signo = sig;
1047 q->info.si_errno = 0; 1052 q->info.si_errno = 0;
1048 q->info.si_code = SI_USER; 1053 q->info.si_code = SI_USER;
@@ -1051,6 +1056,7 @@ static int __send_signal(int sig, struct siginfo *info, struct task_struct *t,
1051 q->info.si_uid = from_kuid_munged(current_user_ns(), current_uid()); 1056 q->info.si_uid = from_kuid_munged(current_user_ns(), current_uid());
1052 break; 1057 break;
1053 case (unsigned long) SEND_SIG_PRIV: 1058 case (unsigned long) SEND_SIG_PRIV:
1059 clear_siginfo(&q->info);
1054 q->info.si_signo = sig; 1060 q->info.si_signo = sig;
1055 q->info.si_errno = 0; 1061 q->info.si_errno = 0;
1056 q->info.si_code = SI_KERNEL; 1062 q->info.si_code = SI_KERNEL;
@@ -1485,6 +1491,129 @@ force_sigsegv(int sig, struct task_struct *p)
1485 return 0; 1491 return 0;
1486} 1492}
1487 1493
1494int force_sig_fault(int sig, int code, void __user *addr
1495 ___ARCH_SI_TRAPNO(int trapno)
1496 ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr)
1497 , struct task_struct *t)
1498{
1499 struct siginfo info;
1500
1501 clear_siginfo(&info);
1502 info.si_signo = sig;
1503 info.si_errno = 0;
1504 info.si_code = code;
1505 info.si_addr = addr;
1506#ifdef __ARCH_SI_TRAPNO
1507 info.si_trapno = trapno;
1508#endif
1509#ifdef __ia64__
1510 info.si_imm = imm;
1511 info.si_flags = flags;
1512 info.si_isr = isr;
1513#endif
1514 return force_sig_info(info.si_signo, &info, t);
1515}
1516
1517int send_sig_fault(int sig, int code, void __user *addr
1518 ___ARCH_SI_TRAPNO(int trapno)
1519 ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr)
1520 , struct task_struct *t)
1521{
1522 struct siginfo info;
1523
1524 clear_siginfo(&info);
1525 info.si_signo = sig;
1526 info.si_errno = 0;
1527 info.si_code = code;
1528 info.si_addr = addr;
1529#ifdef __ARCH_SI_TRAPNO
1530 info.si_trapno = trapno;
1531#endif
1532#ifdef __ia64__
1533 info.si_imm = imm;
1534 info.si_flags = flags;
1535 info.si_isr = isr;
1536#endif
1537 return send_sig_info(info.si_signo, &info, t);
1538}
1539
1540#if defined(BUS_MCEERR_AO) && defined(BUS_MCEERR_AR)
1541int force_sig_mceerr(int code, void __user *addr, short lsb, struct task_struct *t)
1542{
1543 struct siginfo info;
1544
1545 WARN_ON((code != BUS_MCEERR_AO) && (code != BUS_MCEERR_AR));
1546 clear_siginfo(&info);
1547 info.si_signo = SIGBUS;
1548 info.si_errno = 0;
1549 info.si_code = code;
1550 info.si_addr = addr;
1551 info.si_addr_lsb = lsb;
1552 return force_sig_info(info.si_signo, &info, t);
1553}
1554
1555int send_sig_mceerr(int code, void __user *addr, short lsb, struct task_struct *t)
1556{
1557 struct siginfo info;
1558
1559 WARN_ON((code != BUS_MCEERR_AO) && (code != BUS_MCEERR_AR));
1560 clear_siginfo(&info);
1561 info.si_signo = SIGBUS;
1562 info.si_errno = 0;
1563 info.si_code = code;
1564 info.si_addr = addr;
1565 info.si_addr_lsb = lsb;
1566 return send_sig_info(info.si_signo, &info, t);
1567}
1568EXPORT_SYMBOL(send_sig_mceerr);
1569#endif
1570
1571#ifdef SEGV_BNDERR
1572int force_sig_bnderr(void __user *addr, void __user *lower, void __user *upper)
1573{
1574 struct siginfo info;
1575
1576 clear_siginfo(&info);
1577 info.si_signo = SIGSEGV;
1578 info.si_errno = 0;
1579 info.si_code = SEGV_BNDERR;
1580 info.si_addr = addr;
1581 info.si_lower = lower;
1582 info.si_upper = upper;
1583 return force_sig_info(info.si_signo, &info, current);
1584}
1585#endif
1586
1587#ifdef SEGV_PKUERR
1588int force_sig_pkuerr(void __user *addr, u32 pkey)
1589{
1590 struct siginfo info;
1591
1592 clear_siginfo(&info);
1593 info.si_signo = SIGSEGV;
1594 info.si_errno = 0;
1595 info.si_code = SEGV_PKUERR;
1596 info.si_addr = addr;
1597 info.si_pkey = pkey;
1598 return force_sig_info(info.si_signo, &info, current);
1599}
1600#endif
1601
1602/* For the crazy architectures that include trap information in
1603 * the errno field, instead of an actual errno value.
1604 */
1605int force_sig_ptrace_errno_trap(int errno, void __user *addr)
1606{
1607 struct siginfo info;
1608
1609 clear_siginfo(&info);
1610 info.si_signo = SIGTRAP;
1611 info.si_errno = errno;
1612 info.si_code = TRAP_HWBKPT;
1613 info.si_addr = addr;
1614 return force_sig_info(info.si_signo, &info, current);
1615}
1616
1488int kill_pgrp(struct pid *pid, int sig, int priv) 1617int kill_pgrp(struct pid *pid, int sig, int priv)
1489{ 1618{
1490 int ret; 1619 int ret;
@@ -1623,6 +1752,7 @@ bool do_notify_parent(struct task_struct *tsk, int sig)
1623 sig = SIGCHLD; 1752 sig = SIGCHLD;
1624 } 1753 }
1625 1754
1755 clear_siginfo(&info);
1626 info.si_signo = sig; 1756 info.si_signo = sig;
1627 info.si_errno = 0; 1757 info.si_errno = 0;
1628 /* 1758 /*
@@ -1717,6 +1847,7 @@ static void do_notify_parent_cldstop(struct task_struct *tsk,
1717 parent = tsk->real_parent; 1847 parent = tsk->real_parent;
1718 } 1848 }
1719 1849
1850 clear_siginfo(&info);
1720 info.si_signo = SIGCHLD; 1851 info.si_signo = SIGCHLD;
1721 info.si_errno = 0; 1852 info.si_errno = 0;
1722 /* 1853 /*
@@ -1929,7 +2060,7 @@ static void ptrace_do_notify(int signr, int exit_code, int why)
1929{ 2060{
1930 siginfo_t info; 2061 siginfo_t info;
1931 2062
1932 memset(&info, 0, sizeof info); 2063 clear_siginfo(&info);
1933 info.si_signo = signr; 2064 info.si_signo = signr;
1934 info.si_code = exit_code; 2065 info.si_code = exit_code;
1935 info.si_pid = task_pid_vnr(current); 2066 info.si_pid = task_pid_vnr(current);
@@ -2136,6 +2267,7 @@ static int ptrace_signal(int signr, siginfo_t *info)
2136 * have updated *info via PTRACE_SETSIGINFO. 2267 * have updated *info via PTRACE_SETSIGINFO.
2137 */ 2268 */
2138 if (signr != info->si_signo) { 2269 if (signr != info->si_signo) {
2270 clear_siginfo(info);
2139 info->si_signo = signr; 2271 info->si_signo = signr;
2140 info->si_errno = 0; 2272 info->si_errno = 0;
2141 info->si_code = SI_USER; 2273 info->si_code = SI_USER;
@@ -2688,9 +2820,7 @@ enum siginfo_layout siginfo_layout(int sig, int si_code)
2688#endif 2820#endif
2689 [SIGCHLD] = { NSIGCHLD, SIL_CHLD }, 2821 [SIGCHLD] = { NSIGCHLD, SIL_CHLD },
2690 [SIGPOLL] = { NSIGPOLL, SIL_POLL }, 2822 [SIGPOLL] = { NSIGPOLL, SIL_POLL },
2691#ifdef __ARCH_SIGSYS
2692 [SIGSYS] = { NSIGSYS, SIL_SYS }, 2823 [SIGSYS] = { NSIGSYS, SIL_SYS },
2693#endif
2694 }; 2824 };
2695 if ((sig < ARRAY_SIZE(filter)) && (si_code <= filter[sig].limit)) 2825 if ((sig < ARRAY_SIZE(filter)) && (si_code <= filter[sig].limit))
2696 layout = filter[sig].layout; 2826 layout = filter[sig].layout;
@@ -2712,12 +2842,14 @@ enum siginfo_layout siginfo_layout(int sig, int si_code)
2712 if ((sig == SIGFPE) && (si_code == FPE_FIXME)) 2842 if ((sig == SIGFPE) && (si_code == FPE_FIXME))
2713 layout = SIL_FAULT; 2843 layout = SIL_FAULT;
2714#endif 2844#endif
2845#ifdef BUS_FIXME
2846 if ((sig == SIGBUS) && (si_code == BUS_FIXME))
2847 layout = SIL_FAULT;
2848#endif
2715 } 2849 }
2716 return layout; 2850 return layout;
2717} 2851}
2718 2852
2719#ifndef HAVE_ARCH_COPY_SIGINFO_TO_USER
2720
2721int copy_siginfo_to_user(siginfo_t __user *to, const siginfo_t *from) 2853int copy_siginfo_to_user(siginfo_t __user *to, const siginfo_t *from)
2722{ 2854{
2723 int err; 2855 int err;
@@ -2756,13 +2888,21 @@ int copy_siginfo_to_user(siginfo_t __user *to, const siginfo_t *from)
2756#ifdef __ARCH_SI_TRAPNO 2888#ifdef __ARCH_SI_TRAPNO
2757 err |= __put_user(from->si_trapno, &to->si_trapno); 2889 err |= __put_user(from->si_trapno, &to->si_trapno);
2758#endif 2890#endif
2759#ifdef BUS_MCEERR_AO 2891#ifdef __ia64__
2892 err |= __put_user(from->si_imm, &to->si_imm);
2893 err |= __put_user(from->si_flags, &to->si_flags);
2894 err |= __put_user(from->si_isr, &to->si_isr);
2895#endif
2760 /* 2896 /*
2761 * Other callers might not initialize the si_lsb field, 2897 * Other callers might not initialize the si_lsb field,
2762 * so check explicitly for the right codes here. 2898 * so check explicitly for the right codes here.
2763 */ 2899 */
2764 if (from->si_signo == SIGBUS && 2900#ifdef BUS_MCEERR_AR
2765 (from->si_code == BUS_MCEERR_AR || from->si_code == BUS_MCEERR_AO)) 2901 if (from->si_signo == SIGBUS && from->si_code == BUS_MCEERR_AR)
2902 err |= __put_user(from->si_addr_lsb, &to->si_addr_lsb);
2903#endif
2904#ifdef BUS_MCEERR_AO
2905 if (from->si_signo == SIGBUS && from->si_code == BUS_MCEERR_AO)
2766 err |= __put_user(from->si_addr_lsb, &to->si_addr_lsb); 2906 err |= __put_user(from->si_addr_lsb, &to->si_addr_lsb);
2767#endif 2907#endif
2768#ifdef SEGV_BNDERR 2908#ifdef SEGV_BNDERR
@@ -2788,18 +2928,185 @@ int copy_siginfo_to_user(siginfo_t __user *to, const siginfo_t *from)
2788 err |= __put_user(from->si_uid, &to->si_uid); 2928 err |= __put_user(from->si_uid, &to->si_uid);
2789 err |= __put_user(from->si_ptr, &to->si_ptr); 2929 err |= __put_user(from->si_ptr, &to->si_ptr);
2790 break; 2930 break;
2791#ifdef __ARCH_SIGSYS
2792 case SIL_SYS: 2931 case SIL_SYS:
2793 err |= __put_user(from->si_call_addr, &to->si_call_addr); 2932 err |= __put_user(from->si_call_addr, &to->si_call_addr);
2794 err |= __put_user(from->si_syscall, &to->si_syscall); 2933 err |= __put_user(from->si_syscall, &to->si_syscall);
2795 err |= __put_user(from->si_arch, &to->si_arch); 2934 err |= __put_user(from->si_arch, &to->si_arch);
2796 break; 2935 break;
2797#endif
2798 } 2936 }
2799 return err; 2937 return err;
2800} 2938}
2801 2939
2940#ifdef CONFIG_COMPAT
2941int copy_siginfo_to_user32(struct compat_siginfo __user *to,
2942 const struct siginfo *from)
2943#if defined(CONFIG_X86_X32_ABI) || defined(CONFIG_IA32_EMULATION)
2944{
2945 return __copy_siginfo_to_user32(to, from, in_x32_syscall());
2946}
2947int __copy_siginfo_to_user32(struct compat_siginfo __user *to,
2948 const struct siginfo *from, bool x32_ABI)
2949#endif
2950{
2951 struct compat_siginfo new;
2952 memset(&new, 0, sizeof(new));
2953
2954 new.si_signo = from->si_signo;
2955 new.si_errno = from->si_errno;
2956 new.si_code = from->si_code;
2957 switch(siginfo_layout(from->si_signo, from->si_code)) {
2958 case SIL_KILL:
2959 new.si_pid = from->si_pid;
2960 new.si_uid = from->si_uid;
2961 break;
2962 case SIL_TIMER:
2963 new.si_tid = from->si_tid;
2964 new.si_overrun = from->si_overrun;
2965 new.si_int = from->si_int;
2966 break;
2967 case SIL_POLL:
2968 new.si_band = from->si_band;
2969 new.si_fd = from->si_fd;
2970 break;
2971 case SIL_FAULT:
2972 new.si_addr = ptr_to_compat(from->si_addr);
2973#ifdef __ARCH_SI_TRAPNO
2974 new.si_trapno = from->si_trapno;
2975#endif
2976#ifdef BUS_MCEERR_AR
2977 if ((from->si_signo == SIGBUS) && (from->si_code == BUS_MCEERR_AR))
2978 new.si_addr_lsb = from->si_addr_lsb;
2979#endif
2980#ifdef BUS_MCEERR_AO
2981 if ((from->si_signo == SIGBUS) && (from->si_code == BUS_MCEERR_AO))
2982 new.si_addr_lsb = from->si_addr_lsb;
2983#endif
2984#ifdef SEGV_BNDERR
2985 if ((from->si_signo == SIGSEGV) &&
2986 (from->si_code == SEGV_BNDERR)) {
2987 new.si_lower = ptr_to_compat(from->si_lower);
2988 new.si_upper = ptr_to_compat(from->si_upper);
2989 }
2990#endif
2991#ifdef SEGV_PKUERR
2992 if ((from->si_signo == SIGSEGV) &&
2993 (from->si_code == SEGV_PKUERR))
2994 new.si_pkey = from->si_pkey;
2995#endif
2996
2997 break;
2998 case SIL_CHLD:
2999 new.si_pid = from->si_pid;
3000 new.si_uid = from->si_uid;
3001 new.si_status = from->si_status;
3002#ifdef CONFIG_X86_X32_ABI
3003 if (x32_ABI) {
3004 new._sifields._sigchld_x32._utime = from->si_utime;
3005 new._sifields._sigchld_x32._stime = from->si_stime;
3006 } else
3007#endif
3008 {
3009 new.si_utime = from->si_utime;
3010 new.si_stime = from->si_stime;
3011 }
3012 break;
3013 case SIL_RT:
3014 new.si_pid = from->si_pid;
3015 new.si_uid = from->si_uid;
3016 new.si_int = from->si_int;
3017 break;
3018 case SIL_SYS:
3019 new.si_call_addr = ptr_to_compat(from->si_call_addr);
3020 new.si_syscall = from->si_syscall;
3021 new.si_arch = from->si_arch;
3022 break;
3023 }
3024
3025 if (copy_to_user(to, &new, sizeof(struct compat_siginfo)))
3026 return -EFAULT;
3027
3028 return 0;
3029}
3030
3031int copy_siginfo_from_user32(struct siginfo *to,
3032 const struct compat_siginfo __user *ufrom)
3033{
3034 struct compat_siginfo from;
3035
3036 if (copy_from_user(&from, ufrom, sizeof(struct compat_siginfo)))
3037 return -EFAULT;
3038
3039 clear_siginfo(to);
3040 to->si_signo = from.si_signo;
3041 to->si_errno = from.si_errno;
3042 to->si_code = from.si_code;
3043 switch(siginfo_layout(from.si_signo, from.si_code)) {
3044 case SIL_KILL:
3045 to->si_pid = from.si_pid;
3046 to->si_uid = from.si_uid;
3047 break;
3048 case SIL_TIMER:
3049 to->si_tid = from.si_tid;
3050 to->si_overrun = from.si_overrun;
3051 to->si_int = from.si_int;
3052 break;
3053 case SIL_POLL:
3054 to->si_band = from.si_band;
3055 to->si_fd = from.si_fd;
3056 break;
3057 case SIL_FAULT:
3058 to->si_addr = compat_ptr(from.si_addr);
3059#ifdef __ARCH_SI_TRAPNO
3060 to->si_trapno = from.si_trapno;
3061#endif
3062#ifdef BUS_MCEERR_AR
3063 if ((from.si_signo == SIGBUS) && (from.si_code == BUS_MCEERR_AR))
3064 to->si_addr_lsb = from.si_addr_lsb;
3065#endif
3066#ifdef BUS_MCEER_AO
3067 if ((from.si_signo == SIGBUS) && (from.si_code == BUS_MCEERR_AO))
3068 to->si_addr_lsb = from.si_addr_lsb;
3069#endif
3070#ifdef SEGV_BNDERR
3071 if ((from.si_signo == SIGSEGV) && (from.si_code == SEGV_BNDERR)) {
3072 to->si_lower = compat_ptr(from.si_lower);
3073 to->si_upper = compat_ptr(from.si_upper);
3074 }
3075#endif
3076#ifdef SEGV_PKUERR
3077 if ((from.si_signo == SIGSEGV) && (from.si_code == SEGV_PKUERR))
3078 to->si_pkey = from.si_pkey;
3079#endif
3080 break;
3081 case SIL_CHLD:
3082 to->si_pid = from.si_pid;
3083 to->si_uid = from.si_uid;
3084 to->si_status = from.si_status;
3085#ifdef CONFIG_X86_X32_ABI
3086 if (in_x32_syscall()) {
3087 to->si_utime = from._sifields._sigchld_x32._utime;
3088 to->si_stime = from._sifields._sigchld_x32._stime;
3089 } else
2802#endif 3090#endif
3091 {
3092 to->si_utime = from.si_utime;
3093 to->si_stime = from.si_stime;
3094 }
3095 break;
3096 case SIL_RT:
3097 to->si_pid = from.si_pid;
3098 to->si_uid = from.si_uid;
3099 to->si_int = from.si_int;
3100 break;
3101 case SIL_SYS:
3102 to->si_call_addr = compat_ptr(from.si_call_addr);
3103 to->si_syscall = from.si_syscall;
3104 to->si_arch = from.si_arch;
3105 break;
3106 }
3107 return 0;
3108}
3109#endif /* CONFIG_COMPAT */
2803 3110
2804/** 3111/**
2805 * do_sigtimedwait - wait for queued signals specified in @which 3112 * do_sigtimedwait - wait for queued signals specified in @which
@@ -2937,6 +3244,7 @@ SYSCALL_DEFINE2(kill, pid_t, pid, int, sig)
2937{ 3244{
2938 struct siginfo info; 3245 struct siginfo info;
2939 3246
3247 clear_siginfo(&info);
2940 info.si_signo = sig; 3248 info.si_signo = sig;
2941 info.si_errno = 0; 3249 info.si_errno = 0;
2942 info.si_code = SI_USER; 3250 info.si_code = SI_USER;
@@ -2978,8 +3286,9 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
2978 3286
2979static int do_tkill(pid_t tgid, pid_t pid, int sig) 3287static int do_tkill(pid_t tgid, pid_t pid, int sig)
2980{ 3288{
2981 struct siginfo info = {}; 3289 struct siginfo info;
2982 3290
3291 clear_siginfo(&info);
2983 info.si_signo = sig; 3292 info.si_signo = sig;
2984 info.si_errno = 0; 3293 info.si_errno = 0;
2985 info.si_code = SI_TKILL; 3294 info.si_code = SI_TKILL;
@@ -3060,7 +3369,7 @@ COMPAT_SYSCALL_DEFINE3(rt_sigqueueinfo,
3060 int, sig, 3369 int, sig,
3061 struct compat_siginfo __user *, uinfo) 3370 struct compat_siginfo __user *, uinfo)
3062{ 3371{
3063 siginfo_t info = {}; 3372 siginfo_t info;
3064 int ret = copy_siginfo_from_user32(&info, uinfo); 3373 int ret = copy_siginfo_from_user32(&info, uinfo);
3065 if (unlikely(ret)) 3374 if (unlikely(ret))
3066 return ret; 3375 return ret;
@@ -3104,7 +3413,7 @@ COMPAT_SYSCALL_DEFINE4(rt_tgsigqueueinfo,
3104 int, sig, 3413 int, sig,
3105 struct compat_siginfo __user *, uinfo) 3414 struct compat_siginfo __user *, uinfo)
3106{ 3415{
3107 siginfo_t info = {}; 3416 siginfo_t info;
3108 3417
3109 if (copy_siginfo_from_user32(&info, uinfo)) 3418 if (copy_siginfo_from_user32(&info, uinfo))
3110 return -EFAULT; 3419 return -EFAULT;
@@ -3677,6 +3986,7 @@ void __init signals_init(void)
3677 /* If this check fails, the __ARCH_SI_PREAMBLE_SIZE value is wrong! */ 3986 /* If this check fails, the __ARCH_SI_PREAMBLE_SIZE value is wrong! */
3678 BUILD_BUG_ON(__ARCH_SI_PREAMBLE_SIZE 3987 BUILD_BUG_ON(__ARCH_SI_PREAMBLE_SIZE
3679 != offsetof(struct siginfo, _sifields._pad)); 3988 != offsetof(struct siginfo, _sifields._pad));
3989 BUILD_BUG_ON(sizeof(struct siginfo) != SI_MAX_SIZE);
3680 3990
3681 sigqueue_cachep = KMEM_CACHE(sigqueue, SLAB_PANIC); 3991 sigqueue_cachep = KMEM_CACHE(sigqueue, SLAB_PANIC);
3682} 3992}
@@ -3684,26 +3994,25 @@ void __init signals_init(void)
3684#ifdef CONFIG_KGDB_KDB 3994#ifdef CONFIG_KGDB_KDB
3685#include <linux/kdb.h> 3995#include <linux/kdb.h>
3686/* 3996/*
3687 * kdb_send_sig_info - Allows kdb to send signals without exposing 3997 * kdb_send_sig - Allows kdb to send signals without exposing
3688 * signal internals. This function checks if the required locks are 3998 * signal internals. This function checks if the required locks are
3689 * available before calling the main signal code, to avoid kdb 3999 * available before calling the main signal code, to avoid kdb
3690 * deadlocks. 4000 * deadlocks.
3691 */ 4001 */
3692void 4002void kdb_send_sig(struct task_struct *t, int sig)
3693kdb_send_sig_info(struct task_struct *t, struct siginfo *info)
3694{ 4003{
3695 static struct task_struct *kdb_prev_t; 4004 static struct task_struct *kdb_prev_t;
3696 int sig, new_t; 4005 int new_t, ret;
3697 if (!spin_trylock(&t->sighand->siglock)) { 4006 if (!spin_trylock(&t->sighand->siglock)) {
3698 kdb_printf("Can't do kill command now.\n" 4007 kdb_printf("Can't do kill command now.\n"
3699 "The sigmask lock is held somewhere else in " 4008 "The sigmask lock is held somewhere else in "
3700 "kernel, try again later\n"); 4009 "kernel, try again later\n");
3701 return; 4010 return;
3702 } 4011 }
3703 spin_unlock(&t->sighand->siglock);
3704 new_t = kdb_prev_t != t; 4012 new_t = kdb_prev_t != t;
3705 kdb_prev_t = t; 4013 kdb_prev_t = t;
3706 if (t->state != TASK_RUNNING && new_t) { 4014 if (t->state != TASK_RUNNING && new_t) {
4015 spin_unlock(&t->sighand->siglock);
3707 kdb_printf("Process is not RUNNING, sending a signal from " 4016 kdb_printf("Process is not RUNNING, sending a signal from "
3708 "kdb risks deadlock\n" 4017 "kdb risks deadlock\n"
3709 "on the run queue locks. " 4018 "on the run queue locks. "
@@ -3712,8 +4021,9 @@ kdb_send_sig_info(struct task_struct *t, struct siginfo *info)
3712 "the deadlock.\n"); 4021 "the deadlock.\n");
3713 return; 4022 return;
3714 } 4023 }
3715 sig = info->si_signo; 4024 ret = send_signal(sig, SEND_SIG_PRIV, t, false);
3716 if (send_sig_info(sig, info, t)) 4025 spin_unlock(&t->sighand->siglock);
4026 if (ret)
3717 kdb_printf("Fail to deliver Signal %d to process %d.\n", 4027 kdb_printf("Fail to deliver Signal %d to process %d.\n",
3718 sig, t->pid); 4028 sig, t->pid);
3719 else 4029 else
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index ec999f32c840..75043046914e 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -462,7 +462,7 @@ static struct k_itimer * alloc_posix_timer(void)
462 kmem_cache_free(posix_timers_cache, tmr); 462 kmem_cache_free(posix_timers_cache, tmr);
463 return NULL; 463 return NULL;
464 } 464 }
465 memset(&tmr->sigq->info, 0, sizeof(siginfo_t)); 465 clear_siginfo(&tmr->sigq->info);
466 return tmr; 466 return tmr;
467} 467}
468 468
diff --git a/mm/hwpoison-inject.c b/mm/hwpoison-inject.c
index 356df057a2a8..b6ac70616c32 100644
--- a/mm/hwpoison-inject.c
+++ b/mm/hwpoison-inject.c
@@ -52,7 +52,7 @@ static int hwpoison_inject(void *data, u64 val)
52 52
53inject: 53inject:
54 pr_info("Injecting memory failure at pfn %#lx\n", pfn); 54 pr_info("Injecting memory failure at pfn %#lx\n", pfn);
55 return memory_failure(pfn, 18, MF_COUNT_INCREASED); 55 return memory_failure(pfn, MF_COUNT_INCREASED);
56put_out: 56put_out:
57 put_hwpoison_page(p); 57 put_hwpoison_page(p);
58 return 0; 58 return 0;
diff --git a/mm/madvise.c b/mm/madvise.c
index 751e97aa2210..4d3c922ea1a1 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -661,7 +661,7 @@ static int madvise_inject_error(int behavior,
661 pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n", 661 pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n",
662 page_to_pfn(page), start); 662 page_to_pfn(page), start);
663 663
664 ret = memory_failure(page_to_pfn(page), 0, MF_COUNT_INCREASED); 664 ret = memory_failure(page_to_pfn(page), MF_COUNT_INCREASED);
665 if (ret) 665 if (ret)
666 return ret; 666 return ret;
667 } 667 }
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 4acdf393a801..4b80ccee4535 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -178,25 +178,19 @@ EXPORT_SYMBOL_GPL(hwpoison_filter);
178 * ``action optional'' if they are not immediately affected by the error 178 * ``action optional'' if they are not immediately affected by the error
179 * ``action required'' if error happened in current execution context 179 * ``action required'' if error happened in current execution context
180 */ 180 */
181static int kill_proc(struct task_struct *t, unsigned long addr, int trapno, 181static int kill_proc(struct task_struct *t, unsigned long addr,
182 unsigned long pfn, struct page *page, int flags) 182 unsigned long pfn, struct page *page, int flags)
183{ 183{
184 struct siginfo si; 184 short addr_lsb;
185 int ret; 185 int ret;
186 186
187 pr_err("Memory failure: %#lx: Killing %s:%d due to hardware memory corruption\n", 187 pr_err("Memory failure: %#lx: Killing %s:%d due to hardware memory corruption\n",
188 pfn, t->comm, t->pid); 188 pfn, t->comm, t->pid);
189 si.si_signo = SIGBUS; 189 addr_lsb = compound_order(compound_head(page)) + PAGE_SHIFT;
190 si.si_errno = 0;
191 si.si_addr = (void *)addr;
192#ifdef __ARCH_SI_TRAPNO
193 si.si_trapno = trapno;
194#endif
195 si.si_addr_lsb = compound_order(compound_head(page)) + PAGE_SHIFT;
196 190
197 if ((flags & MF_ACTION_REQUIRED) && t->mm == current->mm) { 191 if ((flags & MF_ACTION_REQUIRED) && t->mm == current->mm) {
198 si.si_code = BUS_MCEERR_AR; 192 ret = force_sig_mceerr(BUS_MCEERR_AR, (void __user *)addr,
199 ret = force_sig_info(SIGBUS, &si, current); 193 addr_lsb, current);
200 } else { 194 } else {
201 /* 195 /*
202 * Don't use force here, it's convenient if the signal 196 * Don't use force here, it's convenient if the signal
@@ -204,8 +198,8 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
204 * This could cause a loop when the user sets SIGBUS 198 * This could cause a loop when the user sets SIGBUS
205 * to SIG_IGN, but hopefully no one will do that? 199 * to SIG_IGN, but hopefully no one will do that?
206 */ 200 */
207 si.si_code = BUS_MCEERR_AO; 201 ret = send_sig_mceerr(BUS_MCEERR_AO, (void __user *)addr,
208 ret = send_sig_info(SIGBUS, &si, t); /* synchronous? */ 202 addr_lsb, t); /* synchronous? */
209 } 203 }
210 if (ret < 0) 204 if (ret < 0)
211 pr_info("Memory failure: Error sending signal to %s:%d: %d\n", 205 pr_info("Memory failure: Error sending signal to %s:%d: %d\n",
@@ -323,7 +317,7 @@ static void add_to_kill(struct task_struct *tsk, struct page *p,
323 * Also when FAIL is set do a force kill because something went 317 * Also when FAIL is set do a force kill because something went
324 * wrong earlier. 318 * wrong earlier.
325 */ 319 */
326static void kill_procs(struct list_head *to_kill, int forcekill, int trapno, 320static void kill_procs(struct list_head *to_kill, int forcekill,
327 bool fail, struct page *page, unsigned long pfn, 321 bool fail, struct page *page, unsigned long pfn,
328 int flags) 322 int flags)
329{ 323{
@@ -348,7 +342,7 @@ static void kill_procs(struct list_head *to_kill, int forcekill, int trapno,
348 * check for that, but we need to tell the 342 * check for that, but we need to tell the
349 * process anyways. 343 * process anyways.
350 */ 344 */
351 else if (kill_proc(tk->tsk, tk->addr, trapno, 345 else if (kill_proc(tk->tsk, tk->addr,
352 pfn, page, flags) < 0) 346 pfn, page, flags) < 0)
353 pr_err("Memory failure: %#lx: Cannot send advisory machine check signal to %s:%d\n", 347 pr_err("Memory failure: %#lx: Cannot send advisory machine check signal to %s:%d\n",
354 pfn, tk->tsk->comm, tk->tsk->pid); 348 pfn, tk->tsk->comm, tk->tsk->pid);
@@ -927,7 +921,7 @@ EXPORT_SYMBOL_GPL(get_hwpoison_page);
927 * the pages and send SIGBUS to the processes if the data was dirty. 921 * the pages and send SIGBUS to the processes if the data was dirty.
928 */ 922 */
929static bool hwpoison_user_mappings(struct page *p, unsigned long pfn, 923static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
930 int trapno, int flags, struct page **hpagep) 924 int flags, struct page **hpagep)
931{ 925{
932 enum ttu_flags ttu = TTU_IGNORE_MLOCK | TTU_IGNORE_ACCESS; 926 enum ttu_flags ttu = TTU_IGNORE_MLOCK | TTU_IGNORE_ACCESS;
933 struct address_space *mapping; 927 struct address_space *mapping;
@@ -1017,7 +1011,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
1017 * any accesses to the poisoned memory. 1011 * any accesses to the poisoned memory.
1018 */ 1012 */
1019 forcekill = PageDirty(hpage) || (flags & MF_MUST_KILL); 1013 forcekill = PageDirty(hpage) || (flags & MF_MUST_KILL);
1020 kill_procs(&tokill, forcekill, trapno, !unmap_success, p, pfn, flags); 1014 kill_procs(&tokill, forcekill, !unmap_success, p, pfn, flags);
1021 1015
1022 return unmap_success; 1016 return unmap_success;
1023} 1017}
@@ -1045,7 +1039,7 @@ static int identify_page_state(unsigned long pfn, struct page *p,
1045 return page_action(ps, p, pfn); 1039 return page_action(ps, p, pfn);
1046} 1040}
1047 1041
1048static int memory_failure_hugetlb(unsigned long pfn, int trapno, int flags) 1042static int memory_failure_hugetlb(unsigned long pfn, int flags)
1049{ 1043{
1050 struct page *p = pfn_to_page(pfn); 1044 struct page *p = pfn_to_page(pfn);
1051 struct page *head = compound_head(p); 1045 struct page *head = compound_head(p);
@@ -1090,7 +1084,7 @@ static int memory_failure_hugetlb(unsigned long pfn, int trapno, int flags)
1090 return 0; 1084 return 0;
1091 } 1085 }
1092 1086
1093 if (!hwpoison_user_mappings(p, pfn, trapno, flags, &head)) { 1087 if (!hwpoison_user_mappings(p, pfn, flags, &head)) {
1094 action_result(pfn, MF_MSG_UNMAP_FAILED, MF_IGNORED); 1088 action_result(pfn, MF_MSG_UNMAP_FAILED, MF_IGNORED);
1095 res = -EBUSY; 1089 res = -EBUSY;
1096 goto out; 1090 goto out;
@@ -1105,7 +1099,6 @@ out:
1105/** 1099/**
1106 * memory_failure - Handle memory failure of a page. 1100 * memory_failure - Handle memory failure of a page.
1107 * @pfn: Page Number of the corrupted page 1101 * @pfn: Page Number of the corrupted page
1108 * @trapno: Trap number reported in the signal to user space.
1109 * @flags: fine tune action taken 1102 * @flags: fine tune action taken
1110 * 1103 *
1111 * This function is called by the low level machine check code 1104 * This function is called by the low level machine check code
@@ -1120,7 +1113,7 @@ out:
1120 * Must run in process context (e.g. a work queue) with interrupts 1113 * Must run in process context (e.g. a work queue) with interrupts
1121 * enabled and no spinlocks hold. 1114 * enabled and no spinlocks hold.
1122 */ 1115 */
1123int memory_failure(unsigned long pfn, int trapno, int flags) 1116int memory_failure(unsigned long pfn, int flags)
1124{ 1117{
1125 struct page *p; 1118 struct page *p;
1126 struct page *hpage; 1119 struct page *hpage;
@@ -1129,7 +1122,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
1129 unsigned long page_flags; 1122 unsigned long page_flags;
1130 1123
1131 if (!sysctl_memory_failure_recovery) 1124 if (!sysctl_memory_failure_recovery)
1132 panic("Memory failure from trap %d on page %lx", trapno, pfn); 1125 panic("Memory failure on page %lx", pfn);
1133 1126
1134 if (!pfn_valid(pfn)) { 1127 if (!pfn_valid(pfn)) {
1135 pr_err("Memory failure: %#lx: memory outside kernel control\n", 1128 pr_err("Memory failure: %#lx: memory outside kernel control\n",
@@ -1139,7 +1132,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
1139 1132
1140 p = pfn_to_page(pfn); 1133 p = pfn_to_page(pfn);
1141 if (PageHuge(p)) 1134 if (PageHuge(p))
1142 return memory_failure_hugetlb(pfn, trapno, flags); 1135 return memory_failure_hugetlb(pfn, flags);
1143 if (TestSetPageHWPoison(p)) { 1136 if (TestSetPageHWPoison(p)) {
1144 pr_err("Memory failure: %#lx: already hardware poisoned\n", 1137 pr_err("Memory failure: %#lx: already hardware poisoned\n",
1145 pfn); 1138 pfn);
@@ -1268,7 +1261,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
1268 * When the raw error page is thp tail page, hpage points to the raw 1261 * When the raw error page is thp tail page, hpage points to the raw
1269 * page after thp split. 1262 * page after thp split.
1270 */ 1263 */
1271 if (!hwpoison_user_mappings(p, pfn, trapno, flags, &hpage)) { 1264 if (!hwpoison_user_mappings(p, pfn, flags, &hpage)) {
1272 action_result(pfn, MF_MSG_UNMAP_FAILED, MF_IGNORED); 1265 action_result(pfn, MF_MSG_UNMAP_FAILED, MF_IGNORED);
1273 res = -EBUSY; 1266 res = -EBUSY;
1274 goto out; 1267 goto out;
@@ -1296,7 +1289,6 @@ EXPORT_SYMBOL_GPL(memory_failure);
1296 1289
1297struct memory_failure_entry { 1290struct memory_failure_entry {
1298 unsigned long pfn; 1291 unsigned long pfn;
1299 int trapno;
1300 int flags; 1292 int flags;
1301}; 1293};
1302 1294
@@ -1312,7 +1304,6 @@ static DEFINE_PER_CPU(struct memory_failure_cpu, memory_failure_cpu);
1312/** 1304/**
1313 * memory_failure_queue - Schedule handling memory failure of a page. 1305 * memory_failure_queue - Schedule handling memory failure of a page.
1314 * @pfn: Page Number of the corrupted page 1306 * @pfn: Page Number of the corrupted page
1315 * @trapno: Trap number reported in the signal to user space.
1316 * @flags: Flags for memory failure handling 1307 * @flags: Flags for memory failure handling
1317 * 1308 *
1318 * This function is called by the low level hardware error handler 1309 * This function is called by the low level hardware error handler
@@ -1326,13 +1317,12 @@ static DEFINE_PER_CPU(struct memory_failure_cpu, memory_failure_cpu);
1326 * 1317 *
1327 * Can run in IRQ context. 1318 * Can run in IRQ context.
1328 */ 1319 */
1329void memory_failure_queue(unsigned long pfn, int trapno, int flags) 1320void memory_failure_queue(unsigned long pfn, int flags)
1330{ 1321{
1331 struct memory_failure_cpu *mf_cpu; 1322 struct memory_failure_cpu *mf_cpu;
1332 unsigned long proc_flags; 1323 unsigned long proc_flags;
1333 struct memory_failure_entry entry = { 1324 struct memory_failure_entry entry = {
1334 .pfn = pfn, 1325 .pfn = pfn,
1335 .trapno = trapno,
1336 .flags = flags, 1326 .flags = flags,
1337 }; 1327 };
1338 1328
@@ -1365,7 +1355,7 @@ static void memory_failure_work_func(struct work_struct *work)
1365 if (entry.flags & MF_SOFT_OFFLINE) 1355 if (entry.flags & MF_SOFT_OFFLINE)
1366 soft_offline_page(pfn_to_page(entry.pfn), entry.flags); 1356 soft_offline_page(pfn_to_page(entry.pfn), entry.flags);
1367 else 1357 else
1368 memory_failure(entry.pfn, entry.trapno, entry.flags); 1358 memory_failure(entry.pfn, entry.flags);
1369 } 1359 }
1370} 1360}
1371 1361