History

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 ...

Linus Torvalds committed 8 years ago

Commit d4173022 parents 0aebc6a c0f455576 files · +855 −1808Browse files

Showing the changes to include/uapi (1 of 76 files). Show all

Unified · Split

include/uapi/asm-generic/siginfo.h+84−25
@@ -23,10 +23,6 @@ typedef union sigval { · 22 unmodified lines
2323 #define SI_PAD_SIZE ((SI_MAX_SIZE - __ARCH_SI_PREAMBLE_SIZE) / sizeof(int))
2424 #endif
2525
26−#ifndef __ARCH_SI_UID_T
27−#define __ARCH_SI_UID_T __kernel_uid32_t
28−#endif
29−
3026 /*
3127 * The default "si_band" type is "long", as specified by POSIX.
3228 * However, some architectures want to override this to "int"
@@ -44,12 +40,15 @@ typedef union sigval { · 11 unmodified lines
4440 #define __ARCH_SI_ATTRIBUTES
4541 #endif
4642
47−#ifndef HAVE_ARCH_SIGINFO_T
48−
4943 typedef struct siginfo {
5044 int si_signo;
45+#ifndef __ARCH_HAS_SWAPPED_SIGINFO
5146 int si_errno;
5247 int si_code;
48+#else
49+ int si_code;
50+ int si_errno;
51+#endif
5352
5453 union {
5554 int _pad[SI_PAD_SIZE];
@@ -57,14 +56,13 @@ typedef struct siginfo { · 1 unmodified line
5756 /* kill() */
5857 struct {
5958 __kernel_pid_t _pid; /* sender's pid */
60− __ARCH_SI_UID_T _uid; /* sender's uid */
59+ __kernel_uid32_t _uid; /* sender's uid */
6160 } _kill;
6261
6362 /* POSIX.1b timers */
6463 struct {
6564 __kernel_timer_t _tid; /* timer id */
6665 int _overrun; /* overrun count */
67− char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)];
6866 sigval_t _sigval; /* same as below */
6967 int _sys_private; /* not to be passed to user */
7068 } _timer;
@@ -72,34 +70,47 @@ typedef struct siginfo { · 1 unmodified line
7270 /* POSIX.1b signals */
7371 struct {
7472 __kernel_pid_t _pid; /* sender's pid */
75− __ARCH_SI_UID_T _uid; /* sender's uid */
73+ __kernel_uid32_t _uid; /* sender's uid */
7674 sigval_t _sigval;
7775 } _rt;
7876
7977 /* SIGCHLD */
8078 struct {
8179 __kernel_pid_t _pid; /* which child */
82− __ARCH_SI_UID_T _uid; /* sender's uid */
80+ __kernel_uid32_t _uid; /* sender's uid */
8381 int _status; /* exit code */
8482 __ARCH_SI_CLOCK_T _utime;
8583 __ARCH_SI_CLOCK_T _stime;
8684 } _sigchld;
8785
88− /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
86+ /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGTRAP, SIGEMT */
8987 struct {
9088 void __user *_addr; /* faulting insn/memory ref. */
9189 #ifdef __ARCH_SI_TRAPNO
9290 int _trapno; /* TRAP # which caused the signal */
9391 #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
9597 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 */
96103 /* used when si_code=SEGV_BNDERR */
97104 struct {
105+ short _dummy_bnd;
98106 void __user *_lower;
99107 void __user *_upper;
100108 } _addr_bnd;
101109 /* used when si_code=SEGV_PKUERR */
102− __u32 _pkey;
110+ struct {
111+ short _dummy_pkey;
112+ __u32 _pkey;
113+ } _addr_pkey;
103114 };
104115 } _sigfault;
105116
@@ -118,10 +129,6 @@ typedef struct siginfo { · 12 unmodified lines
118129 } _sifields;
119130 } __ARCH_SI_ATTRIBUTES siginfo_t;
120131
121−/* If the arch shares siginfo, then it has SIGSYS. */
122−#define __ARCH_SIGSYS
123−#endif
124−
125132 /*
126133 * How these fields are to be accessed.
127134 */
@@ -143,14 +150,12 @@ typedef struct siginfo { · 15 unmodified lines
143150 #define si_addr_lsb _sifields._sigfault._addr_lsb
144151 #define si_lower _sifields._sigfault._addr_bnd._lower
145152 #define si_upper _sifields._sigfault._addr_bnd._upper
146−#define si_pkey _sifields._sigfault._pkey
153+#define si_pkey _sifields._sigfault._addr_pkey._pkey
147154 #define si_band _sifields._sigpoll._band
148155 #define si_fd _sifields._sigpoll._fd
149−#ifdef __ARCH_SIGSYS
150156 #define si_call_addr _sifields._sigsys._call_addr
151157 #define si_syscall _sifields._sigsys._syscall
152158 #define si_arch _sifields._sigsys._arch
153−#endif
154159
155160 /*
156161 * si_code values
@@ -165,6 +170,7 @@ typedef struct siginfo { · 8 unmodified lines
165170 #define SI_SIGIO -5 /* sent by queued SIGIO */
166171 #define SI_TKILL -6 /* sent by tkill system call */
167172 #define SI_DETHREAD -7 /* sent by execve() killing subsidiary threads */
173+#define SI_ASYNCNL -60 /* sent by glibc async name lookup completion */
168174
169175 #define SI_FROMUSER(siptr) ((siptr)->si_code <= 0)
170176 #define SI_FROMKERNEL(siptr) ((siptr)->si_code > 0)
@@ -173,14 +179,34 @@ typedef struct siginfo { · 2 unmodified lines
173179 * SIGILL si_codes
174180 */
175181 #define ILL_ILLOPC 1 /* illegal opcode */
182+#ifdef __bfin__
183+# define ILL_ILLPARAOP 2 /* illegal opcode combine */
184+#endif
176185 #define ILL_ILLOPN 2 /* illegal operand */
177186 #define ILL_ILLADR 3 /* illegal addressing mode */
178187 #define ILL_ILLTRP 4 /* illegal trap */
188+#ifdef __bfin__
189+# define ILL_ILLEXCPT 4 /* unrecoverable exception */
190+#endif
179191 #define ILL_PRVOPC 5 /* privileged opcode */
180192 #define ILL_PRVREG 6 /* privileged register */
181193 #define ILL_COPROC 7 /* coprocessor error */
182194 #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
184210
185211 /*
186212 * SIGFPE si_codes
@@ -193,15 +219,33 @@ typedef struct siginfo { · 6 unmodified lines
193219 #define FPE_FLTRES 6 /* floating point inexact result */
194220 #define FPE_FLTINV 7 /* floating point invalid operation */
195221 #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
197233
198234 /*
199235 * SIGSEGV si_codes
200236 */
201237 #define SEGV_MAPERR 1 /* address not mapped to object */
202238 #define SEGV_ACCERR 2 /* invalid permissions for mapped object */
203−#define SEGV_BNDERR 3 /* failed address bound checks */
204−#define SEGV_PKUERR 4 /* failed protection key checks */
239+#ifdef __bfin__
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
205249 #define NSIGSEGV 4
206250
207251 /*
@@ -210,8 +254,12 @@ typedef struct siginfo { · 2 unmodified lines
210254 #define BUS_ADRALN 1 /* invalid address alignment */
211255 #define BUS_ADRERR 2 /* non-existent physical address */
212256 #define BUS_OBJERR 3 /* object specific hardware error */
257+#ifdef __bfin__
258+# define BUS_OPFETCH 4 /* error from instruction fetch */
259+#else
213260 /* hardware memory error consumed on a machine check: action required */
214−#define BUS_MCEERR_AR 4
261+# define BUS_MCEERR_AR 4
262+#endif
215263 /* hardware memory error detected in process but not consumed: action optional*/
216264 #define BUS_MCEERR_AO 5
217265 #define NSIGBUS 5
@@ -223,8 +271,19 @@ typedef struct siginfo { · 5 unmodified lines
223271 #define TRAP_TRACE 2 /* process trace trap */
224272 #define TRAP_BRANCH 3 /* process taken branch trap */
225273 #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
226280 #define NSIGTRAP 4
227281
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+
228287 /*
229288 * SIGCHLD si_codes
230289 */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t