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

Merge tag 'ptrace-cleanups-for-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace

Pull ptrace cleanups from Eric Biederman:
"This set of changes removes tracehook.h, moves modification of all of
the ptrace fields inside of siglock to remove races, adds a missing
permission check to ptrace.c

The removal of tracehook.h is quite significant as it has been a major
source of confusion in recent years. Much of that confusion was around
task_work and TIF_NOTIFY_SIGNAL (which I have now decoupled making the
semantics clearer).

For people who don't know tracehook.h is a vestiage of an attempt to
implement uprobes like functionality that was never fully merged, and
was later superseeded by uprobes when uprobes was merged. For many
years now we have been removing what tracehook functionaly a little
bit at a time. To the point where anything left in tracehook.h was
some weird strange thing that was difficult to understand"

* tag 'ptrace-cleanups-for-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace:
ptrace: Remove duplicated include in ptrace.c
ptrace: Check PTRACE_O_SUSPEND_SECCOMP permission on PTRACE_SEIZE
ptrace: Return the signal to continue with from ptrace_stop
ptrace: Move setting/clearing ptrace_message into ptrace_stop
tracehook: Remove tracehook.h
resume_user_mode: Move to resume_user_mode.h
resume_user_mode: Remove #ifdef TIF_NOTIFY_RESUME in set_notify_resume
signal: Move set_notify_signal and clear_notify_signal into sched/signal.h
task_work: Decouple TIF_NOTIFY_SIGNAL and task_work
task_work: Call tracehook_notify_signal from get_signal on all architectures
task_work: Introduce task_work_pending
task_work: Remove unnecessary include from posix_timers.h
ptrace: Remove tracehook_signal_handler
ptrace: Remove arch_syscall_{enter,exit}_tracehook
ptrace: Create ptrace_report_syscall_{entry,exit} in ptrace.h
ptrace/arm: Rename tracehook_report_syscall report_syscall
ptrace: Move ptrace_report_syscall into ptrace.h

+368 -489
-1
MAINTAINERS
··· 15930 15930 F: include/asm-generic/syscall.h 15931 15931 F: include/linux/ptrace.h 15932 15932 F: include/linux/regset.h 15933 - F: include/linux/tracehook.h 15934 15933 F: include/uapi/linux/ptrace.h 15935 15934 F: include/uapi/linux/ptrace.h 15936 15935 F: kernel/ptrace.c
+2 -3
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} 221 - # TIF_NOTIFY_RESUME calls tracehook_notify_resume() 222 - # signal delivery calls tracehook_signal_handler() 220 + # TIF_SYSCALL_TRACE calls ptrace_report_syscall_{entry,exit} 221 + # TIF_NOTIFY_RESUME calls resume_user_mode_work() 223 222 # 224 223 config HAVE_ARCH_TRACEHOOK 225 224 bool
+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 -2
arch/alpha/kernel/signal.c
··· 22 22 #include <linux/binfmts.h> 23 23 #include <linux/bitops.h> 24 24 #include <linux/syscalls.h> 25 - #include <linux/tracehook.h> 25 + #include <linux/resume_user_mode.h> 26 26 27 27 #include <linux/uaccess.h> 28 28 #include <asm/sigcontext.h> ··· 531 531 do_signal(regs, r0, r19); 532 532 r0 = 0; 533 533 } else { 534 - tracehook_notify_resume(regs); 534 + resume_user_mode_work(regs); 535 535 } 536 536 } 537 537 local_irq_disable();
+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 -2
arch/arc/kernel/signal.c
··· 49 49 #include <linux/personality.h> 50 50 #include <linux/uaccess.h> 51 51 #include <linux/syscalls.h> 52 - #include <linux/tracehook.h> 52 + #include <linux/resume_user_mode.h> 53 53 #include <linux/sched/task_stack.h> 54 54 55 55 #include <asm/ucontext.h> ··· 438 438 * user mode 439 439 */ 440 440 if (test_thread_flag(TIF_NOTIFY_RESUME)) 441 - tracehook_notify_resume(regs); 441 + resume_user_mode_work(regs); 442 442 }
+5 -7
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> ··· 830 831 PTRACE_SYSCALL_EXIT, 831 832 }; 832 833 833 - static void tracehook_report_syscall(struct pt_regs *regs, 834 - enum ptrace_syscall_dir dir) 834 + static void report_syscall(struct pt_regs *regs, enum ptrace_syscall_dir dir) 835 835 { 836 836 unsigned long ip; 837 837 ··· 842 844 regs->ARM_ip = dir; 843 845 844 846 if (dir == PTRACE_SYSCALL_EXIT) 845 - tracehook_report_syscall_exit(regs, 0); 846 - else if (tracehook_report_syscall_entry(regs)) 847 + ptrace_report_syscall_exit(regs, 0); 848 + else if (ptrace_report_syscall_entry(regs)) 847 849 current_thread_info()->abi_syscall = -1; 848 850 849 851 regs->ARM_ip = ip; ··· 854 856 int scno; 855 857 856 858 if (test_thread_flag(TIF_SYSCALL_TRACE)) 857 - tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER); 859 + report_syscall(regs, PTRACE_SYSCALL_ENTER); 858 860 859 861 /* Do seccomp after ptrace; syscall may have changed. */ 860 862 #ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER ··· 895 897 trace_sys_exit(regs, regs_return_value(regs)); 896 898 897 899 if (test_thread_flag(TIF_SYSCALL_TRACE)) 898 - tracehook_report_syscall(regs, PTRACE_SYSCALL_EXIT); 900 + report_syscall(regs, PTRACE_SYSCALL_EXIT); 899 901 }
+2 -2
arch/arm/kernel/signal.c
··· 9 9 #include <linux/signal.h> 10 10 #include <linux/personality.h> 11 11 #include <linux/uaccess.h> 12 - #include <linux/tracehook.h> 12 + #include <linux/resume_user_mode.h> 13 13 #include <linux/uprobes.h> 14 14 #include <linux/syscalls.h> 15 15 ··· 627 627 } else if (thread_flags & _TIF_UPROBE) { 628 628 uprobe_notify_resume(regs); 629 629 } else { 630 - tracehook_notify_resume(regs); 630 + resume_user_mode_work(regs); 631 631 } 632 632 } 633 633 local_irq_disable();
+6 -8
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> ··· 1791 1792 PTRACE_SYSCALL_EXIT, 1792 1793 }; 1793 1794 1794 - static void tracehook_report_syscall(struct pt_regs *regs, 1795 - enum ptrace_syscall_dir dir) 1795 + static void report_syscall(struct pt_regs *regs, enum ptrace_syscall_dir dir) 1796 1796 { 1797 1797 int regno; 1798 1798 unsigned long saved_reg; ··· 1817 1819 regs->regs[regno] = dir; 1818 1820 1819 1821 if (dir == PTRACE_SYSCALL_ENTER) { 1820 - if (tracehook_report_syscall_entry(regs)) 1822 + if (ptrace_report_syscall_entry(regs)) 1821 1823 forget_syscall(regs); 1822 1824 regs->regs[regno] = saved_reg; 1823 1825 } else if (!test_thread_flag(TIF_SINGLESTEP)) { 1824 - tracehook_report_syscall_exit(regs, 0); 1826 + ptrace_report_syscall_exit(regs, 0); 1825 1827 regs->regs[regno] = saved_reg; 1826 1828 } else { 1827 1829 regs->regs[regno] = saved_reg; ··· 1831 1833 * tracer modifications to the registers may have rewound the 1832 1834 * state machine. 1833 1835 */ 1834 - tracehook_report_syscall_exit(regs, 1); 1836 + ptrace_report_syscall_exit(regs, 1); 1835 1837 } 1836 1838 } 1837 1839 ··· 1840 1842 unsigned long flags = read_thread_flags(); 1841 1843 1842 1844 if (flags & (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE)) { 1843 - tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER); 1845 + report_syscall(regs, PTRACE_SYSCALL_ENTER); 1844 1846 if (flags & _TIF_SYSCALL_EMU) 1845 1847 return NO_SYSCALL; 1846 1848 } ··· 1868 1870 trace_sys_exit(regs, syscall_get_return_value(current, regs)); 1869 1871 1870 1872 if (flags & (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP)) 1871 - tracehook_report_syscall(regs, PTRACE_SYSCALL_EXIT); 1873 + report_syscall(regs, PTRACE_SYSCALL_EXIT); 1872 1874 1873 1875 rseq_syscall(regs); 1874 1876 }
+2 -2
arch/arm64/kernel/signal.c
··· 16 16 #include <linux/uaccess.h> 17 17 #include <linux/sizes.h> 18 18 #include <linux/string.h> 19 - #include <linux/tracehook.h> 19 + #include <linux/resume_user_mode.h> 20 20 #include <linux/ratelimit.h> 21 21 #include <linux/syscalls.h> 22 22 ··· 942 942 do_signal(regs); 943 943 944 944 if (thread_flags & _TIF_NOTIFY_RESUME) 945 - tracehook_notify_resume(regs); 945 + resume_user_mode_work(regs); 946 946 947 947 if (thread_flags & _TIF_FOREIGN_FPSTATE) 948 948 fpsimd_restore_current_state();
+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 -2
arch/csky/kernel/signal.c
··· 3 3 #include <linux/signal.h> 4 4 #include <linux/uaccess.h> 5 5 #include <linux/syscalls.h> 6 - #include <linux/tracehook.h> 6 + #include <linux/resume_user_mode.h> 7 7 8 8 #include <asm/traps.h> 9 9 #include <asm/ucontext.h> ··· 265 265 do_signal(regs); 266 266 267 267 if (thread_info_flags & _TIF_NOTIFY_RESUME) 268 - tracehook_notify_resume(regs); 268 + resume_user_mode_work(regs); 269 269 }
+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 }
+2 -2
arch/h8300/kernel/signal.c
··· 39 39 #include <linux/personality.h> 40 40 #include <linux/tty.h> 41 41 #include <linux/binfmts.h> 42 - #include <linux/tracehook.h> 42 + #include <linux/resume_user_mode.h> 43 43 44 44 #include <asm/setup.h> 45 45 #include <linux/uaccess.h> ··· 283 283 do_signal(regs); 284 284 285 285 if (thread_info_flags & _TIF_NOTIFY_RESUME) 286 - tracehook_notify_resume(regs); 286 + resume_user_mode_work(regs); 287 287 }
+2 -2
arch/hexagon/kernel/process.c
··· 14 14 #include <linux/tick.h> 15 15 #include <linux/uaccess.h> 16 16 #include <linux/slab.h> 17 - #include <linux/tracehook.h> 17 + #include <linux/resume_user_mode.h> 18 18 19 19 /* 20 20 * Program thread launch. Often defined as a macro in processor.h, ··· 177 177 } 178 178 179 179 if (thread_info_flags & _TIF_NOTIFY_RESUME) { 180 - tracehook_notify_resume(regs); 180 + resume_user_mode_work(regs); 181 181 return 1; 182 182 } 183 183
-1
arch/hexagon/kernel/signal.c
··· 7 7 8 8 #include <linux/linkage.h> 9 9 #include <linux/syscalls.h> 10 - #include <linux/tracehook.h> 11 10 #include <linux/sched/task_stack.h> 12 11 13 12 #include <asm/registers.h>
+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/process.c
··· 32 32 #include <linux/delay.h> 33 33 #include <linux/kdebug.h> 34 34 #include <linux/utsname.h> 35 - #include <linux/tracehook.h> 35 + #include <linux/resume_user_mode.h> 36 36 #include <linux/rcupdate.h> 37 37 38 38 #include <asm/cpu.h> ··· 179 179 180 180 if (test_thread_flag(TIF_NOTIFY_RESUME)) { 181 181 local_irq_enable(); /* force interrupt enable */ 182 - tracehook_notify_resume(&scr->pt); 182 + resume_user_mode_work(&scr->pt); 183 183 } 184 184 185 185 /* copy user rbs to kernel rbs */
+3 -3
arch/ia64/kernel/ptrace.c
··· 23 23 #include <linux/signal.h> 24 24 #include <linux/regset.h> 25 25 #include <linux/elf.h> 26 - #include <linux/tracehook.h> 26 + #include <linux/resume_user_mode.h> 27 27 28 28 #include <asm/processor.h> 29 29 #include <asm/ptrace_offsets.h> ··· 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))
-1
arch/ia64/kernel/signal.c
··· 12 12 #include <linux/kernel.h> 13 13 #include <linux/mm.h> 14 14 #include <linux/ptrace.h> 15 - #include <linux/tracehook.h> 16 15 #include <linux/sched.h> 17 16 #include <linux/signal.h> 18 17 #include <linux/smp.h>
+2 -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> 23 22 24 23 #include <linux/uaccess.h> 25 24 #include <asm/page.h> ··· 281 282 int ret = 0; 282 283 283 284 if (test_thread_flag(TIF_SYSCALL_TRACE)) 284 - ret = tracehook_report_syscall_entry(task_pt_regs(current)); 285 + ret = ptrace_report_syscall_entry(task_pt_regs(current)); 285 286 return ret; 286 287 } 287 288 288 289 asmlinkage void syscall_trace_leave(void) 289 290 { 290 291 if (test_thread_flag(TIF_SYSCALL_TRACE)) 291 - tracehook_report_syscall_exit(task_pt_regs(current), 0); 292 + ptrace_report_syscall_exit(task_pt_regs(current), 0); 292 293 } 293 294 #endif /* CONFIG_COLDFIRE */
+2 -2
arch/m68k/kernel/signal.c
··· 43 43 #include <linux/tty.h> 44 44 #include <linux/binfmts.h> 45 45 #include <linux/extable.h> 46 - #include <linux/tracehook.h> 46 + #include <linux/resume_user_mode.h> 47 47 48 48 #include <asm/setup.h> 49 49 #include <linux/uaccess.h> ··· 1109 1109 do_signal(regs); 1110 1110 1111 1111 if (test_thread_flag(TIF_NOTIFY_RESUME)) 1112 - tracehook_notify_resume(regs); 1112 + resume_user_mode_work(regs); 1113 1113 }
+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 -2
arch/microblaze/kernel/signal.c
··· 31 31 #include <linux/personality.h> 32 32 #include <linux/percpu.h> 33 33 #include <linux/linkage.h> 34 - #include <linux/tracehook.h> 34 + #include <linux/resume_user_mode.h> 35 35 #include <asm/entry.h> 36 36 #include <asm/ucontext.h> 37 37 #include <linux/uaccess.h> ··· 311 311 do_signal(regs, in_syscall); 312 312 313 313 if (test_thread_flag(TIF_NOTIFY_RESUME)) 314 - tracehook_notify_resume(regs); 314 + resume_user_mode_work(regs); 315 315 }
+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 }
+2 -2
arch/mips/kernel/signal.c
··· 25 25 #include <linux/compiler.h> 26 26 #include <linux/syscalls.h> 27 27 #include <linux/uaccess.h> 28 - #include <linux/tracehook.h> 28 + #include <linux/resume_user_mode.h> 29 29 30 30 #include <asm/abi.h> 31 31 #include <asm/asm.h> ··· 915 915 do_signal(regs); 916 916 917 917 if (thread_info_flags & _TIF_NOTIFY_RESUME) 918 - tracehook_notify_resume(regs); 918 + resume_user_mode_work(regs); 919 919 920 920 user_enter(); 921 921 }
+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 -2
arch/nios2/kernel/signal.c
··· 15 15 #include <linux/uaccess.h> 16 16 #include <linux/unistd.h> 17 17 #include <linux/personality.h> 18 - #include <linux/tracehook.h> 18 + #include <linux/resume_user_mode.h> 19 19 20 20 #include <asm/ucontext.h> 21 21 #include <asm/cacheflush.h> ··· 321 321 return restart; 322 322 } 323 323 } else if (test_thread_flag(TIF_NOTIFY_RESUME)) 324 - tracehook_notify_resume(regs); 324 + resume_user_mode_work(regs); 325 325 326 326 return 0; 327 327 }
+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 }
+2 -2
arch/openrisc/kernel/signal.c
··· 21 21 #include <linux/ptrace.h> 22 22 #include <linux/unistd.h> 23 23 #include <linux/stddef.h> 24 - #include <linux/tracehook.h> 24 + #include <linux/resume_user_mode.h> 25 25 26 26 #include <asm/processor.h> 27 27 #include <asm/syscall.h> ··· 309 309 } 310 310 syscall = 0; 311 311 } else { 312 - tracehook_notify_resume(regs); 312 + resume_user_mode_work(regs); 313 313 } 314 314 } 315 315 local_irq_disable();
+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
+2 -2
arch/parisc/kernel/signal.c
··· 19 19 #include <linux/errno.h> 20 20 #include <linux/wait.h> 21 21 #include <linux/ptrace.h> 22 - #include <linux/tracehook.h> 22 + #include <linux/resume_user_mode.h> 23 23 #include <linux/unistd.h> 24 24 #include <linux/stddef.h> 25 25 #include <linux/compat.h> ··· 585 585 do_signal(regs, in_syscall); 586 586 587 587 if (test_thread_flag(TIF_NOTIFY_RESUME)) 588 - tracehook_notify_resume(regs); 588 + resume_user_mode_work(regs); 589 589 }
+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> ··· 262 262 flags = read_thread_flags() & (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE); 263 263 264 264 if (flags) { 265 - int rc = tracehook_report_syscall_entry(regs); 265 + int rc = ptrace_report_syscall_entry(regs); 266 266 267 267 if (unlikely(flags & _TIF_SYSCALL_EMU)) { 268 268 /* 269 269 * A nonzero return code from 270 - * tracehook_report_syscall_entry() tells us to prevent 270 + * ptrace_report_syscall_entry() tells us to prevent 271 271 * the syscall execution, but we are not going to 272 272 * execute it anyway. 273 273 * ··· 333 333 334 334 step = test_thread_flag(TIF_SINGLESTEP); 335 335 if (step || test_thread_flag(TIF_SYSCALL_TRACE)) 336 - tracehook_report_syscall_exit(regs, step); 336 + ptrace_report_syscall_exit(regs, step); 337 337 } 338 338 339 339 void __init pt_regs_check(void);
+2 -2
arch/powerpc/kernel/signal.c
··· 9 9 * this archive for more details. 10 10 */ 11 11 12 - #include <linux/tracehook.h> 12 + #include <linux/resume_user_mode.h> 13 13 #include <linux/signal.h> 14 14 #include <linux/uprobes.h> 15 15 #include <linux/key.h> ··· 294 294 } 295 295 296 296 if (thread_info_flags & _TIF_NOTIFY_RESUME) 297 - tracehook_notify_resume(regs); 297 + resume_user_mode_work(regs); 298 298 } 299 299 300 300 static unsigned long get_tm_stackpointer(struct task_struct *tsk)
+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 -2
arch/riscv/kernel/signal.c
··· 9 9 #include <linux/signal.h> 10 10 #include <linux/uaccess.h> 11 11 #include <linux/syscalls.h> 12 - #include <linux/tracehook.h> 12 + #include <linux/resume_user_mode.h> 13 13 #include <linux/linkage.h> 14 14 15 15 #include <asm/ucontext.h> ··· 319 319 do_signal(regs); 320 320 321 321 if (thread_info_flags & _TIF_NOTIFY_RESUME) 322 - tracehook_notify_resume(regs); 322 + resume_user_mode_work(regs); 323 323 }
-1
arch/s390/include/asm/entry-common.h
··· 5 5 #include <linux/sched.h> 6 6 #include <linux/audit.h> 7 7 #include <linux/randomize_kstack.h> 8 - #include <linux/tracehook.h> 9 8 #include <linux/processor.h> 10 9 #include <linux/uaccess.h> 11 10 #include <asm/timex.h>
-1
arch/s390/kernel/ptrace.c
··· 21 21 #include <linux/signal.h> 22 22 #include <linux/elf.h> 23 23 #include <linux/regset.h> 24 - #include <linux/tracehook.h> 25 24 #include <linux/seccomp.h> 26 25 #include <linux/compat.h> 27 26 #include <trace/syscall.h>
+2 -3
arch/s390/kernel/signal.c
··· 25 25 #include <linux/tty.h> 26 26 #include <linux/personality.h> 27 27 #include <linux/binfmts.h> 28 - #include <linux/tracehook.h> 29 28 #include <linux/syscalls.h> 30 29 #include <linux/compat.h> 31 30 #include <asm/ucontext.h> ··· 452 453 * stack-frames in one go after that. 453 454 */ 454 455 455 - void arch_do_signal_or_restart(struct pt_regs *regs, bool has_signal) 456 + void arch_do_signal_or_restart(struct pt_regs *regs) 456 457 { 457 458 struct ksignal ksig; 458 459 sigset_t *oldset = sigmask_to_save(); ··· 465 466 current->thread.system_call = 466 467 test_pt_regs_flag(regs, PIF_SYSCALL) ? regs->int_code : 0; 467 468 468 - if (has_signal && get_signal(&ksig)) { 469 + if (get_signal(&ksig)) { 469 470 /* Whee! Actually deliver the signal. */ 470 471 if (current->thread.system_call) { 471 472 regs->int_code = current->thread.system_call;
+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 -2
arch/sh/kernel/signal_32.c
··· 25 25 #include <linux/personality.h> 26 26 #include <linux/binfmts.h> 27 27 #include <linux/io.h> 28 - #include <linux/tracehook.h> 28 + #include <linux/resume_user_mode.h> 29 29 #include <asm/ucontext.h> 30 30 #include <linux/uaccess.h> 31 31 #include <asm/cacheflush.h> ··· 503 503 do_signal(regs, save_r0); 504 504 505 505 if (thread_info_flags & _TIF_NOTIFY_RESUME) 506 - tracehook_notify_resume(regs); 506 + resume_user_mode_work(regs); 507 507 }
+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();
-1
arch/sparc/kernel/signal32.c
··· 20 20 #include <linux/binfmts.h> 21 21 #include <linux/compat.h> 22 22 #include <linux/bitops.h> 23 - #include <linux/tracehook.h> 24 23 25 24 #include <linux/uaccess.h> 26 25 #include <asm/ptrace.h>
+2 -2
arch/sparc/kernel/signal_32.c
··· 19 19 #include <linux/smp.h> 20 20 #include <linux/binfmts.h> /* do_coredum */ 21 21 #include <linux/bitops.h> 22 - #include <linux/tracehook.h> 22 + #include <linux/resume_user_mode.h> 23 23 24 24 #include <linux/uaccess.h> 25 25 #include <asm/ptrace.h> ··· 524 524 if (thread_info_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)) 525 525 do_signal(regs, orig_i0); 526 526 if (thread_info_flags & _TIF_NOTIFY_RESUME) 527 - tracehook_notify_resume(regs); 527 + resume_user_mode_work(regs); 528 528 } 529 529 530 530 asmlinkage int do_sys_sigstack(struct sigstack __user *ssptr,
+2 -2
arch/sparc/kernel/signal_64.c
··· 15 15 #include <linux/errno.h> 16 16 #include <linux/wait.h> 17 17 #include <linux/ptrace.h> 18 - #include <linux/tracehook.h> 18 + #include <linux/resume_user_mode.h> 19 19 #include <linux/unistd.h> 20 20 #include <linux/mm.h> 21 21 #include <linux/tty.h> ··· 552 552 if (thread_info_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)) 553 553 do_signal(regs, orig_i0); 554 554 if (thread_info_flags & _TIF_NOTIFY_RESUME) 555 - tracehook_notify_resume(regs); 555 + resume_user_mode_work(regs); 556 556 user_enter(); 557 557 } 558 558
+2 -2
arch/um/kernel/process.c
··· 23 23 #include <linux/seq_file.h> 24 24 #include <linux/tick.h> 25 25 #include <linux/threads.h> 26 - #include <linux/tracehook.h> 26 + #include <linux/resume_user_mode.h> 27 27 #include <asm/current.h> 28 28 #include <asm/mmu_context.h> 29 29 #include <linux/uaccess.h> ··· 104 104 test_thread_flag(TIF_NOTIFY_SIGNAL)) 105 105 do_signal(regs); 106 106 if (test_thread_flag(TIF_NOTIFY_RESUME)) 107 - tracehook_notify_resume(regs); 107 + resume_user_mode_work(regs); 108 108 } 109 109 110 110 int get_current_pid(void)
+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);
-1
arch/x86/kernel/ptrace.c
··· 13 13 #include <linux/errno.h> 14 14 #include <linux/slab.h> 15 15 #include <linux/ptrace.h> 16 - #include <linux/tracehook.h> 17 16 #include <linux/user.h> 18 17 #include <linux/elf.h> 19 18 #include <linux/security.h>
+2 -3
arch/x86/kernel/signal.c
··· 18 18 #include <linux/kstrtox.h> 19 19 #include <linux/errno.h> 20 20 #include <linux/wait.h> 21 - #include <linux/tracehook.h> 22 21 #include <linux/unistd.h> 23 22 #include <linux/stddef.h> 24 23 #include <linux/personality.h> ··· 860 861 * want to handle. Thus you cannot kill init even with a SIGKILL even by 861 862 * mistake. 862 863 */ 863 - void arch_do_signal_or_restart(struct pt_regs *regs, bool has_signal) 864 + void arch_do_signal_or_restart(struct pt_regs *regs) 864 865 { 865 866 struct ksignal ksig; 866 867 867 - if (has_signal && get_signal(&ksig)) { 868 + if (get_signal(&ksig)) { 868 869 /* Whee! Actually deliver the signal. */ 869 870 handle_signal(&ksig, regs); 870 871 return;
+1
arch/x86/mm/tlb.c
··· 9 9 #include <linux/cpu.h> 10 10 #include <linux/debugfs.h> 11 11 #include <linux/sched/smt.h> 12 + #include <linux/task_work.h> 12 13 13 14 #include <asm/tlbflush.h> 14 15 #include <asm/mmu_context.h>
+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 }
+2 -2
arch/xtensa/kernel/signal.c
··· 19 19 #include <linux/errno.h> 20 20 #include <linux/ptrace.h> 21 21 #include <linux/personality.h> 22 - #include <linux/tracehook.h> 22 + #include <linux/resume_user_mode.h> 23 23 #include <linux/sched/task_stack.h> 24 24 25 25 #include <asm/ucontext.h> ··· 511 511 do_signal(regs); 512 512 513 513 if (test_thread_flag(TIF_NOTIFY_RESUME)) 514 - tracehook_notify_resume(regs); 514 + resume_user_mode_work(regs); 515 515 }
+1 -1
block/blk-cgroup.c
··· 26 26 #include <linux/delay.h> 27 27 #include <linux/atomic.h> 28 28 #include <linux/ctype.h> 29 - #include <linux/tracehook.h> 29 + #include <linux/resume_user_mode.h> 30 30 #include <linux/psi.h> 31 31 #include <linux/part_stat.h> 32 32 #include "blk.h"
-1
fs/coredump.c
··· 31 31 #include <linux/tsacct_kern.h> 32 32 #include <linux/cn_proc.h> 33 33 #include <linux/audit.h> 34 - #include <linux/tracehook.h> 35 34 #include <linux/kmod.h> 36 35 #include <linux/fsnotify.h> 37 36 #include <linux/fs_struct.h>
-1
fs/exec.c
··· 56 56 #include <linux/tsacct_kern.h> 57 57 #include <linux/cn_proc.h> 58 58 #include <linux/audit.h> 59 - #include <linux/tracehook.h> 60 59 #include <linux/kmod.h> 61 60 #include <linux/fsnotify.h> 62 61 #include <linux/fs_struct.h>
+4 -2
fs/io-wq.c
··· 13 13 #include <linux/slab.h> 14 14 #include <linux/rculist_nulls.h> 15 15 #include <linux/cpu.h> 16 - #include <linux/tracehook.h> 16 + #include <linux/task_work.h> 17 17 #include <linux/audit.h> 18 18 #include <uapi/linux/io_uring.h> 19 19 ··· 522 522 { 523 523 if (unlikely(test_thread_flag(TIF_NOTIFY_SIGNAL))) { 524 524 __set_current_state(TASK_RUNNING); 525 - tracehook_notify_signal(); 525 + clear_notify_signal(); 526 + if (task_work_pending(current)) 527 + task_work_run(); 526 528 return true; 527 529 } 528 530 return false;
+6 -5
fs/io_uring.c
··· 79 79 #include <linux/task_work.h> 80 80 #include <linux/pagemap.h> 81 81 #include <linux/io_uring.h> 82 - #include <linux/tracehook.h> 83 82 #include <linux/audit.h> 84 83 #include <linux/security.h> 85 84 ··· 2749 2750 2750 2751 static inline bool io_run_task_work(void) 2751 2752 { 2752 - if (test_thread_flag(TIF_NOTIFY_SIGNAL) || current->task_works) { 2753 + if (test_thread_flag(TIF_NOTIFY_SIGNAL) || task_work_pending(current)) { 2753 2754 __set_current_state(TASK_RUNNING); 2754 - tracehook_notify_signal(); 2755 + clear_notify_signal(); 2756 + if (task_work_pending(current)) 2757 + task_work_run(); 2755 2758 return true; 2756 2759 } 2757 2760 ··· 8042 8041 } 8043 8042 8044 8043 prepare_to_wait(&sqd->wait, &wait, TASK_INTERRUPTIBLE); 8045 - if (!io_sqd_events_pending(sqd) && !current->task_works) { 8044 + if (!io_sqd_events_pending(sqd) && !task_work_pending(current)) { 8046 8045 bool needs_sched = true; 8047 8046 8048 8047 list_for_each_entry(ctx, &sqd->ctx_list, sqd_list) { ··· 11097 11096 11098 11097 hlist_for_each_entry(req, list, hash_node) 11099 11098 seq_printf(m, " op=%d, task_works=%d\n", req->opcode, 11100 - req->task->task_works != NULL); 11099 + task_work_pending(req->task)); 11101 11100 } 11102 11101 11103 11102 seq_puts(m, "CqOverflowList:\n");
-1
fs/proc/array.c
··· 88 88 #include <linux/pid_namespace.h> 89 89 #include <linux/prctl.h> 90 90 #include <linux/ptrace.h> 91 - #include <linux/tracehook.h> 92 91 #include <linux/string_helpers.h> 93 92 #include <linux/user_namespace.h> 94 93 #include <linux/fs_struct.h>
-1
fs/proc/base.c
··· 74 74 #include <linux/mount.h> 75 75 #include <linux/security.h> 76 76 #include <linux/ptrace.h> 77 - #include <linux/tracehook.h> 78 77 #include <linux/printk.h> 79 78 #include <linux/cache.h> 80 79 #include <linux/cgroup.h>
+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
+4 -43
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> ··· 80 80 #endif 81 81 82 82 /** 83 - * arch_syscall_enter_tracehook - Wrapper around tracehook_report_syscall_entry() 84 - * @regs: Pointer to currents pt_regs 85 - * 86 - * Returns: 0 on success or an error code to skip the syscall. 87 - * 88 - * Defaults to tracehook_report_syscall_entry(). Can be replaced by 89 - * architecture specific code. 90 - * 91 - * Invoked from syscall_enter_from_user_mode() 92 - */ 93 - static inline __must_check int arch_syscall_enter_tracehook(struct pt_regs *regs); 94 - 95 - #ifndef arch_syscall_enter_tracehook 96 - static inline __must_check int arch_syscall_enter_tracehook(struct pt_regs *regs) 97 - { 98 - return tracehook_report_syscall_entry(regs); 99 - } 100 - #endif 101 - 102 - /** 103 83 * enter_from_user_mode - Establish state when coming from user mode 104 84 * 105 85 * Syscall/interrupt entry disables interrupts, but user mode is traced as ··· 137 157 * It handles the following work items: 138 158 * 139 159 * 1) syscall_work flag dependent invocations of 140 - * arch_syscall_enter_tracehook(), __secure_computing(), trace_sys_enter() 160 + * ptrace_report_syscall_entry(), __secure_computing(), trace_sys_enter() 141 161 * 2) Invocation of audit_syscall_entry() 142 162 */ 143 163 long syscall_enter_from_user_mode_work(struct pt_regs *regs, long syscall); ··· 257 277 * 258 278 * Invoked from exit_to_user_mode_loop(). 259 279 */ 260 - void arch_do_signal_or_restart(struct pt_regs *regs, bool has_signal); 261 - 262 - /** 263 - * arch_syscall_exit_tracehook - Wrapper around tracehook_report_syscall_exit() 264 - * @regs: Pointer to currents pt_regs 265 - * @step: Indicator for single step 266 - * 267 - * Defaults to tracehook_report_syscall_exit(). Can be replaced by 268 - * architecture specific code. 269 - * 270 - * Invoked from syscall_exit_to_user_mode() 271 - */ 272 - static inline void arch_syscall_exit_tracehook(struct pt_regs *regs, bool step); 273 - 274 - #ifndef arch_syscall_exit_tracehook 275 - static inline void arch_syscall_exit_tracehook(struct pt_regs *regs, bool step) 276 - { 277 - tracehook_report_syscall_exit(regs, step); 278 - } 279 - #endif 280 + void arch_do_signal_or_restart(struct pt_regs *regs); 280 281 281 282 /** 282 283 * exit_to_user_mode - Fixup state when exiting to user mode ··· 308 347 * - rseq syscall exit 309 348 * - audit 310 349 * - syscall tracing 311 - * - tracehook (single stepping) 350 + * - ptrace (single stepping) 312 351 * 313 352 * 2) Preparatory work 314 353 * - Exit to user mode loop (common TIF handling). Invokes
+1 -1
include/linux/entry-kvm.h
··· 3 3 #define __LINUX_ENTRYKVM_H 4 4 5 5 #include <linux/static_call_types.h> 6 - #include <linux/tracehook.h> 6 + #include <linux/resume_user_mode.h> 7 7 #include <linux/syscalls.h> 8 8 #include <linux/seccomp.h> 9 9 #include <linux/sched.h>
-1
include/linux/posix-timers.h
··· 6 6 #include <linux/list.h> 7 7 #include <linux/alarmtimer.h> 8 8 #include <linux/timerqueue.h> 9 - #include <linux/task_work.h> 10 9 11 10 struct kernel_siginfo; 12 11 struct task_struct;
+78 -3
include/linux/ptrace.h
··· 60 60 extern void ptrace_disable(struct task_struct *); 61 61 extern int ptrace_request(struct task_struct *child, long request, 62 62 unsigned long addr, unsigned long data); 63 - extern void ptrace_notify(int exit_code); 63 + extern int ptrace_notify(int exit_code, unsigned long message); 64 64 extern void __ptrace_link(struct task_struct *child, 65 65 struct task_struct *new_parent, 66 66 const struct cred *ptracer_cred); ··· 155 155 static inline void ptrace_event(int event, unsigned long message) 156 156 { 157 157 if (unlikely(ptrace_event_enabled(current, event))) { 158 - current->ptrace_message = message; 159 - ptrace_notify((event << 8) | SIGTRAP); 158 + ptrace_notify((event << 8) | SIGTRAP, message); 160 159 } else if (event == PTRACE_EVENT_EXEC) { 161 160 /* legacy EXEC report via SIGTRAP */ 162 161 if ((current->ptrace & (PT_PTRACED|PT_SEIZED)) == PT_PTRACED) ··· 412 413 extern int task_current_syscall(struct task_struct *target, struct syscall_info *info); 413 414 414 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 + int signr; 424 + 425 + if (!(ptrace & PT_PTRACED)) 426 + return 0; 427 + 428 + signr = ptrace_notify(SIGTRAP | ((ptrace & PT_TRACESYSGOOD) ? 0x80 : 0), 429 + message); 430 + 431 + /* 432 + * this isn't the same as continuing with a signal, but it will do 433 + * for normal use. strace only continues with a signal if the 434 + * stopping signal is not SIGTRAP. -brl 435 + */ 436 + if (signr) 437 + send_sig(signr, current, 1); 438 + 439 + return fatal_signal_pending(current); 440 + } 441 + 442 + /** 443 + * ptrace_report_syscall_entry - task is about to attempt a system call 444 + * @regs: user register state of current task 445 + * 446 + * This will be called if %SYSCALL_WORK_SYSCALL_TRACE or 447 + * %SYSCALL_WORK_SYSCALL_EMU have been set, when the current task has just 448 + * entered the kernel for a system call. Full user register state is 449 + * available here. Changing the values in @regs can affect the system 450 + * call number and arguments to be tried. It is safe to block here, 451 + * preventing the system call from beginning. 452 + * 453 + * Returns zero normally, or nonzero if the calling arch code should abort 454 + * the system call. That must prevent normal entry so no system call is 455 + * made. If @task ever returns to user mode after this, its register state 456 + * is unspecified, but should be something harmless like an %ENOSYS error 457 + * return. It should preserve enough information so that syscall_rollback() 458 + * can work (see asm-generic/syscall.h). 459 + * 460 + * Called without locks, just after entering kernel mode. 461 + */ 462 + static inline __must_check int ptrace_report_syscall_entry( 463 + struct pt_regs *regs) 464 + { 465 + return ptrace_report_syscall(PTRACE_EVENTMSG_SYSCALL_ENTRY); 466 + } 467 + 468 + /** 469 + * ptrace_report_syscall_exit - task has just finished a system call 470 + * @regs: user register state of current task 471 + * @step: nonzero if simulating single-step or block-step 472 + * 473 + * This will be called if %SYSCALL_WORK_SYSCALL_TRACE has been set, when 474 + * the current task has just finished an attempted system call. Full 475 + * user register state is available here. It is safe to block here, 476 + * preventing signals from being processed. 477 + * 478 + * If @step is nonzero, this report is also in lieu of the normal 479 + * trap that would follow the system call instruction because 480 + * user_enable_block_step() or user_enable_single_step() was used. 481 + * In this case, %SYSCALL_WORK_SYSCALL_TRACE might not be set. 482 + * 483 + * Called without locks, just before checking for pending signals. 484 + */ 485 + static inline void ptrace_report_syscall_exit(struct pt_regs *regs, int step) 486 + { 487 + if (step) 488 + user_single_step_report(regs); 489 + else 490 + ptrace_report_syscall(PTRACE_EVENTMSG_SYSCALL_EXIT); 491 + } 415 492 #endif
+64
include/linux/resume_user_mode.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + 3 + #ifndef LINUX_RESUME_USER_MODE_H 4 + #define LINUX_RESUME_USER_MODE_H 5 + 6 + #include <linux/sched.h> 7 + #include <linux/task_work.h> 8 + #include <linux/memcontrol.h> 9 + #include <linux/blk-cgroup.h> 10 + 11 + /** 12 + * set_notify_resume - cause resume_user_mode_work() to be called 13 + * @task: task that will call resume_user_mode_work() 14 + * 15 + * Calling this arranges that @task will call resume_user_mode_work() 16 + * before returning to user mode. If it's already running in user mode, 17 + * it will enter the kernel and call resume_user_mode_work() soon. 18 + * If it's blocked, it will not be woken. 19 + */ 20 + static inline void set_notify_resume(struct task_struct *task) 21 + { 22 + if (!test_and_set_tsk_thread_flag(task, TIF_NOTIFY_RESUME)) 23 + kick_process(task); 24 + } 25 + 26 + 27 + /** 28 + * resume_user_mode_work - Perform work before returning to user mode 29 + * @regs: user-mode registers of @current task 30 + * 31 + * This is called when %TIF_NOTIFY_RESUME has been set. Now we are 32 + * about to return to user mode, and the user state in @regs can be 33 + * inspected or adjusted. The caller in arch code has cleared 34 + * %TIF_NOTIFY_RESUME before the call. If the flag gets set again 35 + * asynchronously, this will be called again before we return to 36 + * user mode. 37 + * 38 + * Called without locks. 39 + */ 40 + static inline void resume_user_mode_work(struct pt_regs *regs) 41 + { 42 + clear_thread_flag(TIF_NOTIFY_RESUME); 43 + /* 44 + * This barrier pairs with task_work_add()->set_notify_resume() after 45 + * hlist_add_head(task->task_works); 46 + */ 47 + smp_mb__after_atomic(); 48 + if (unlikely(task_work_pending(current))) 49 + task_work_run(); 50 + 51 + #ifdef CONFIG_KEYS_REQUEST_CACHE 52 + if (unlikely(current->cached_requested_key)) { 53 + key_put(current->cached_requested_key); 54 + current->cached_requested_key = NULL; 55 + } 56 + #endif 57 + 58 + mem_cgroup_handle_over_high(); 59 + blkcg_maybe_throttle_current(); 60 + 61 + rseq_handle_notify_resume(NULL, regs); 62 + } 63 + 64 + #endif /* LINUX_RESUME_USER_MODE_H */
+17
include/linux/sched/signal.h
··· 349 349 extern int send_sigqueue(struct sigqueue *, struct pid *, enum pid_type); 350 350 extern int do_sigaction(int, struct k_sigaction *, struct k_sigaction *); 351 351 352 + static inline void clear_notify_signal(void) 353 + { 354 + clear_thread_flag(TIF_NOTIFY_SIGNAL); 355 + smp_mb__after_atomic(); 356 + } 357 + 358 + /* 359 + * Called to break out of interruptible wait loops, and enter the 360 + * exit_to_user_mode_loop(). 361 + */ 362 + static inline void set_notify_signal(struct task_struct *task) 363 + { 364 + if (!test_and_set_tsk_thread_flag(task, TIF_NOTIFY_SIGNAL) && 365 + !wake_up_state(task, TASK_INTERRUPTIBLE)) 366 + kick_process(task); 367 + } 368 + 352 369 static inline int restart_syscall(void) 353 370 { 354 371 set_tsk_thread_flag(current, TIF_SIGPENDING);
+5
include/linux/task_work.h
··· 19 19 TWA_SIGNAL, 20 20 }; 21 21 22 + static inline bool task_work_pending(struct task_struct *task) 23 + { 24 + return READ_ONCE(task->task_works); 25 + } 26 + 22 27 int task_work_add(struct task_struct *task, struct callback_head *twork, 23 28 enum task_work_notify_mode mode); 24 29
-226
include/linux/tracehook.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-only */ 2 - /* 3 - * Tracing hooks 4 - * 5 - * Copyright (C) 2008-2009 Red Hat, Inc. All rights reserved. 6 - * 7 - * This file defines hook entry points called by core code where 8 - * user tracing/debugging support might need to do something. These 9 - * entry points are called tracehook_*(). Each hook declared below 10 - * has a detailed kerneldoc comment giving the context (locking et 11 - * al) from which it is called, and the meaning of its return value. 12 - * 13 - * Each function here typically has only one call site, so it is ok 14 - * to have some nontrivial tracehook_*() inlines. In all cases, the 15 - * fast path when no tracing is enabled should be very short. 16 - * 17 - * The purpose of this file and the tracehook_* layer is to consolidate 18 - * the interface that the kernel core and arch code uses to enable any 19 - * user debugging or tracing facility (such as ptrace). The interfaces 20 - * here are carefully documented so that maintainers of core and arch 21 - * code do not need to think about the implementation details of the 22 - * tracing facilities. Likewise, maintainers of the tracing code do not 23 - * need to understand all the calling core or arch code in detail, just 24 - * documented circumstances of each call, such as locking conditions. 25 - * 26 - * If the calling core code changes so that locking is different, then 27 - * it is ok to change the interface documented here. The maintainer of 28 - * core code changing should notify the maintainers of the tracing code 29 - * that they need to work out the change. 30 - * 31 - * Some tracehook_*() inlines take arguments that the current tracing 32 - * implementations might not necessarily use. These function signatures 33 - * are chosen to pass in all the information that is on hand in the 34 - * caller and might conceivably be relevant to a tracer, so that the 35 - * core code won't have to be updated when tracing adds more features. 36 - * If a call site changes so that some of those parameters are no longer 37 - * already on hand without extra work, then the tracehook_* interface 38 - * can change so there is no make-work burden on the core code. The 39 - * maintainer of core code changing should notify the maintainers of the 40 - * tracing code that they need to work out the change. 41 - */ 42 - 43 - #ifndef _LINUX_TRACEHOOK_H 44 - #define _LINUX_TRACEHOOK_H 1 45 - 46 - #include <linux/sched.h> 47 - #include <linux/ptrace.h> 48 - #include <linux/security.h> 49 - #include <linux/task_work.h> 50 - #include <linux/memcontrol.h> 51 - #include <linux/blk-cgroup.h> 52 - struct linux_binprm; 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 - 81 - /** 82 - * tracehook_report_syscall_entry - task is about to attempt a system call 83 - * @regs: user register state of current task 84 - * 85 - * This will be called if %SYSCALL_WORK_SYSCALL_TRACE or 86 - * %SYSCALL_WORK_SYSCALL_EMU have been set, when the current task has just 87 - * entered the kernel for a system call. Full user register state is 88 - * available here. Changing the values in @regs can affect the system 89 - * call number and arguments to be tried. It is safe to block here, 90 - * preventing the system call from beginning. 91 - * 92 - * Returns zero normally, or nonzero if the calling arch code should abort 93 - * the system call. That must prevent normal entry so no system call is 94 - * made. If @task ever returns to user mode after this, its register state 95 - * is unspecified, but should be something harmless like an %ENOSYS error 96 - * return. It should preserve enough information so that syscall_rollback() 97 - * can work (see asm-generic/syscall.h). 98 - * 99 - * Called without locks, just after entering kernel mode. 100 - */ 101 - static inline __must_check int tracehook_report_syscall_entry( 102 - struct pt_regs *regs) 103 - { 104 - return ptrace_report_syscall(PTRACE_EVENTMSG_SYSCALL_ENTRY); 105 - } 106 - 107 - /** 108 - * tracehook_report_syscall_exit - task has just finished a system call 109 - * @regs: user register state of current task 110 - * @step: nonzero if simulating single-step or block-step 111 - * 112 - * This will be called if %SYSCALL_WORK_SYSCALL_TRACE has been set, when 113 - * the current task has just finished an attempted system call. Full 114 - * user register state is available here. It is safe to block here, 115 - * preventing signals from being processed. 116 - * 117 - * If @step is nonzero, this report is also in lieu of the normal 118 - * trap that would follow the system call instruction because 119 - * user_enable_block_step() or user_enable_single_step() was used. 120 - * In this case, %SYSCALL_WORK_SYSCALL_TRACE might not be set. 121 - * 122 - * Called without locks, just before checking for pending signals. 123 - */ 124 - static inline void tracehook_report_syscall_exit(struct pt_regs *regs, int step) 125 - { 126 - if (step) 127 - user_single_step_report(regs); 128 - else 129 - ptrace_report_syscall(PTRACE_EVENTMSG_SYSCALL_EXIT); 130 - } 131 - 132 - /** 133 - * tracehook_signal_handler - signal handler setup is complete 134 - * @stepping: nonzero if debugger single-step or block-step in use 135 - * 136 - * Called by the arch code after a signal handler has been set up. 137 - * Register and stack state reflects the user handler about to run. 138 - * Signal mask changes have already been made. 139 - * 140 - * Called without locks, shortly before returning to user mode 141 - * (or handling more signals). 142 - */ 143 - static inline void tracehook_signal_handler(int stepping) 144 - { 145 - if (stepping) 146 - ptrace_notify(SIGTRAP); 147 - } 148 - 149 - /** 150 - * set_notify_resume - cause tracehook_notify_resume() to be called 151 - * @task: task that will call tracehook_notify_resume() 152 - * 153 - * Calling this arranges that @task will call tracehook_notify_resume() 154 - * before returning to user mode. If it's already running in user mode, 155 - * it will enter the kernel and call tracehook_notify_resume() soon. 156 - * If it's blocked, it will not be woken. 157 - */ 158 - static inline void set_notify_resume(struct task_struct *task) 159 - { 160 - #ifdef TIF_NOTIFY_RESUME 161 - if (!test_and_set_tsk_thread_flag(task, TIF_NOTIFY_RESUME)) 162 - kick_process(task); 163 - #endif 164 - } 165 - 166 - /** 167 - * tracehook_notify_resume - report when about to return to user mode 168 - * @regs: user-mode registers of @current task 169 - * 170 - * This is called when %TIF_NOTIFY_RESUME has been set. Now we are 171 - * about to return to user mode, and the user state in @regs can be 172 - * inspected or adjusted. The caller in arch code has cleared 173 - * %TIF_NOTIFY_RESUME before the call. If the flag gets set again 174 - * asynchronously, this will be called again before we return to 175 - * user mode. 176 - * 177 - * Called without locks. 178 - */ 179 - static inline void tracehook_notify_resume(struct pt_regs *regs) 180 - { 181 - clear_thread_flag(TIF_NOTIFY_RESUME); 182 - /* 183 - * This barrier pairs with task_work_add()->set_notify_resume() after 184 - * hlist_add_head(task->task_works); 185 - */ 186 - smp_mb__after_atomic(); 187 - if (unlikely(current->task_works)) 188 - task_work_run(); 189 - 190 - #ifdef CONFIG_KEYS_REQUEST_CACHE 191 - if (unlikely(current->cached_requested_key)) { 192 - key_put(current->cached_requested_key); 193 - current->cached_requested_key = NULL; 194 - } 195 - #endif 196 - 197 - mem_cgroup_handle_over_high(); 198 - blkcg_maybe_throttle_current(); 199 - 200 - rseq_handle_notify_resume(NULL, regs); 201 - } 202 - 203 - /* 204 - * called by exit_to_user_mode_loop() if ti_work & _TIF_NOTIFY_SIGNAL. This 205 - * is currently used by TWA_SIGNAL based task_work, which requires breaking 206 - * wait loops to ensure that task_work is noticed and run. 207 - */ 208 - static inline void tracehook_notify_signal(void) 209 - { 210 - clear_thread_flag(TIF_NOTIFY_SIGNAL); 211 - smp_mb__after_atomic(); 212 - if (current->task_works) 213 - task_work_run(); 214 - } 215 - 216 - /* 217 - * Called when we have work to process from exit_to_user_mode_loop() 218 - */ 219 - static inline void set_notify_signal(struct task_struct *task) 220 - { 221 - if (!test_and_set_tsk_thread_flag(task, TIF_NOTIFY_SIGNAL) && 222 - !wake_up_state(task, TASK_INTERRUPTIBLE)) 223 - kick_process(task); 224 - } 225 - 226 - #endif /* <linux/tracehook.h> */
+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_stop to describe the current syscall-stop. 118 118 */ 119 119 #define PTRACE_EVENTMSG_SYSCALL_ENTRY 1 120 120 #define PTRACE_EVENTMSG_SYSCALL_EXIT 2
+6 -13
kernel/entry/common.c
··· 2 2 3 3 #include <linux/context_tracking.h> 4 4 #include <linux/entry-common.h> 5 + #include <linux/resume_user_mode.h> 5 6 #include <linux/highmem.h> 6 7 #include <linux/jump_label.h> 7 8 #include <linux/livepatch.h> ··· 60 59 61 60 /* Handle ptrace */ 62 61 if (work & (SYSCALL_WORK_SYSCALL_TRACE | SYSCALL_WORK_SYSCALL_EMU)) { 63 - ret = arch_syscall_enter_tracehook(regs); 62 + ret = ptrace_report_syscall_entry(regs); 64 63 if (ret || (work & SYSCALL_WORK_SYSCALL_EMU)) 65 64 return -1L; 66 65 } ··· 140 139 } 141 140 142 141 /* Workaround to allow gradual conversion of architecture code */ 143 - void __weak arch_do_signal_or_restart(struct pt_regs *regs, bool has_signal) { } 144 - 145 - static void handle_signal_work(struct pt_regs *regs, unsigned long ti_work) 146 - { 147 - if (ti_work & _TIF_NOTIFY_SIGNAL) 148 - tracehook_notify_signal(); 149 - 150 - arch_do_signal_or_restart(regs, ti_work & _TIF_SIGPENDING); 151 - } 142 + void __weak arch_do_signal_or_restart(struct pt_regs *regs) { } 152 143 153 144 #ifdef CONFIG_RT_DELAYED_SIGNALS 154 145 static inline void raise_delayed_signal(void) ··· 177 184 klp_update_patch_state(current); 178 185 179 186 if (ti_work & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)) 180 - handle_signal_work(regs, ti_work); 187 + arch_do_signal_or_restart(regs); 181 188 182 189 if (ti_work & _TIF_NOTIFY_RESUME) 183 - tracehook_notify_resume(regs); 190 + resume_user_mode_work(regs); 184 191 185 192 /* Architecture specific TIF work */ 186 193 arch_exit_to_user_mode_work(regs, ti_work); ··· 260 267 261 268 step = report_single_step(work); 262 269 if (step || work & SYSCALL_WORK_SYSCALL_TRACE) 263 - arch_syscall_exit_tracehook(regs, step); 270 + ptrace_report_syscall_exit(regs, step); 264 271 } 265 272 266 273 /*
+6 -3
kernel/entry/kvm.c
··· 8 8 do { 9 9 int ret; 10 10 11 - if (ti_work & _TIF_NOTIFY_SIGNAL) 12 - tracehook_notify_signal(); 11 + if (ti_work & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)) { 12 + clear_notify_signal(); 13 + if (task_work_pending(current)) 14 + task_work_run(); 15 + } 13 16 14 17 if (ti_work & _TIF_SIGPENDING) { 15 18 kvm_handle_signal_exit(vcpu); ··· 23 20 schedule(); 24 21 25 22 if (ti_work & _TIF_NOTIFY_RESUME) 26 - tracehook_notify_resume(NULL); 23 + resume_user_mode_work(NULL); 27 24 28 25 ret = arch_xfer_to_guest_mode_handle_work(vcpu, ti_work); 29 26 if (ret)
+2 -1
kernel/exit.c
··· 49 49 #include <linux/audit.h> /* for audit_free() */ 50 50 #include <linux/resource.h> 51 51 #include <linux/task_io_accounting_ops.h> 52 - #include <linux/tracehook.h> 52 + #include <linux/blkdev.h> 53 + #include <linux/task_work.h> 53 54 #include <linux/fs_struct.h> 54 55 #include <linux/init_task.h> 55 56 #include <linux/perf_event.h>
-1
kernel/livepatch/transition.c
··· 9 9 10 10 #include <linux/cpu.h> 11 11 #include <linux/stacktrace.h> 12 - #include <linux/tracehook.h> 13 12 #include "core.h" 14 13 #include "patch.h" 15 14 #include "transition.h"
+32 -15
kernel/ptrace.c
··· 371 371 return !err; 372 372 } 373 373 374 + static int check_ptrace_options(unsigned long data) 375 + { 376 + if (data & ~(unsigned long)PTRACE_O_MASK) 377 + return -EINVAL; 378 + 379 + if (unlikely(data & PTRACE_O_SUSPEND_SECCOMP)) { 380 + if (!IS_ENABLED(CONFIG_CHECKPOINT_RESTORE) || 381 + !IS_ENABLED(CONFIG_SECCOMP)) 382 + return -EINVAL; 383 + 384 + if (!capable(CAP_SYS_ADMIN)) 385 + return -EPERM; 386 + 387 + if (seccomp_mode(&current->seccomp) != SECCOMP_MODE_DISABLED || 388 + current->ptrace & PT_SUSPEND_SECCOMP) 389 + return -EPERM; 390 + } 391 + return 0; 392 + } 393 + 374 394 static int ptrace_attach(struct task_struct *task, long request, 375 395 unsigned long addr, 376 396 unsigned long flags) ··· 402 382 if (seize) { 403 383 if (addr != 0) 404 384 goto out; 385 + /* 386 + * This duplicates the check in check_ptrace_options() because 387 + * ptrace_attach() and ptrace_setoptions() have historically 388 + * used different error codes for unknown ptrace options. 389 + */ 405 390 if (flags & ~(unsigned long)PTRACE_O_MASK) 406 391 goto out; 392 + retval = check_ptrace_options(flags); 393 + if (retval) 394 + return retval; 407 395 flags = PT_PTRACED | PT_SEIZED | (flags << PT_OPT_FLAG_SHIFT); 408 396 } else { 409 397 flags = PT_PTRACED; ··· 682 654 static int ptrace_setoptions(struct task_struct *child, unsigned long data) 683 655 { 684 656 unsigned flags; 657 + int ret; 685 658 686 - if (data & ~(unsigned long)PTRACE_O_MASK) 687 - return -EINVAL; 688 - 689 - if (unlikely(data & PTRACE_O_SUSPEND_SECCOMP)) { 690 - if (!IS_ENABLED(CONFIG_CHECKPOINT_RESTORE) || 691 - !IS_ENABLED(CONFIG_SECCOMP)) 692 - return -EINVAL; 693 - 694 - if (!capable(CAP_SYS_ADMIN)) 695 - return -EPERM; 696 - 697 - if (seccomp_mode(&current->seccomp) != SECCOMP_MODE_DISABLED || 698 - current->ptrace & PT_SUSPEND_SECCOMP) 699 - return -EPERM; 700 - } 659 + ret = check_ptrace_options(data); 660 + if (ret) 661 + return ret; 701 662 702 663 /* Avoid intermediate state when all opts are cleared */ 703 664 flags = child->ptrace;
+1
kernel/sched/fair.c
··· 44 44 #include <linux/profile.h> 45 45 #include <linux/psi.h> 46 46 #include <linux/ratelimit.h> 47 + #include <linux/task_work.h> 47 48 48 49 #include <asm/switch_to.h> 49 50
-1
kernel/seccomp.c
··· 42 42 #include <linux/pid.h> 43 43 #include <linux/ptrace.h> 44 44 #include <linux/capability.h> 45 - #include <linux/tracehook.h> 46 45 #include <linux/uaccess.h> 47 46 #include <linux/anon_inodes.h> 48 47 #include <linux/lockdep.h>
+32 -30
kernel/signal.c
··· 32 32 #include <linux/signal.h> 33 33 #include <linux/signalfd.h> 34 34 #include <linux/ratelimit.h> 35 - #include <linux/tracehook.h> 35 + #include <linux/task_work.h> 36 36 #include <linux/capability.h> 37 37 #include <linux/freezer.h> 38 38 #include <linux/pid_namespace.h> ··· 2229 2229 * That makes it a way to test a stopped process for 2230 2230 * being ptrace-stopped vs being job-control-stopped. 2231 2231 * 2232 - * If we actually decide not to stop at all because the tracer 2233 - * is gone, we keep current->exit_code unless clear_code. 2232 + * Returns the signal the ptracer requested the code resume 2233 + * with. If the code did not stop because the tracer is gone, 2234 + * the stop signal remains unchanged unless clear_code. 2234 2235 */ 2235 - static void ptrace_stop(int exit_code, int why, int clear_code, kernel_siginfo_t *info) 2236 + static int ptrace_stop(int exit_code, int why, int clear_code, 2237 + unsigned long message, kernel_siginfo_t *info) 2236 2238 __releases(&current->sighand->siglock) 2237 2239 __acquires(&current->sighand->siglock) 2238 2240 { 2239 2241 bool gstop_done = false; 2242 + bool read_code = true; 2240 2243 2241 2244 if (arch_ptrace_stop_needed()) { 2242 2245 /* ··· 2281 2278 */ 2282 2279 smp_wmb(); 2283 2280 2281 + current->ptrace_message = message; 2284 2282 current->last_siginfo = info; 2285 2283 current->exit_code = exit_code; 2286 2284 ··· 2348 2344 2349 2345 /* tasklist protects us from ptrace_freeze_traced() */ 2350 2346 __set_current_state(TASK_RUNNING); 2347 + read_code = false; 2351 2348 if (clear_code) 2352 - current->exit_code = 0; 2349 + exit_code = 0; 2353 2350 read_unlock(&tasklist_lock); 2354 2351 } 2355 2352 ··· 2360 2355 * any signal-sending on another CPU that wants to examine it. 2361 2356 */ 2362 2357 spin_lock_irq(&current->sighand->siglock); 2358 + if (read_code) 2359 + exit_code = current->exit_code; 2363 2360 current->last_siginfo = NULL; 2361 + current->ptrace_message = 0; 2362 + current->exit_code = 0; 2364 2363 2365 2364 /* LISTENING can be set only during STOP traps, clear it */ 2366 2365 current->jobctl &= ~JOBCTL_LISTENING; ··· 2375 2366 * This sets TIF_SIGPENDING, but never clears it. 2376 2367 */ 2377 2368 recalc_sigpending_tsk(current); 2369 + return exit_code; 2378 2370 } 2379 2371 2380 - static void ptrace_do_notify(int signr, int exit_code, int why) 2372 + static int ptrace_do_notify(int signr, int exit_code, int why, unsigned long message) 2381 2373 { 2382 2374 kernel_siginfo_t info; 2383 2375 ··· 2389 2379 info.si_uid = from_kuid_munged(current_user_ns(), current_uid()); 2390 2380 2391 2381 /* Let the debugger run. */ 2392 - ptrace_stop(exit_code, why, 1, &info); 2382 + return ptrace_stop(exit_code, why, 1, message, &info); 2393 2383 } 2394 2384 2395 - void ptrace_notify(int exit_code) 2385 + int ptrace_notify(int exit_code, unsigned long message) 2396 2386 { 2387 + int signr; 2388 + 2397 2389 BUG_ON((exit_code & (0x7f | ~0xffff)) != SIGTRAP); 2398 - if (unlikely(current->task_works)) 2390 + if (unlikely(task_work_pending(current))) 2399 2391 task_work_run(); 2400 2392 2401 2393 spin_lock_irq(&current->sighand->siglock); 2402 - ptrace_do_notify(SIGTRAP, exit_code, CLD_TRAPPED); 2394 + signr = ptrace_do_notify(SIGTRAP, exit_code, CLD_TRAPPED, message); 2403 2395 spin_unlock_irq(&current->sighand->siglock); 2396 + return signr; 2404 2397 } 2405 2398 2406 2399 /** ··· 2558 2545 signr = SIGTRAP; 2559 2546 WARN_ON_ONCE(!signr); 2560 2547 ptrace_do_notify(signr, signr | (PTRACE_EVENT_STOP << 8), 2561 - CLD_STOPPED); 2548 + CLD_STOPPED, 0); 2562 2549 } else { 2563 2550 WARN_ON_ONCE(!signr); 2564 - ptrace_stop(signr, CLD_STOPPED, 0, NULL); 2565 - current->exit_code = 0; 2551 + ptrace_stop(signr, CLD_STOPPED, 0, 0, NULL); 2566 2552 } 2567 2553 } 2568 2554 ··· 2614 2602 * comment in dequeue_signal(). 2615 2603 */ 2616 2604 current->jobctl |= JOBCTL_STOP_DEQUEUED; 2617 - ptrace_stop(signr, CLD_TRAPPED, 0, info); 2605 + signr = ptrace_stop(signr, CLD_TRAPPED, 0, 0, info); 2618 2606 2619 2607 /* We're back. Did the debugger cancel the sig? */ 2620 - signr = current->exit_code; 2621 2608 if (signr == 0) 2622 2609 return signr; 2623 - 2624 - current->exit_code = 0; 2625 2610 2626 2611 /* 2627 2612 * Update the siginfo structure if the signal has ··· 2676 2667 struct signal_struct *signal = current->signal; 2677 2668 int signr; 2678 2669 2679 - if (unlikely(current->task_works)) 2670 + clear_notify_signal(); 2671 + if (unlikely(task_work_pending(current))) 2680 2672 task_work_run(); 2681 2673 2682 - /* 2683 - * For non-generic architectures, check for TIF_NOTIFY_SIGNAL so 2684 - * that the arch handlers don't all have to do it. If we get here 2685 - * without TIF_SIGPENDING, just exit after running signal work. 2686 - */ 2687 - if (!IS_ENABLED(CONFIG_GENERIC_ENTRY)) { 2688 - if (test_thread_flag(TIF_NOTIFY_SIGNAL)) 2689 - tracehook_notify_signal(); 2690 - if (!task_sigpending(current)) 2691 - return false; 2692 - } 2674 + if (!task_sigpending(current)) 2675 + return false; 2693 2676 2694 2677 if (unlikely(uprobe_deny_signal())) 2695 2678 return false; ··· 2940 2939 set_current_blocked(&blocked); 2941 2940 if (current->sas_ss_flags & SS_AUTODISARM) 2942 2941 sas_ss_reset(current); 2943 - tracehook_signal_handler(stepping); 2942 + if (stepping) 2943 + ptrace_notify(SIGTRAP, 0); 2944 2944 } 2945 2945 2946 2946 void signal_setup_done(int failed, struct ksignal *ksig, int stepping)
+2 -2
kernel/task_work.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 #include <linux/spinlock.h> 3 3 #include <linux/task_work.h> 4 - #include <linux/tracehook.h> 4 + #include <linux/resume_user_mode.h> 5 5 6 6 static struct callback_head work_exited; /* all we need is ->next == NULL */ 7 7 ··· 78 78 struct callback_head *work; 79 79 unsigned long flags; 80 80 81 - if (likely(!task->task_works)) 81 + if (likely(!task_work_pending(task))) 82 82 return NULL; 83 83 /* 84 84 * If cmpxchg() fails we continue without updating pprev.
+1
kernel/time/posix-cpu-timers.c
··· 15 15 #include <linux/workqueue.h> 16 16 #include <linux/compat.h> 17 17 #include <linux/sched/deadline.h> 18 + #include <linux/task_work.h> 18 19 19 20 #include "posix-timers.h" 20 21
+1 -1
mm/memcontrol.c
··· 60 60 #include <linux/oom.h> 61 61 #include <linux/lockdep.h> 62 62 #include <linux/file.h> 63 - #include <linux/tracehook.h> 63 + #include <linux/resume_user_mode.h> 64 64 #include <linux/psi.h> 65 65 #include <linux/seq_buf.h> 66 66 #include "internal.h"
-1
security/apparmor/domain.c
··· 14 14 #include <linux/file.h> 15 15 #include <linux/mount.h> 16 16 #include <linux/syscalls.h> 17 - #include <linux/tracehook.h> 18 17 #include <linux/personality.h> 19 18 #include <linux/xattr.h> 20 19 #include <linux/user_namespace.h>
-1
security/selinux/hooks.c
··· 25 25 #include <linux/kd.h> 26 26 #include <linux/kernel.h> 27 27 #include <linux/kernel_read_file.h> 28 - #include <linux/tracehook.h> 29 28 #include <linux/errno.h> 30 29 #include <linux/sched/signal.h> 31 30 #include <linux/sched/task.h>