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

ptrace: Create ptrace_report_syscall_{entry,exit} in ptrace.h

Rename tracehook_report_syscall_{entry,exit} to
ptrace_report_syscall_{entry,exit} and place them in ptrace.h

There is no longer any generic tracehook infractructure so make
these ptrace specific functions ptrace specific.

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

+109 -126
+1 -1
arch/Kconfig
··· 217 217 # asm/syscall.h supplying asm-generic/syscall.h interface 218 218 # linux/regset.h user_regset interfaces 219 219 # CORE_DUMP_USE_REGSET #define'd in linux/elf.h 220 - # TIF_SYSCALL_TRACE calls tracehook_report_syscall_{entry,exit} 220 + # TIF_SYSCALL_TRACE calls ptrace_report_syscall_{entry,exit} 221 221 # TIF_NOTIFY_RESUME calls tracehook_notify_resume() 222 222 # signal delivery calls tracehook_signal_handler() 223 223 #
+2 -3
arch/alpha/kernel/ptrace.c
··· 15 15 #include <linux/user.h> 16 16 #include <linux/security.h> 17 17 #include <linux/signal.h> 18 - #include <linux/tracehook.h> 19 18 #include <linux/audit.h> 20 19 21 20 #include <linux/uaccess.h> ··· 322 323 unsigned long ret = 0; 323 324 struct pt_regs *regs = current_pt_regs(); 324 325 if (test_thread_flag(TIF_SYSCALL_TRACE) && 325 - tracehook_report_syscall_entry(current_pt_regs())) 326 + ptrace_report_syscall_entry(current_pt_regs())) 326 327 ret = -1UL; 327 328 audit_syscall_entry(regs->r0, regs->r16, regs->r17, regs->r18, regs->r19); 328 329 return ret ?: current_pt_regs()->r0; ··· 333 334 { 334 335 audit_syscall_exit(current_pt_regs()); 335 336 if (test_thread_flag(TIF_SYSCALL_TRACE)) 336 - tracehook_report_syscall_exit(current_pt_regs(), 0); 337 + ptrace_report_syscall_exit(current_pt_regs(), 0); 337 338 }
+2 -3
arch/arc/kernel/ptrace.c
··· 4 4 */ 5 5 6 6 #include <linux/ptrace.h> 7 - #include <linux/tracehook.h> 8 7 #include <linux/sched/task_stack.h> 9 8 #include <linux/regset.h> 10 9 #include <linux/unistd.h> ··· 257 258 258 259 asmlinkage int syscall_trace_entry(struct pt_regs *regs) 259 260 { 260 - if (tracehook_report_syscall_entry(regs)) 261 + if (ptrace_report_syscall_entry(regs)) 261 262 return ULONG_MAX; 262 263 263 264 return regs->r8; ··· 265 266 266 267 asmlinkage void syscall_trace_exit(struct pt_regs *regs) 267 268 { 268 - tracehook_report_syscall_exit(regs, 0); 269 + ptrace_report_syscall_exit(regs, 0); 269 270 }
+2 -3
arch/arm/kernel/ptrace.c
··· 22 22 #include <linux/hw_breakpoint.h> 23 23 #include <linux/regset.h> 24 24 #include <linux/audit.h> 25 - #include <linux/tracehook.h> 26 25 #include <linux/unistd.h> 27 26 28 27 #include <asm/syscall.h> ··· 842 843 regs->ARM_ip = dir; 843 844 844 845 if (dir == PTRACE_SYSCALL_EXIT) 845 - tracehook_report_syscall_exit(regs, 0); 846 - else if (tracehook_report_syscall_entry(regs)) 846 + ptrace_report_syscall_exit(regs, 0); 847 + else if (ptrace_report_syscall_entry(regs)) 847 848 current_thread_info()->abi_syscall = -1; 848 849 849 850 regs->ARM_ip = ip;
+3 -4
arch/arm64/kernel/ptrace.c
··· 27 27 #include <linux/perf_event.h> 28 28 #include <linux/hw_breakpoint.h> 29 29 #include <linux/regset.h> 30 - #include <linux/tracehook.h> 31 30 #include <linux/elf.h> 32 31 33 32 #include <asm/compat.h> ··· 1817 1818 regs->regs[regno] = dir; 1818 1819 1819 1820 if (dir == PTRACE_SYSCALL_ENTER) { 1820 - if (tracehook_report_syscall_entry(regs)) 1821 + if (ptrace_report_syscall_entry(regs)) 1821 1822 forget_syscall(regs); 1822 1823 regs->regs[regno] = saved_reg; 1823 1824 } else if (!test_thread_flag(TIF_SINGLESTEP)) { 1824 - tracehook_report_syscall_exit(regs, 0); 1825 + ptrace_report_syscall_exit(regs, 0); 1825 1826 regs->regs[regno] = saved_reg; 1826 1827 } else { 1827 1828 regs->regs[regno] = saved_reg; ··· 1831 1832 * tracer modifications to the registers may have rewound the 1832 1833 * state machine. 1833 1834 */ 1834 - tracehook_report_syscall_exit(regs, 1); 1835 + ptrace_report_syscall_exit(regs, 1); 1835 1836 } 1836 1837 } 1837 1838
+2 -3
arch/csky/kernel/ptrace.c
··· 12 12 #include <linux/sched/task_stack.h> 13 13 #include <linux/signal.h> 14 14 #include <linux/smp.h> 15 - #include <linux/tracehook.h> 16 15 #include <linux/uaccess.h> 17 16 #include <linux/user.h> 18 17 ··· 320 321 asmlinkage int syscall_trace_enter(struct pt_regs *regs) 321 322 { 322 323 if (test_thread_flag(TIF_SYSCALL_TRACE)) 323 - if (tracehook_report_syscall_entry(regs)) 324 + if (ptrace_report_syscall_entry(regs)) 324 325 return -1; 325 326 326 327 if (secure_computing() == -1) ··· 338 339 audit_syscall_exit(regs); 339 340 340 341 if (test_thread_flag(TIF_SYSCALL_TRACE)) 341 - tracehook_report_syscall_exit(regs, 0); 342 + ptrace_report_syscall_exit(regs, 0); 342 343 343 344 if (test_thread_flag(TIF_SYSCALL_TRACEPOINT)) 344 345 trace_sys_exit(regs, syscall_get_return_value(current, regs));
+2 -3
arch/h8300/kernel/ptrace.c
··· 12 12 #include <linux/errno.h> 13 13 #include <linux/ptrace.h> 14 14 #include <linux/audit.h> 15 - #include <linux/tracehook.h> 16 15 #include <linux/regset.h> 17 16 #include <linux/elf.h> 18 17 ··· 173 174 long ret = 0; 174 175 175 176 if (test_thread_flag(TIF_SYSCALL_TRACE) && 176 - tracehook_report_syscall_entry(regs)) 177 + ptrace_report_syscall_entry(regs)) 177 178 /* 178 179 * Tracing decided this syscall should not happen. 179 180 * We'll return a bogus call number to get an ENOSYS ··· 195 196 196 197 step = test_thread_flag(TIF_SINGLESTEP); 197 198 if (step || test_thread_flag(TIF_SYSCALL_TRACE)) 198 - tracehook_report_syscall_exit(regs, step); 199 + ptrace_report_syscall_exit(regs, step); 199 200 }
+3 -3
arch/hexagon/kernel/traps.c
··· 14 14 #include <linux/kdebug.h> 15 15 #include <linux/syscalls.h> 16 16 #include <linux/signal.h> 17 - #include <linux/tracehook.h> 17 + #include <linux/ptrace.h> 18 18 #include <asm/traps.h> 19 19 #include <asm/vm_fault.h> 20 20 #include <asm/syscall.h> ··· 348 348 349 349 /* allow strace to catch syscall args */ 350 350 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACE) && 351 - tracehook_report_syscall_entry(regs))) 351 + ptrace_report_syscall_entry(regs))) 352 352 return; /* return -ENOSYS somewhere? */ 353 353 354 354 /* Interrupts should be re-enabled for syscall processing */ ··· 386 386 387 387 /* allow strace to get the syscall return state */ 388 388 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACE))) 389 - tracehook_report_syscall_exit(regs, 0); 389 + ptrace_report_syscall_exit(regs, 0); 390 390 391 391 break; 392 392 case TRAP_DEBUG:
+2 -2
arch/ia64/kernel/ptrace.c
··· 1217 1217 struct pt_regs regs) 1218 1218 { 1219 1219 if (test_thread_flag(TIF_SYSCALL_TRACE)) 1220 - if (tracehook_report_syscall_entry(&regs)) 1220 + if (ptrace_report_syscall_entry(&regs)) 1221 1221 return -ENOSYS; 1222 1222 1223 1223 /* copy user rbs to kernel rbs */ ··· 1243 1243 1244 1244 step = test_thread_flag(TIF_SINGLESTEP); 1245 1245 if (step || test_thread_flag(TIF_SYSCALL_TRACE)) 1246 - tracehook_report_syscall_exit(&regs, step); 1246 + ptrace_report_syscall_exit(&regs, step); 1247 1247 1248 1248 /* copy user rbs to kernel rbs */ 1249 1249 if (test_thread_flag(TIF_RESTORE_RSE))
+3 -3
arch/m68k/kernel/ptrace.c
··· 19 19 #include <linux/ptrace.h> 20 20 #include <linux/user.h> 21 21 #include <linux/signal.h> 22 - #include <linux/tracehook.h> 22 + #include <linux/ptrace.h> 23 23 24 24 #include <linux/uaccess.h> 25 25 #include <asm/page.h> ··· 282 282 int ret = 0; 283 283 284 284 if (test_thread_flag(TIF_SYSCALL_TRACE)) 285 - ret = tracehook_report_syscall_entry(task_pt_regs(current)); 285 + ret = ptrace_report_syscall_entry(task_pt_regs(current)); 286 286 return ret; 287 287 } 288 288 289 289 asmlinkage void syscall_trace_leave(void) 290 290 { 291 291 if (test_thread_flag(TIF_SYSCALL_TRACE)) 292 - tracehook_report_syscall_exit(task_pt_regs(current), 0); 292 + ptrace_report_syscall_exit(task_pt_regs(current), 0); 293 293 } 294 294 #endif /* CONFIG_COLDFIRE */
+2 -3
arch/microblaze/kernel/ptrace.c
··· 33 33 #include <linux/elf.h> 34 34 #include <linux/audit.h> 35 35 #include <linux/seccomp.h> 36 - #include <linux/tracehook.h> 37 36 38 37 #include <linux/errno.h> 39 38 #include <asm/processor.h> ··· 139 140 secure_computing_strict(regs->r12); 140 141 141 142 if (test_thread_flag(TIF_SYSCALL_TRACE) && 142 - tracehook_report_syscall_entry(regs)) 143 + ptrace_report_syscall_entry(regs)) 143 144 /* 144 145 * Tracing decided this syscall should not happen. 145 146 * We'll return a bogus call number to get an ENOSYS ··· 160 161 161 162 step = test_thread_flag(TIF_SINGLESTEP); 162 163 if (step || test_thread_flag(TIF_SYSCALL_TRACE)) 163 - tracehook_report_syscall_exit(regs, step); 164 + ptrace_report_syscall_exit(regs, step); 164 165 } 165 166 166 167 void ptrace_disable(struct task_struct *child)
+2 -3
arch/mips/kernel/ptrace.c
··· 27 27 #include <linux/smp.h> 28 28 #include <linux/security.h> 29 29 #include <linux/stddef.h> 30 - #include <linux/tracehook.h> 31 30 #include <linux/audit.h> 32 31 #include <linux/seccomp.h> 33 32 #include <linux/ftrace.h> ··· 1316 1317 current_thread_info()->syscall = syscall; 1317 1318 1318 1319 if (test_thread_flag(TIF_SYSCALL_TRACE)) { 1319 - if (tracehook_report_syscall_entry(regs)) 1320 + if (ptrace_report_syscall_entry(regs)) 1320 1321 return -1; 1321 1322 syscall = current_thread_info()->syscall; 1322 1323 } ··· 1375 1376 trace_sys_exit(regs, regs_return_value(regs)); 1376 1377 1377 1378 if (test_thread_flag(TIF_SYSCALL_TRACE)) 1378 - tracehook_report_syscall_exit(regs, 0); 1379 + ptrace_report_syscall_exit(regs, 0); 1379 1380 1380 1381 user_enter(); 1381 1382 }
+1 -1
arch/nds32/include/asm/syscall.h
··· 39 39 * 40 40 * It's only valid to call this when @task is stopped for system 41 41 * call exit tracing (due to TIF_SYSCALL_TRACE or TIF_SYSCALL_AUDIT), 42 - * after tracehook_report_syscall_entry() returned nonzero to prevent 42 + * after ptrace_report_syscall_entry() returned nonzero to prevent 43 43 * the system call from taking place. 44 44 * 45 45 * This rolls back the register state in @regs so it's as if the
+2 -3
arch/nds32/kernel/ptrace.c
··· 3 3 4 4 #include <linux/ptrace.h> 5 5 #include <linux/regset.h> 6 - #include <linux/tracehook.h> 7 6 #include <linux/elf.h> 8 7 #include <linux/sched/task_stack.h> 9 8 ··· 102 103 asmlinkage int syscall_trace_enter(struct pt_regs *regs) 103 104 { 104 105 if (test_thread_flag(TIF_SYSCALL_TRACE)) { 105 - if (tracehook_report_syscall_entry(regs)) 106 + if (ptrace_report_syscall_entry(regs)) 106 107 forget_syscall(regs); 107 108 } 108 109 return regs->syscallno; ··· 112 113 { 113 114 int step = test_thread_flag(TIF_SINGLESTEP); 114 115 if (step || test_thread_flag(TIF_SYSCALL_TRACE)) 115 - tracehook_report_syscall_exit(regs, step); 116 + ptrace_report_syscall_exit(regs, step); 116 117 117 118 }
+2 -3
arch/nios2/kernel/ptrace.c
··· 15 15 #include <linux/regset.h> 16 16 #include <linux/sched.h> 17 17 #include <linux/sched/task_stack.h> 18 - #include <linux/tracehook.h> 19 18 #include <linux/uaccess.h> 20 19 #include <linux/user.h> 21 20 ··· 133 134 int ret = 0; 134 135 135 136 if (test_thread_flag(TIF_SYSCALL_TRACE)) 136 - ret = tracehook_report_syscall_entry(task_pt_regs(current)); 137 + ret = ptrace_report_syscall_entry(task_pt_regs(current)); 137 138 138 139 return ret; 139 140 } ··· 141 142 asmlinkage void do_syscall_trace_exit(void) 142 143 { 143 144 if (test_thread_flag(TIF_SYSCALL_TRACE)) 144 - tracehook_report_syscall_exit(task_pt_regs(current), 0); 145 + ptrace_report_syscall_exit(task_pt_regs(current), 0); 145 146 }
+2 -3
arch/openrisc/kernel/ptrace.c
··· 22 22 #include <linux/ptrace.h> 23 23 #include <linux/audit.h> 24 24 #include <linux/regset.h> 25 - #include <linux/tracehook.h> 26 25 #include <linux/elf.h> 27 26 28 27 #include <asm/thread_info.h> ··· 158 159 long ret = 0; 159 160 160 161 if (test_thread_flag(TIF_SYSCALL_TRACE) && 161 - tracehook_report_syscall_entry(regs)) 162 + ptrace_report_syscall_entry(regs)) 162 163 /* 163 164 * Tracing decided this syscall should not happen. 164 165 * We'll return a bogus call number to get an ENOSYS ··· 180 181 181 182 step = test_thread_flag(TIF_SINGLESTEP); 182 183 if (step || test_thread_flag(TIF_SYSCALL_TRACE)) 183 - tracehook_report_syscall_exit(regs, step); 184 + ptrace_report_syscall_exit(regs, step); 184 185 }
+3 -4
arch/parisc/kernel/ptrace.c
··· 15 15 #include <linux/elf.h> 16 16 #include <linux/errno.h> 17 17 #include <linux/ptrace.h> 18 - #include <linux/tracehook.h> 19 18 #include <linux/user.h> 20 19 #include <linux/personality.h> 21 20 #include <linux/regset.h> ··· 315 316 long do_syscall_trace_enter(struct pt_regs *regs) 316 317 { 317 318 if (test_thread_flag(TIF_SYSCALL_TRACE)) { 318 - int rc = tracehook_report_syscall_entry(regs); 319 + int rc = ptrace_report_syscall_entry(regs); 319 320 320 321 /* 321 322 * As tracesys_next does not set %r28 to -ENOSYS ··· 326 327 if (rc) { 327 328 /* 328 329 * A nonzero return code from 329 - * tracehook_report_syscall_entry() tells us 330 + * ptrace_report_syscall_entry() tells us 330 331 * to prevent the syscall execution. Skip 331 332 * the syscall call and the syscall restart handling. 332 333 * ··· 380 381 #endif 381 382 382 383 if (stepping || test_thread_flag(TIF_SYSCALL_TRACE)) 383 - tracehook_report_syscall_exit(regs, stepping); 384 + ptrace_report_syscall_exit(regs, stepping); 384 385 } 385 386 386 387
+4 -4
arch/powerpc/kernel/ptrace/ptrace.c
··· 16 16 */ 17 17 18 18 #include <linux/regset.h> 19 - #include <linux/tracehook.h> 19 + #include <linux/ptrace.h> 20 20 #include <linux/audit.h> 21 21 #include <linux/context_tracking.h> 22 22 #include <linux/syscalls.h> ··· 263 263 flags = read_thread_flags() & (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE); 264 264 265 265 if (flags) { 266 - int rc = tracehook_report_syscall_entry(regs); 266 + int rc = ptrace_report_syscall_entry(regs); 267 267 268 268 if (unlikely(flags & _TIF_SYSCALL_EMU)) { 269 269 /* 270 270 * A nonzero return code from 271 - * tracehook_report_syscall_entry() tells us to prevent 271 + * ptrace_report_syscall_entry() tells us to prevent 272 272 * the syscall execution, but we are not going to 273 273 * execute it anyway. 274 274 * ··· 334 334 335 335 step = test_thread_flag(TIF_SINGLESTEP); 336 336 if (step || test_thread_flag(TIF_SYSCALL_TRACE)) 337 - tracehook_report_syscall_exit(regs, step); 337 + ptrace_report_syscall_exit(regs, step); 338 338 } 339 339 340 340 void __init pt_regs_check(void);
+2 -3
arch/riscv/kernel/ptrace.c
··· 17 17 #include <linux/regset.h> 18 18 #include <linux/sched.h> 19 19 #include <linux/sched/task_stack.h> 20 - #include <linux/tracehook.h> 21 20 22 21 #define CREATE_TRACE_POINTS 23 22 #include <trace/events/syscalls.h> ··· 240 241 __visible int do_syscall_trace_enter(struct pt_regs *regs) 241 242 { 242 243 if (test_thread_flag(TIF_SYSCALL_TRACE)) 243 - if (tracehook_report_syscall_entry(regs)) 244 + if (ptrace_report_syscall_entry(regs)) 244 245 return -1; 245 246 246 247 /* ··· 265 266 audit_syscall_exit(regs); 266 267 267 268 if (test_thread_flag(TIF_SYSCALL_TRACE)) 268 - tracehook_report_syscall_exit(regs, 0); 269 + ptrace_report_syscall_exit(regs, 0); 269 270 270 271 #ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS 271 272 if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
+2 -3
arch/sh/kernel/ptrace_32.c
··· 20 20 #include <linux/io.h> 21 21 #include <linux/audit.h> 22 22 #include <linux/seccomp.h> 23 - #include <linux/tracehook.h> 24 23 #include <linux/elf.h> 25 24 #include <linux/regset.h> 26 25 #include <linux/hw_breakpoint.h> ··· 455 456 asmlinkage long do_syscall_trace_enter(struct pt_regs *regs) 456 457 { 457 458 if (test_thread_flag(TIF_SYSCALL_TRACE) && 458 - tracehook_report_syscall_entry(regs)) { 459 + ptrace_report_syscall_entry(regs)) { 459 460 regs->regs[0] = -ENOSYS; 460 461 return -1; 461 462 } ··· 483 484 484 485 step = test_thread_flag(TIF_SINGLESTEP); 485 486 if (step || test_thread_flag(TIF_SYSCALL_TRACE)) 486 - tracehook_report_syscall_exit(regs, step); 487 + ptrace_report_syscall_exit(regs, step); 487 488 }
+2 -3
arch/sparc/kernel/ptrace_32.c
··· 21 21 #include <linux/signal.h> 22 22 #include <linux/regset.h> 23 23 #include <linux/elf.h> 24 - #include <linux/tracehook.h> 25 24 26 25 #include <linux/uaccess.h> 27 26 #include <asm/cacheflush.h> ··· 438 439 439 440 if (test_thread_flag(TIF_SYSCALL_TRACE)) { 440 441 if (syscall_exit_p) 441 - tracehook_report_syscall_exit(regs, 0); 442 + ptrace_report_syscall_exit(regs, 0); 442 443 else 443 - ret = tracehook_report_syscall_entry(regs); 444 + ret = ptrace_report_syscall_entry(regs); 444 445 } 445 446 446 447 return ret;
+2 -3
arch/sparc/kernel/ptrace_64.c
··· 25 25 #include <linux/audit.h> 26 26 #include <linux/signal.h> 27 27 #include <linux/regset.h> 28 - #include <linux/tracehook.h> 29 28 #include <trace/syscall.h> 30 29 #include <linux/compat.h> 31 30 #include <linux/elf.h> ··· 1094 1095 user_exit(); 1095 1096 1096 1097 if (test_thread_flag(TIF_SYSCALL_TRACE)) 1097 - ret = tracehook_report_syscall_entry(regs); 1098 + ret = ptrace_report_syscall_entry(regs); 1098 1099 1099 1100 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) 1100 1101 trace_sys_enter(regs, regs->u_regs[UREG_G1]); ··· 1117 1118 trace_sys_exit(regs, regs->u_regs[UREG_I0]); 1118 1119 1119 1120 if (test_thread_flag(TIF_SYSCALL_TRACE)) 1120 - tracehook_report_syscall_exit(regs, 0); 1121 + ptrace_report_syscall_exit(regs, 0); 1121 1122 1122 1123 if (test_thread_flag(TIF_NOHZ)) 1123 1124 user_enter();
+2 -3
arch/um/kernel/ptrace.c
··· 6 6 #include <linux/audit.h> 7 7 #include <linux/ptrace.h> 8 8 #include <linux/sched.h> 9 - #include <linux/tracehook.h> 10 9 #include <linux/uaccess.h> 11 10 #include <asm/ptrace-abi.h> 12 11 ··· 134 135 if (!test_thread_flag(TIF_SYSCALL_TRACE)) 135 136 return 0; 136 137 137 - return tracehook_report_syscall_entry(regs); 138 + return ptrace_report_syscall_entry(regs); 138 139 } 139 140 140 141 void syscall_trace_leave(struct pt_regs *regs) ··· 150 151 if (!test_thread_flag(TIF_SYSCALL_TRACE)) 151 152 return; 152 153 153 - tracehook_report_syscall_exit(regs, 0); 154 + ptrace_report_syscall_exit(regs, 0); 154 155 /* force do_signal() --> is_syscall() */ 155 156 if (ptraced & PT_PTRACED) 156 157 set_thread_flag(TIF_SIGPENDING);
+2 -3
arch/xtensa/kernel/ptrace.c
··· 26 26 #include <linux/security.h> 27 27 #include <linux/signal.h> 28 28 #include <linux/smp.h> 29 - #include <linux/tracehook.h> 30 29 #include <linux/uaccess.h> 31 30 32 31 #define CREATE_TRACE_POINTS ··· 549 550 regs->areg[2] = -ENOSYS; 550 551 551 552 if (test_thread_flag(TIF_SYSCALL_TRACE) && 552 - tracehook_report_syscall_entry(regs)) { 553 + ptrace_report_syscall_entry(regs)) { 553 554 regs->areg[2] = -ENOSYS; 554 555 regs->syscall = NO_SYSCALL; 555 556 return 0; ··· 582 583 step = test_thread_flag(TIF_SINGLESTEP); 583 584 584 585 if (step || test_thread_flag(TIF_SYSCALL_TRACE)) 585 - tracehook_report_syscall_exit(regs, step); 586 + ptrace_report_syscall_exit(regs, step); 586 587 }
+1 -1
include/asm-generic/syscall.h
··· 44 44 * 45 45 * It's only valid to call this when @task is stopped for system 46 46 * call exit tracing (due to %SYSCALL_WORK_SYSCALL_TRACE or 47 - * %SYSCALL_WORK_SYSCALL_AUDIT), after tracehook_report_syscall_entry() 47 + * %SYSCALL_WORK_SYSCALL_AUDIT), after ptrace_report_syscall_entry() 48 48 * returned nonzero to prevent the system call from taking place. 49 49 * 50 50 * This rolls back the register state in @regs so it's as if the
+3 -3
include/linux/entry-common.h
··· 3 3 #define __LINUX_ENTRYCOMMON_H 4 4 5 5 #include <linux/static_call_types.h> 6 - #include <linux/tracehook.h> 6 + #include <linux/ptrace.h> 7 7 #include <linux/syscalls.h> 8 8 #include <linux/seccomp.h> 9 9 #include <linux/sched.h> ··· 95 95 #ifndef arch_syscall_enter_tracehook 96 96 static inline __must_check int arch_syscall_enter_tracehook(struct pt_regs *regs) 97 97 { 98 - return tracehook_report_syscall_entry(regs); 98 + return ptrace_report_syscall_entry(regs); 99 99 } 100 100 #endif 101 101 ··· 294 294 #ifndef arch_syscall_exit_tracehook 295 295 static inline void arch_syscall_exit_tracehook(struct pt_regs *regs, bool step) 296 296 { 297 - tracehook_report_syscall_exit(regs, step); 297 + ptrace_report_syscall_exit(regs, step); 298 298 } 299 299 #endif 300 300
+51
include/linux/ptrace.h
··· 440 440 current->ptrace_message = 0; 441 441 return fatal_signal_pending(current); 442 442 } 443 + 444 + /** 445 + * ptrace_report_syscall_entry - task is about to attempt a system call 446 + * @regs: user register state of current task 447 + * 448 + * This will be called if %SYSCALL_WORK_SYSCALL_TRACE or 449 + * %SYSCALL_WORK_SYSCALL_EMU have been set, when the current task has just 450 + * entered the kernel for a system call. Full user register state is 451 + * available here. Changing the values in @regs can affect the system 452 + * call number and arguments to be tried. It is safe to block here, 453 + * preventing the system call from beginning. 454 + * 455 + * Returns zero normally, or nonzero if the calling arch code should abort 456 + * the system call. That must prevent normal entry so no system call is 457 + * made. If @task ever returns to user mode after this, its register state 458 + * is unspecified, but should be something harmless like an %ENOSYS error 459 + * return. It should preserve enough information so that syscall_rollback() 460 + * can work (see asm-generic/syscall.h). 461 + * 462 + * Called without locks, just after entering kernel mode. 463 + */ 464 + static inline __must_check int ptrace_report_syscall_entry( 465 + struct pt_regs *regs) 466 + { 467 + return ptrace_report_syscall(PTRACE_EVENTMSG_SYSCALL_ENTRY); 468 + } 469 + 470 + /** 471 + * ptrace_report_syscall_exit - task has just finished a system call 472 + * @regs: user register state of current task 473 + * @step: nonzero if simulating single-step or block-step 474 + * 475 + * This will be called if %SYSCALL_WORK_SYSCALL_TRACE has been set, when 476 + * the current task has just finished an attempted system call. Full 477 + * user register state is available here. It is safe to block here, 478 + * preventing signals from being processed. 479 + * 480 + * If @step is nonzero, this report is also in lieu of the normal 481 + * trap that would follow the system call instruction because 482 + * user_enable_block_step() or user_enable_single_step() was used. 483 + * In this case, %SYSCALL_WORK_SYSCALL_TRACE might not be set. 484 + * 485 + * Called without locks, just before checking for pending signals. 486 + */ 487 + static inline void ptrace_report_syscall_exit(struct pt_regs *regs, int step) 488 + { 489 + if (step) 490 + user_single_step_report(regs); 491 + else 492 + ptrace_report_syscall(PTRACE_EVENTMSG_SYSCALL_EXIT); 493 + } 443 494 #endif
-51
include/linux/tracehook.h
··· 53 53 54 54 55 55 /** 56 - * tracehook_report_syscall_entry - task is about to attempt a system call 57 - * @regs: user register state of current task 58 - * 59 - * This will be called if %SYSCALL_WORK_SYSCALL_TRACE or 60 - * %SYSCALL_WORK_SYSCALL_EMU have been set, when the current task has just 61 - * entered the kernel for a system call. Full user register state is 62 - * available here. Changing the values in @regs can affect the system 63 - * call number and arguments to be tried. It is safe to block here, 64 - * preventing the system call from beginning. 65 - * 66 - * Returns zero normally, or nonzero if the calling arch code should abort 67 - * the system call. That must prevent normal entry so no system call is 68 - * made. If @task ever returns to user mode after this, its register state 69 - * is unspecified, but should be something harmless like an %ENOSYS error 70 - * return. It should preserve enough information so that syscall_rollback() 71 - * can work (see asm-generic/syscall.h). 72 - * 73 - * Called without locks, just after entering kernel mode. 74 - */ 75 - static inline __must_check int tracehook_report_syscall_entry( 76 - struct pt_regs *regs) 77 - { 78 - return ptrace_report_syscall(PTRACE_EVENTMSG_SYSCALL_ENTRY); 79 - } 80 - 81 - /** 82 - * tracehook_report_syscall_exit - task has just finished a system call 83 - * @regs: user register state of current task 84 - * @step: nonzero if simulating single-step or block-step 85 - * 86 - * This will be called if %SYSCALL_WORK_SYSCALL_TRACE has been set, when 87 - * the current task has just finished an attempted system call. Full 88 - * user register state is available here. It is safe to block here, 89 - * preventing signals from being processed. 90 - * 91 - * If @step is nonzero, this report is also in lieu of the normal 92 - * trap that would follow the system call instruction because 93 - * user_enable_block_step() or user_enable_single_step() was used. 94 - * In this case, %SYSCALL_WORK_SYSCALL_TRACE might not be set. 95 - * 96 - * Called without locks, just before checking for pending signals. 97 - */ 98 - static inline void tracehook_report_syscall_exit(struct pt_regs *regs, int step) 99 - { 100 - if (step) 101 - user_single_step_report(regs); 102 - else 103 - ptrace_report_syscall(PTRACE_EVENTMSG_SYSCALL_EXIT); 104 - } 105 - 106 - /** 107 56 * tracehook_signal_handler - signal handler setup is complete 108 57 * @stepping: nonzero if debugger single-step or block-step in use 109 58 *
+1 -1
include/uapi/linux/ptrace.h
··· 114 114 115 115 /* 116 116 * These values are stored in task->ptrace_message 117 - * by tracehook_report_syscall_* to describe the current syscall-stop. 117 + * by ptrace_report_syscall_* to describe the current syscall-stop. 118 118 */ 119 119 #define PTRACE_EVENTMSG_SYSCALL_ENTRY 1 120 120 #define PTRACE_EVENTMSG_SYSCALL_EXIT 2
+1
kernel/entry/common.c
··· 2 2 3 3 #include <linux/context_tracking.h> 4 4 #include <linux/entry-common.h> 5 + #include <linux/tracehook.h> 5 6 #include <linux/highmem.h> 6 7 #include <linux/livepatch.h> 7 8 #include <linux/audit.h>