This source file includes following definitions.
- signal_compat_build_tests
- sigaction_compat_abi
1
2 #include <linux/compat.h>
3 #include <linux/uaccess.h>
4 #include <linux/ptrace.h>
5
6
7
8
9
10
11
12
13
14
15
16
17
18 static inline void signal_compat_build_tests(void)
19 {
20 int _sifields_offset = offsetof(compat_siginfo_t, _sifields);
21
22
23
24
25
26
27
28 BUILD_BUG_ON(NSIGILL != 11);
29 BUILD_BUG_ON(NSIGFPE != 15);
30 BUILD_BUG_ON(NSIGSEGV != 7);
31 BUILD_BUG_ON(NSIGBUS != 5);
32 BUILD_BUG_ON(NSIGTRAP != 5);
33 BUILD_BUG_ON(NSIGCHLD != 6);
34 BUILD_BUG_ON(NSIGSYS != 1);
35
36
37 BUILD_BUG_ON(sizeof(compat_siginfo_t) != 128);
38
39
40
41
42
43 BUILD_BUG_ON(offsetof(compat_siginfo_t, _sifields) != 3 * sizeof(int));
44 #define CHECK_CSI_OFFSET(name) BUILD_BUG_ON(_sifields_offset != offsetof(compat_siginfo_t, _sifields.name))
45
46 BUILD_BUG_ON(offsetof(siginfo_t, si_signo) != 0);
47 BUILD_BUG_ON(offsetof(siginfo_t, si_errno) != 4);
48 BUILD_BUG_ON(offsetof(siginfo_t, si_code) != 8);
49
50 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_signo) != 0);
51 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_errno) != 4);
52 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_code) != 8);
53
54
55
56
57
58
59
60
61
62
63
64
65
66 #define CHECK_CSI_SIZE(name, size) BUILD_BUG_ON(size != sizeof(((compat_siginfo_t *)0)->_sifields.name))
67 #define CHECK_SI_SIZE(name, size) BUILD_BUG_ON(size != sizeof(((siginfo_t *)0)->_sifields.name))
68
69 CHECK_CSI_OFFSET(_kill);
70 CHECK_CSI_SIZE (_kill, 2*sizeof(int));
71 CHECK_SI_SIZE (_kill, 2*sizeof(int));
72
73 BUILD_BUG_ON(offsetof(siginfo_t, si_pid) != 0x10);
74 BUILD_BUG_ON(offsetof(siginfo_t, si_uid) != 0x14);
75 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_pid) != 0xC);
76 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_uid) != 0x10);
77
78 CHECK_CSI_OFFSET(_timer);
79 CHECK_CSI_SIZE (_timer, 3*sizeof(int));
80 CHECK_SI_SIZE (_timer, 6*sizeof(int));
81
82 BUILD_BUG_ON(offsetof(siginfo_t, si_tid) != 0x10);
83 BUILD_BUG_ON(offsetof(siginfo_t, si_overrun) != 0x14);
84 BUILD_BUG_ON(offsetof(siginfo_t, si_value) != 0x18);
85 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_tid) != 0x0C);
86 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_overrun) != 0x10);
87 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_value) != 0x14);
88
89 CHECK_CSI_OFFSET(_rt);
90 CHECK_CSI_SIZE (_rt, 3*sizeof(int));
91 CHECK_SI_SIZE (_rt, 4*sizeof(int));
92
93 BUILD_BUG_ON(offsetof(siginfo_t, si_pid) != 0x10);
94 BUILD_BUG_ON(offsetof(siginfo_t, si_uid) != 0x14);
95 BUILD_BUG_ON(offsetof(siginfo_t, si_value) != 0x18);
96 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_pid) != 0x0C);
97 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_uid) != 0x10);
98 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_value) != 0x14);
99
100 CHECK_CSI_OFFSET(_sigchld);
101 CHECK_CSI_SIZE (_sigchld, 5*sizeof(int));
102 CHECK_SI_SIZE (_sigchld, 8*sizeof(int));
103
104 BUILD_BUG_ON(offsetof(siginfo_t, si_pid) != 0x10);
105 BUILD_BUG_ON(offsetof(siginfo_t, si_uid) != 0x14);
106 BUILD_BUG_ON(offsetof(siginfo_t, si_status) != 0x18);
107 BUILD_BUG_ON(offsetof(siginfo_t, si_utime) != 0x20);
108 BUILD_BUG_ON(offsetof(siginfo_t, si_stime) != 0x28);
109 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_pid) != 0x0C);
110 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_uid) != 0x10);
111 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_status) != 0x14);
112 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_utime) != 0x18);
113 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_stime) != 0x1C);
114
115 #ifdef CONFIG_X86_X32_ABI
116 CHECK_CSI_OFFSET(_sigchld_x32);
117 CHECK_CSI_SIZE (_sigchld_x32, 7*sizeof(int));
118
119 BUILD_BUG_ON(offsetof(compat_siginfo_t, _sifields._sigchld_x32._utime) != 0x18);
120 BUILD_BUG_ON(offsetof(compat_siginfo_t, _sifields._sigchld_x32._stime) != 0x20);
121 #endif
122
123 CHECK_CSI_OFFSET(_sigfault);
124 CHECK_CSI_SIZE (_sigfault, 4*sizeof(int));
125 CHECK_SI_SIZE (_sigfault, 8*sizeof(int));
126
127 BUILD_BUG_ON(offsetof(siginfo_t, si_addr) != 0x10);
128 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_addr) != 0x0C);
129
130 BUILD_BUG_ON(offsetof(siginfo_t, si_addr_lsb) != 0x18);
131 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_addr_lsb) != 0x10);
132
133 BUILD_BUG_ON(offsetof(siginfo_t, si_lower) != 0x20);
134 BUILD_BUG_ON(offsetof(siginfo_t, si_upper) != 0x28);
135 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_lower) != 0x14);
136 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_upper) != 0x18);
137
138 BUILD_BUG_ON(offsetof(siginfo_t, si_pkey) != 0x20);
139 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_pkey) != 0x14);
140
141 CHECK_CSI_OFFSET(_sigpoll);
142 CHECK_CSI_SIZE (_sigpoll, 2*sizeof(int));
143 CHECK_SI_SIZE (_sigpoll, 4*sizeof(int));
144
145 BUILD_BUG_ON(offsetof(siginfo_t, si_band) != 0x10);
146 BUILD_BUG_ON(offsetof(siginfo_t, si_fd) != 0x18);
147 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_band) != 0x0C);
148 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_fd) != 0x10);
149
150 CHECK_CSI_OFFSET(_sigsys);
151 CHECK_CSI_SIZE (_sigsys, 3*sizeof(int));
152 CHECK_SI_SIZE (_sigsys, 4*sizeof(int));
153
154 BUILD_BUG_ON(offsetof(siginfo_t, si_call_addr) != 0x10);
155 BUILD_BUG_ON(offsetof(siginfo_t, si_syscall) != 0x18);
156 BUILD_BUG_ON(offsetof(siginfo_t, si_arch) != 0x1C);
157 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_call_addr) != 0x0C);
158 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_syscall) != 0x10);
159 BUILD_BUG_ON(offsetof(compat_siginfo_t, si_arch) != 0x14);
160
161
162 }
163
164 void sigaction_compat_abi(struct k_sigaction *act, struct k_sigaction *oact)
165 {
166 signal_compat_build_tests();
167
168
169 if (oact)
170 oact->sa.sa_flags &= ~(SA_IA32_ABI | SA_X32_ABI);
171
172 if (!act)
173 return;
174
175
176 act->sa.sa_flags &= ~(SA_IA32_ABI | SA_X32_ABI);
177
178 if (in_ia32_syscall())
179 act->sa.sa_flags |= SA_IA32_ABI;
180 if (in_x32_syscall())
181 act->sa.sa_flags |= SA_X32_ABI;
182 }