Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ptrace: Move ptrace_report_syscall into ptrace.h

Move ptrace_report_syscall from tracehook.h into ptrace.h where it
belongs.

Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lkml.kernel.org/r/20220309162454.123006-1-ebiederm@xmission.com
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>

+27 -26
+27
include/linux/ptrace.h
··· 413 413 extern int task_current_syscall(struct task_struct *target, struct syscall_info *info); 414 414 415 415 extern void sigaction_compat_abi(struct k_sigaction *act, struct k_sigaction *oact); 416 + 417 + /* 418 + * ptrace report for syscall entry and exit looks identical. 419 + */ 420 + static inline int ptrace_report_syscall(unsigned long message) 421 + { 422 + int ptrace = current->ptrace; 423 + 424 + if (!(ptrace & PT_PTRACED)) 425 + return 0; 426 + 427 + current->ptrace_message = message; 428 + ptrace_notify(SIGTRAP | ((ptrace & PT_TRACESYSGOOD) ? 0x80 : 0)); 429 + 430 + /* 431 + * this isn't the same as continuing with a signal, but it will do 432 + * for normal use. strace only continues with a signal if the 433 + * stopping signal is not SIGTRAP. -brl 434 + */ 435 + if (current->exit_code) { 436 + send_sig(current->exit_code, current, 1); 437 + current->exit_code = 0; 438 + } 439 + 440 + current->ptrace_message = 0; 441 + return fatal_signal_pending(current); 442 + } 416 443 #endif
-26
include/linux/tracehook.h
··· 51 51 #include <linux/blk-cgroup.h> 52 52 struct linux_binprm; 53 53 54 - /* 55 - * ptrace report for syscall entry and exit looks identical. 56 - */ 57 - static inline int ptrace_report_syscall(unsigned long message) 58 - { 59 - int ptrace = current->ptrace; 60 - 61 - if (!(ptrace & PT_PTRACED)) 62 - return 0; 63 - 64 - current->ptrace_message = message; 65 - ptrace_notify(SIGTRAP | ((ptrace & PT_TRACESYSGOOD) ? 0x80 : 0)); 66 - 67 - /* 68 - * this isn't the same as continuing with a signal, but it will do 69 - * for normal use. strace only continues with a signal if the 70 - * stopping signal is not SIGTRAP. -brl 71 - */ 72 - if (current->exit_code) { 73 - send_sig(current->exit_code, current, 1); 74 - current->exit_code = 0; 75 - } 76 - 77 - current->ptrace_message = 0; 78 - return fatal_signal_pending(current); 79 - } 80 54 81 55 /** 82 56 * tracehook_report_syscall_entry - task is about to attempt a system call