|
21 | 21 | #include <asm/switch_to.h>
|
22 | 22 | #include <asm/debug.h>
|
23 | 23 |
|
24 |
| -#define CREATE_TRACE_POINTS |
25 |
| -#include <trace/events/syscalls.h> |
26 |
| - |
27 | 24 | #include "ptrace-decl.h"
|
28 | 25 |
|
29 | 26 | /*
|
@@ -195,144 +192,6 @@ long arch_ptrace(struct task_struct *child, long request,
|
195 | 192 | return ret;
|
196 | 193 | }
|
197 | 194 |
|
198 |
| -#ifdef CONFIG_SECCOMP |
199 |
| -static int do_seccomp(struct pt_regs *regs) |
200 |
| -{ |
201 |
| - if (!test_thread_flag(TIF_SECCOMP)) |
202 |
| - return 0; |
203 |
| - |
204 |
| - /* |
205 |
| - * The ABI we present to seccomp tracers is that r3 contains |
206 |
| - * the syscall return value and orig_gpr3 contains the first |
207 |
| - * syscall parameter. This is different to the ptrace ABI where |
208 |
| - * both r3 and orig_gpr3 contain the first syscall parameter. |
209 |
| - */ |
210 |
| - regs->gpr[3] = -ENOSYS; |
211 |
| - |
212 |
| - /* |
213 |
| - * We use the __ version here because we have already checked |
214 |
| - * TIF_SECCOMP. If this fails, there is nothing left to do, we |
215 |
| - * have already loaded -ENOSYS into r3, or seccomp has put |
216 |
| - * something else in r3 (via SECCOMP_RET_ERRNO/TRACE). |
217 |
| - */ |
218 |
| - if (__secure_computing(NULL)) |
219 |
| - return -1; |
220 |
| - |
221 |
| - /* |
222 |
| - * The syscall was allowed by seccomp, restore the register |
223 |
| - * state to what audit expects. |
224 |
| - * Note that we use orig_gpr3, which means a seccomp tracer can |
225 |
| - * modify the first syscall parameter (in orig_gpr3) and also |
226 |
| - * allow the syscall to proceed. |
227 |
| - */ |
228 |
| - regs->gpr[3] = regs->orig_gpr3; |
229 |
| - |
230 |
| - return 0; |
231 |
| -} |
232 |
| -#else |
233 |
| -static inline int do_seccomp(struct pt_regs *regs) { return 0; } |
234 |
| -#endif /* CONFIG_SECCOMP */ |
235 |
| - |
236 |
| -/** |
237 |
| - * do_syscall_trace_enter() - Do syscall tracing on kernel entry. |
238 |
| - * @regs: the pt_regs of the task to trace (current) |
239 |
| - * |
240 |
| - * Performs various types of tracing on syscall entry. This includes seccomp, |
241 |
| - * ptrace, syscall tracepoints and audit. |
242 |
| - * |
243 |
| - * The pt_regs are potentially visible to userspace via ptrace, so their |
244 |
| - * contents is ABI. |
245 |
| - * |
246 |
| - * One or more of the tracers may modify the contents of pt_regs, in particular |
247 |
| - * to modify arguments or even the syscall number itself. |
248 |
| - * |
249 |
| - * It's also possible that a tracer can choose to reject the system call. In |
250 |
| - * that case this function will return an illegal syscall number, and will put |
251 |
| - * an appropriate return value in regs->r3. |
252 |
| - * |
253 |
| - * Return: the (possibly changed) syscall number. |
254 |
| - */ |
255 |
| -long do_syscall_trace_enter(struct pt_regs *regs) |
256 |
| -{ |
257 |
| - u32 flags; |
258 |
| - |
259 |
| - flags = read_thread_flags() & (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE); |
260 |
| - |
261 |
| - if (flags) { |
262 |
| - int rc = ptrace_report_syscall_entry(regs); |
263 |
| - |
264 |
| - if (unlikely(flags & _TIF_SYSCALL_EMU)) { |
265 |
| - /* |
266 |
| - * A nonzero return code from |
267 |
| - * ptrace_report_syscall_entry() tells us to prevent |
268 |
| - * the syscall execution, but we are not going to |
269 |
| - * execute it anyway. |
270 |
| - * |
271 |
| - * Returning -1 will skip the syscall execution. We want |
272 |
| - * to avoid clobbering any registers, so we don't goto |
273 |
| - * the skip label below. |
274 |
| - */ |
275 |
| - return -1; |
276 |
| - } |
277 |
| - |
278 |
| - if (rc) { |
279 |
| - /* |
280 |
| - * The tracer decided to abort the syscall. Note that |
281 |
| - * the tracer may also just change regs->gpr[0] to an |
282 |
| - * invalid syscall number, that is handled below on the |
283 |
| - * exit path. |
284 |
| - */ |
285 |
| - goto skip; |
286 |
| - } |
287 |
| - } |
288 |
| - |
289 |
| - /* Run seccomp after ptrace; allow it to set gpr[3]. */ |
290 |
| - if (do_seccomp(regs)) |
291 |
| - return -1; |
292 |
| - |
293 |
| - /* Avoid trace and audit when syscall is invalid. */ |
294 |
| - if (regs->gpr[0] >= NR_syscalls) |
295 |
| - goto skip; |
296 |
| - |
297 |
| - if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) |
298 |
| - trace_sys_enter(regs, regs->gpr[0]); |
299 |
| - |
300 |
| - if (!is_32bit_task()) |
301 |
| - audit_syscall_entry(regs->gpr[0], regs->gpr[3], regs->gpr[4], |
302 |
| - regs->gpr[5], regs->gpr[6]); |
303 |
| - else |
304 |
| - audit_syscall_entry(regs->gpr[0], |
305 |
| - regs->gpr[3] & 0xffffffff, |
306 |
| - regs->gpr[4] & 0xffffffff, |
307 |
| - regs->gpr[5] & 0xffffffff, |
308 |
| - regs->gpr[6] & 0xffffffff); |
309 |
| - |
310 |
| - /* Return the possibly modified but valid syscall number */ |
311 |
| - return regs->gpr[0]; |
312 |
| - |
313 |
| -skip: |
314 |
| - /* |
315 |
| - * If we are aborting explicitly, or if the syscall number is |
316 |
| - * now invalid, set the return value to -ENOSYS. |
317 |
| - */ |
318 |
| - regs->gpr[3] = -ENOSYS; |
319 |
| - return -1; |
320 |
| -} |
321 |
| - |
322 |
| -void do_syscall_trace_leave(struct pt_regs *regs) |
323 |
| -{ |
324 |
| - int step; |
325 |
| - |
326 |
| - audit_syscall_exit(regs); |
327 |
| - |
328 |
| - if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) |
329 |
| - trace_sys_exit(regs, regs->result); |
330 |
| - |
331 |
| - step = test_thread_flag(TIF_SINGLESTEP); |
332 |
| - if (step || test_thread_flag(TIF_SYSCALL_TRACE)) |
333 |
| - ptrace_report_syscall_exit(regs, step); |
334 |
| -} |
335 |
| - |
336 | 195 | void __init pt_regs_check(void);
|
337 | 196 |
|
338 | 197 | /*
|
|
0 commit comments