aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2018-04-18 18:48:49 -0400
committerEric W. Biederman <ebiederm@xmission.com>2018-10-03 10:46:43 -0400
commitf28380185193610c716a90ec9b9e696638a495ce (patch)
treef7fc4d228bb2e51a4be7833c68f49607b57198cc
parente75dc036c445b91b8b2ad4e6c9b05f04b6be6d3f (diff)
signal: Remove the need for __ARCH_SI_PREABLE_SIZE and SI_PAD_SIZE
Rework the defintion of struct siginfo so that the array padding struct siginfo to SI_MAX_SIZE can be placed in a union along side of the rest of the struct siginfo members. The result is that we no longer need the __ARCH_SI_PREAMBLE_SIZE or SI_PAD_SIZE definitions. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
-rw-r--r--arch/alpha/include/uapi/asm/siginfo.h1
-rw-r--r--arch/arm64/include/uapi/asm/Kbuild1
-rw-r--r--arch/arm64/include/uapi/asm/siginfo.h24
-rw-r--r--arch/ia64/include/uapi/asm/siginfo.h2
-rw-r--r--arch/mips/include/uapi/asm/siginfo.h11
-rw-r--r--arch/parisc/include/uapi/asm/Kbuild1
-rw-r--r--arch/parisc/include/uapi/asm/siginfo.h11
-rw-r--r--arch/powerpc/include/uapi/asm/Kbuild1
-rw-r--r--arch/powerpc/include/uapi/asm/siginfo.h18
-rw-r--r--arch/riscv/include/uapi/asm/Kbuild1
-rw-r--r--arch/riscv/include/uapi/asm/siginfo.h24
-rw-r--r--arch/s390/include/uapi/asm/Kbuild1
-rw-r--r--arch/s390/include/uapi/asm/siginfo.h17
-rw-r--r--arch/sparc/include/uapi/asm/siginfo.h1
-rw-r--r--arch/x86/include/uapi/asm/siginfo.h2
-rw-r--r--include/uapi/asm-generic/siginfo.h187
-rw-r--r--kernel/signal.c3
17 files changed, 99 insertions, 207 deletions
diff --git a/arch/alpha/include/uapi/asm/siginfo.h b/arch/alpha/include/uapi/asm/siginfo.h
index db3f0138536f..6e1a2af2f962 100644
--- a/arch/alpha/include/uapi/asm/siginfo.h
+++ b/arch/alpha/include/uapi/asm/siginfo.h
@@ -2,7 +2,6 @@
2#ifndef _ALPHA_SIGINFO_H 2#ifndef _ALPHA_SIGINFO_H
3#define _ALPHA_SIGINFO_H 3#define _ALPHA_SIGINFO_H
4 4
5#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
6#define __ARCH_SI_TRAPNO 5#define __ARCH_SI_TRAPNO
7 6
8#include <asm-generic/siginfo.h> 7#include <asm-generic/siginfo.h>
diff --git a/arch/arm64/include/uapi/asm/Kbuild b/arch/arm64/include/uapi/asm/Kbuild
index 198afbf0688f..6c5adf458690 100644
--- a/arch/arm64/include/uapi/asm/Kbuild
+++ b/arch/arm64/include/uapi/asm/Kbuild
@@ -19,3 +19,4 @@ generic-y += swab.h
19generic-y += termbits.h 19generic-y += termbits.h
20generic-y += termios.h 20generic-y += termios.h
21generic-y += types.h 21generic-y += types.h
22generic-y += siginfo.h
diff --git a/arch/arm64/include/uapi/asm/siginfo.h b/arch/arm64/include/uapi/asm/siginfo.h
deleted file mode 100644
index 574d12f86039..000000000000
--- a/arch/arm64/include/uapi/asm/siginfo.h
+++ /dev/null
@@ -1,24 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2/*
3 * Copyright (C) 2012 ARM Ltd.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17#ifndef __ASM_SIGINFO_H
18#define __ASM_SIGINFO_H
19
20#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
21
22#include <asm-generic/siginfo.h>
23
24#endif
diff --git a/arch/ia64/include/uapi/asm/siginfo.h b/arch/ia64/include/uapi/asm/siginfo.h
index 52b5af424511..796af1ccaa7e 100644
--- a/arch/ia64/include/uapi/asm/siginfo.h
+++ b/arch/ia64/include/uapi/asm/siginfo.h
@@ -9,8 +9,6 @@
9#define _UAPI_ASM_IA64_SIGINFO_H 9#define _UAPI_ASM_IA64_SIGINFO_H
10 10
11 11
12#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
13
14#include <asm-generic/siginfo.h> 12#include <asm-generic/siginfo.h>
15 13
16#define si_imm _sifields._sigfault._imm /* as per UNIX SysV ABI spec */ 14#define si_imm _sifields._sigfault._imm /* as per UNIX SysV ABI spec */
diff --git a/arch/mips/include/uapi/asm/siginfo.h b/arch/mips/include/uapi/asm/siginfo.h
index 262504bd59a5..c34c7eef0a1c 100644
--- a/arch/mips/include/uapi/asm/siginfo.h
+++ b/arch/mips/include/uapi/asm/siginfo.h
@@ -14,17 +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/*
18 * Careful to keep union _sifields from shifting ...
19 */
20#if _MIPS_SZLONG == 32
21#define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int))
22#elif _MIPS_SZLONG == 64
23#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
24#else
25#error _MIPS_SZLONG neither 32 nor 64
26#endif
27
28#define __ARCH_HAS_SWAPPED_SIGINFO 17#define __ARCH_HAS_SWAPPED_SIGINFO
29 18
30#include <asm-generic/siginfo.h> 19#include <asm-generic/siginfo.h>
diff --git a/arch/parisc/include/uapi/asm/Kbuild b/arch/parisc/include/uapi/asm/Kbuild
index 286ef5a5904b..adb5c64831c7 100644
--- a/arch/parisc/include/uapi/asm/Kbuild
+++ b/arch/parisc/include/uapi/asm/Kbuild
@@ -7,3 +7,4 @@ generic-y += kvm_para.h
7generic-y += param.h 7generic-y += param.h
8generic-y += poll.h 8generic-y += poll.h
9generic-y += resource.h 9generic-y += resource.h
10generic-y += siginfo.h
diff --git a/arch/parisc/include/uapi/asm/siginfo.h b/arch/parisc/include/uapi/asm/siginfo.h
deleted file mode 100644
index 4a1062e05aaf..000000000000
--- a/arch/parisc/include/uapi/asm/siginfo.h
+++ /dev/null
@@ -1,11 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2#ifndef _PARISC_SIGINFO_H
3#define _PARISC_SIGINFO_H
4
5#if defined(__LP64__)
6#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
7#endif
8
9#include <asm-generic/siginfo.h>
10
11#endif
diff --git a/arch/powerpc/include/uapi/asm/Kbuild b/arch/powerpc/include/uapi/asm/Kbuild
index 1a6ed5919ffd..a658091a19f9 100644
--- a/arch/powerpc/include/uapi/asm/Kbuild
+++ b/arch/powerpc/include/uapi/asm/Kbuild
@@ -7,3 +7,4 @@ generic-y += poll.h
7generic-y += resource.h 7generic-y += resource.h
8generic-y += sockios.h 8generic-y += sockios.h
9generic-y += statfs.h 9generic-y += statfs.h
10generic-y += siginfo.h
diff --git a/arch/powerpc/include/uapi/asm/siginfo.h b/arch/powerpc/include/uapi/asm/siginfo.h
deleted file mode 100644
index 1d51d9b88221..000000000000
--- a/arch/powerpc/include/uapi/asm/siginfo.h
+++ /dev/null
@@ -1,18 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2#ifndef _ASM_POWERPC_SIGINFO_H
3#define _ASM_POWERPC_SIGINFO_H
4
5/*
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifdef __powerpc64__
13# define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
14#endif
15
16#include <asm-generic/siginfo.h>
17
18#endif /* _ASM_POWERPC_SIGINFO_H */
diff --git a/arch/riscv/include/uapi/asm/Kbuild b/arch/riscv/include/uapi/asm/Kbuild
index 7e91f4850475..5511b9918131 100644
--- a/arch/riscv/include/uapi/asm/Kbuild
+++ b/arch/riscv/include/uapi/asm/Kbuild
@@ -26,3 +26,4 @@ generic-y += swab.h
26generic-y += termbits.h 26generic-y += termbits.h
27generic-y += termios.h 27generic-y += termios.h
28generic-y += types.h 28generic-y += types.h
29generic-y += siginfo.h
diff --git a/arch/riscv/include/uapi/asm/siginfo.h b/arch/riscv/include/uapi/asm/siginfo.h
deleted file mode 100644
index f96849aac662..000000000000
--- a/arch/riscv/include/uapi/asm/siginfo.h
+++ /dev/null
@@ -1,24 +0,0 @@
1/*
2 * Copyright (C) 2012 ARM Ltd.
3 * Copyright (C) 2016 SiFive, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17#ifndef __ASM_SIGINFO_H
18#define __ASM_SIGINFO_H
19
20#define __ARCH_SI_PREAMBLE_SIZE (__SIZEOF_POINTER__ == 4 ? 12 : 16)
21
22#include <asm-generic/siginfo.h>
23
24#endif
diff --git a/arch/s390/include/uapi/asm/Kbuild b/arch/s390/include/uapi/asm/Kbuild
index e364873e0d10..dc38a90cf091 100644
--- a/arch/s390/include/uapi/asm/Kbuild
+++ b/arch/s390/include/uapi/asm/Kbuild
@@ -18,3 +18,4 @@ generic-y += shmbuf.h
18generic-y += sockios.h 18generic-y += sockios.h
19generic-y += swab.h 19generic-y += swab.h
20generic-y += termbits.h 20generic-y += termbits.h
21generic-y += siginfo.h \ No newline at end of file
diff --git a/arch/s390/include/uapi/asm/siginfo.h b/arch/s390/include/uapi/asm/siginfo.h
deleted file mode 100644
index 6984820f2f1c..000000000000
--- a/arch/s390/include/uapi/asm/siginfo.h
+++ /dev/null
@@ -1,17 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2/*
3 * S390 version
4 *
5 * Derived from "include/asm-i386/siginfo.h"
6 */
7
8#ifndef _S390_SIGINFO_H
9#define _S390_SIGINFO_H
10
11#ifdef __s390x__
12#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
13#endif
14
15#include <asm-generic/siginfo.h>
16
17#endif
diff --git a/arch/sparc/include/uapi/asm/siginfo.h b/arch/sparc/include/uapi/asm/siginfo.h
index 6c820ea0813b..68bdde4c2a2e 100644
--- a/arch/sparc/include/uapi/asm/siginfo.h
+++ b/arch/sparc/include/uapi/asm/siginfo.h
@@ -4,7 +4,6 @@
4 4
5#if defined(__sparc__) && defined(__arch64__) 5#if defined(__sparc__) && defined(__arch64__)
6 6
7#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
8#define __ARCH_SI_BAND_T int 7#define __ARCH_SI_BAND_T int
9 8
10#endif /* defined(__sparc__) && defined(__arch64__) */ 9#endif /* defined(__sparc__) && defined(__arch64__) */
diff --git a/arch/x86/include/uapi/asm/siginfo.h b/arch/x86/include/uapi/asm/siginfo.h
index b3d157957177..6642d8be40c4 100644
--- a/arch/x86/include/uapi/asm/siginfo.h
+++ b/arch/x86/include/uapi/asm/siginfo.h
@@ -7,8 +7,6 @@
7typedef long long __kernel_si_clock_t __attribute__((aligned(4))); 7typedef long long __kernel_si_clock_t __attribute__((aligned(4)));
8# define __ARCH_SI_CLOCK_T __kernel_si_clock_t 8# define __ARCH_SI_CLOCK_T __kernel_si_clock_t
9# define __ARCH_SI_ATTRIBUTES __attribute__((aligned(8))) 9# define __ARCH_SI_ATTRIBUTES __attribute__((aligned(8)))
10# else /* x86-64 */
11# define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
12# endif 10# endif
13#endif 11#endif
14 12
diff --git a/include/uapi/asm-generic/siginfo.h b/include/uapi/asm-generic/siginfo.h
index 1811b8101937..cb3d6c267181 100644
--- a/include/uapi/asm-generic/siginfo.h
+++ b/include/uapi/asm-generic/siginfo.h
@@ -10,18 +10,7 @@ typedef union sigval {
10 void __user *sival_ptr; 10 void __user *sival_ptr;
11} sigval_t; 11} sigval_t;
12 12
13/*
14 * This is the size (including padding) of the part of the
15 * struct siginfo that is before the union.
16 */
17#ifndef __ARCH_SI_PREAMBLE_SIZE
18#define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int))
19#endif
20
21#define SI_MAX_SIZE 128 13#define SI_MAX_SIZE 128
22#ifndef SI_PAD_SIZE
23#define SI_PAD_SIZE ((SI_MAX_SIZE - __ARCH_SI_PREAMBLE_SIZE) / sizeof(int))
24#endif
25 14
26/* 15/*
27 * The default "si_band" type is "long", as specified by POSIX. 16 * The default "si_band" type is "long", as specified by POSIX.
@@ -40,96 +29,108 @@ typedef union sigval {
40#define __ARCH_SI_ATTRIBUTES 29#define __ARCH_SI_ATTRIBUTES
41#endif 30#endif
42 31
43typedef struct siginfo { 32union __sifields {
44 int si_signo; 33 /* kill() */
45#ifndef __ARCH_HAS_SWAPPED_SIGINFO 34 struct {
46 int si_errno; 35 __kernel_pid_t _pid; /* sender's pid */
47 int si_code; 36 __kernel_uid32_t _uid; /* sender's uid */
48#else 37 } _kill;
49 int si_code; 38
50 int si_errno; 39 /* POSIX.1b timers */
51#endif 40 struct {
52 41 __kernel_timer_t _tid; /* timer id */
53 union { 42 int _overrun; /* overrun count */
54 int _pad[SI_PAD_SIZE]; 43 sigval_t _sigval; /* same as below */
55 44 int _sys_private; /* not to be passed to user */
56 /* kill() */ 45 } _timer;
57 struct { 46
58 __kernel_pid_t _pid; /* sender's pid */ 47 /* POSIX.1b signals */
59 __kernel_uid32_t _uid; /* sender's uid */ 48 struct {
60 } _kill; 49 __kernel_pid_t _pid; /* sender's pid */
61 50 __kernel_uid32_t _uid; /* sender's uid */
62 /* POSIX.1b timers */ 51 sigval_t _sigval;
63 struct { 52 } _rt;
64 __kernel_timer_t _tid; /* timer id */ 53
65 int _overrun; /* overrun count */ 54 /* SIGCHLD */
66 sigval_t _sigval; /* same as below */ 55 struct {
67 int _sys_private; /* not to be passed to user */ 56 __kernel_pid_t _pid; /* which child */
68 } _timer; 57 __kernel_uid32_t _uid; /* sender's uid */
69 58 int _status; /* exit code */
70 /* POSIX.1b signals */ 59 __ARCH_SI_CLOCK_T _utime;
71 struct { 60 __ARCH_SI_CLOCK_T _stime;
72 __kernel_pid_t _pid; /* sender's pid */ 61 } _sigchld;
73 __kernel_uid32_t _uid; /* sender's uid */ 62
74 sigval_t _sigval; 63 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGTRAP, SIGEMT */
75 } _rt; 64 struct {
76 65 void __user *_addr; /* faulting insn/memory ref. */
77 /* SIGCHLD */
78 struct {
79 __kernel_pid_t _pid; /* which child */
80 __kernel_uid32_t _uid; /* sender's uid */
81 int _status; /* exit code */
82 __ARCH_SI_CLOCK_T _utime;
83 __ARCH_SI_CLOCK_T _stime;
84 } _sigchld;
85
86 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGTRAP, SIGEMT */
87 struct {
88 void __user *_addr; /* faulting insn/memory ref. */
89#ifdef __ARCH_SI_TRAPNO 66#ifdef __ARCH_SI_TRAPNO
90 int _trapno; /* TRAP # which caused the signal */ 67 int _trapno; /* TRAP # which caused the signal */
91#endif 68#endif
92#ifdef __ia64__ 69#ifdef __ia64__
93 int _imm; /* immediate value for "break" */ 70 int _imm; /* immediate value for "break" */
94 unsigned int _flags; /* see ia64 si_flags */ 71 unsigned int _flags; /* see ia64 si_flags */
95 unsigned long _isr; /* isr */ 72 unsigned long _isr; /* isr */
96#endif 73#endif
97 74
98#define __ADDR_BND_PKEY_PAD (__alignof__(void *) < sizeof(short) ? \ 75#define __ADDR_BND_PKEY_PAD (__alignof__(void *) < sizeof(short) ? \
99 sizeof(short) : __alignof__(void *)) 76 sizeof(short) : __alignof__(void *))
100 union { 77 union {
101 /* 78 /*
102 * used when si_code=BUS_MCEERR_AR or 79 * used when si_code=BUS_MCEERR_AR or
103 * used when si_code=BUS_MCEERR_AO 80 * used when si_code=BUS_MCEERR_AO
104 */ 81 */
105 short _addr_lsb; /* LSB of the reported address */ 82 short _addr_lsb; /* LSB of the reported address */
106 /* used when si_code=SEGV_BNDERR */ 83 /* used when si_code=SEGV_BNDERR */
107 struct { 84 struct {
108 char _dummy_bnd[__ADDR_BND_PKEY_PAD]; 85 char _dummy_bnd[__ADDR_BND_PKEY_PAD];
109 void __user *_lower; 86 void __user *_lower;
110 void __user *_upper; 87 void __user *_upper;
111 } _addr_bnd; 88 } _addr_bnd;
112 /* used when si_code=SEGV_PKUERR */ 89 /* used when si_code=SEGV_PKUERR */
113 struct { 90 struct {
114 char _dummy_pkey[__ADDR_BND_PKEY_PAD]; 91 char _dummy_pkey[__ADDR_BND_PKEY_PAD];
115 __u32 _pkey; 92 __u32 _pkey;
116 } _addr_pkey; 93 } _addr_pkey;
117 }; 94 };
118 } _sigfault; 95 } _sigfault;
119 96
120 /* SIGPOLL */ 97 /* SIGPOLL */
121 struct { 98 struct {
122 __ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */ 99 __ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */
123 int _fd; 100 int _fd;
124 } _sigpoll; 101 } _sigpoll;
102
103 /* SIGSYS */
104 struct {
105 void __user *_call_addr; /* calling user insn */
106 int _syscall; /* triggering system call number */
107 unsigned int _arch; /* AUDIT_ARCH_* of syscall */
108 } _sigsys;
109};
125 110
126 /* SIGSYS */ 111#ifndef __ARCH_HAS_SWAPPED_SIGINFO
127 struct { 112#define __SIGINFO \
128 void __user *_call_addr; /* calling user insn */ 113struct { \
129 int _syscall; /* triggering system call number */ 114 int si_signo; \
130 unsigned int _arch; /* AUDIT_ARCH_* of syscall */ 115 int si_errno; \
131 } _sigsys; 116 int si_code; \
132 } _sifields; 117 union __sifields _sifields; \
118}
119#else
120#define __SIGINFO \
121struct { \
122 int si_signo; \
123 int si_code; \
124 int si_errno; \
125 union __sifields _sifields; \
126}
127#endif /* __ARCH_HAS_SWAPPED_SIGINFO */
128
129typedef struct siginfo {
130 union {
131 __SIGINFO;
132 int _si_pad[SI_MAX_SIZE/sizeof(int)];
133 };
133} __ARCH_SI_ATTRIBUTES siginfo_t; 134} __ARCH_SI_ATTRIBUTES siginfo_t;
134 135
135/* 136/*
diff --git a/kernel/signal.c b/kernel/signal.c
index e445b0a63faa..debb485a76db 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -3963,9 +3963,6 @@ __weak const char *arch_vma_name(struct vm_area_struct *vma)
3963 3963
3964void __init signals_init(void) 3964void __init signals_init(void)
3965{ 3965{
3966 /* If this check fails, the __ARCH_SI_PREAMBLE_SIZE value is wrong! */
3967 BUILD_BUG_ON(__ARCH_SI_PREAMBLE_SIZE
3968 != offsetof(struct siginfo, _sifields._pad));
3969 BUILD_BUG_ON(sizeof(struct siginfo) != SI_MAX_SIZE); 3966 BUILD_BUG_ON(sizeof(struct siginfo) != SI_MAX_SIZE);
3970 3967
3971 sigqueue_cachep = KMEM_CACHE(sigqueue, SLAB_PANIC); 3968 sigqueue_cachep = KMEM_CACHE(sigqueue, SLAB_PANIC);