Skip to content

Commit 153474b

Browse files
committed
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 <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent 42da6b7 commit 153474b

File tree

30 files changed

+109
-126
lines changed

30 files changed

+109
-126
lines changed

arch/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ config TRACE_IRQFLAGS_SUPPORT
217217
# asm/syscall.h supplying asm-generic/syscall.h interface
218218
# linux/regset.h user_regset interfaces
219219
# 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}
221221
# TIF_NOTIFY_RESUME calls tracehook_notify_resume()
222222
# signal delivery calls tracehook_signal_handler()
223223
#

arch/alpha/kernel/ptrace.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <linux/user.h>
1616
#include <linux/security.h>
1717
#include <linux/signal.h>
18-
#include <linux/tracehook.h>
1918
#include <linux/audit.h>
2019

2120
#include <linux/uaccess.h>
@@ -323,7 +322,7 @@ asmlinkage unsigned long syscall_trace_enter(void)
323322
unsigned long ret = 0;
324323
struct pt_regs *regs = current_pt_regs();
325324
if (test_thread_flag(TIF_SYSCALL_TRACE) &&
326-
tracehook_report_syscall_entry(current_pt_regs()))
325+
ptrace_report_syscall_entry(current_pt_regs()))
327326
ret = -1UL;
328327
audit_syscall_entry(regs->r0, regs->r16, regs->r17, regs->r18, regs->r19);
329328
return ret ?: current_pt_regs()->r0;
@@ -334,5 +333,5 @@ syscall_trace_leave(void)
334333
{
335334
audit_syscall_exit(current_pt_regs());
336335
if (test_thread_flag(TIF_SYSCALL_TRACE))
337-
tracehook_report_syscall_exit(current_pt_regs(), 0);
336+
ptrace_report_syscall_exit(current_pt_regs(), 0);
338337
}

arch/arc/kernel/ptrace.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55

66
#include <linux/ptrace.h>
7-
#include <linux/tracehook.h>
87
#include <linux/sched/task_stack.h>
98
#include <linux/regset.h>
109
#include <linux/unistd.h>
@@ -258,13 +257,13 @@ long arch_ptrace(struct task_struct *child, long request,
258257

259258
asmlinkage int syscall_trace_entry(struct pt_regs *regs)
260259
{
261-
if (tracehook_report_syscall_entry(regs))
260+
if (ptrace_report_syscall_entry(regs))
262261
return ULONG_MAX;
263262

264263
return regs->r8;
265264
}
266265

267266
asmlinkage void syscall_trace_exit(struct pt_regs *regs)
268267
{
269-
tracehook_report_syscall_exit(regs, 0);
268+
ptrace_report_syscall_exit(regs, 0);
270269
}

arch/arm/kernel/ptrace.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <linux/hw_breakpoint.h>
2323
#include <linux/regset.h>
2424
#include <linux/audit.h>
25-
#include <linux/tracehook.h>
2625
#include <linux/unistd.h>
2726

2827
#include <asm/syscall.h>
@@ -843,8 +842,8 @@ static void report_syscall(struct pt_regs *regs, enum ptrace_syscall_dir dir)
843842
regs->ARM_ip = dir;
844843

845844
if (dir == PTRACE_SYSCALL_EXIT)
846-
tracehook_report_syscall_exit(regs, 0);
847-
else if (tracehook_report_syscall_entry(regs))
845+
ptrace_report_syscall_exit(regs, 0);
846+
else if (ptrace_report_syscall_entry(regs))
848847
current_thread_info()->abi_syscall = -1;
849848

850849
regs->ARM_ip = ip;

arch/arm64/kernel/ptrace.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <linux/perf_event.h>
2828
#include <linux/hw_breakpoint.h>
2929
#include <linux/regset.h>
30-
#include <linux/tracehook.h>
3130
#include <linux/elf.h>
3231

3332
#include <asm/compat.h>
@@ -1818,11 +1817,11 @@ static void report_syscall(struct pt_regs *regs, enum ptrace_syscall_dir dir)
18181817
regs->regs[regno] = dir;
18191818

18201819
if (dir == PTRACE_SYSCALL_ENTER) {
1821-
if (tracehook_report_syscall_entry(regs))
1820+
if (ptrace_report_syscall_entry(regs))
18221821
forget_syscall(regs);
18231822
regs->regs[regno] = saved_reg;
18241823
} else if (!test_thread_flag(TIF_SINGLESTEP)) {
1825-
tracehook_report_syscall_exit(regs, 0);
1824+
ptrace_report_syscall_exit(regs, 0);
18261825
regs->regs[regno] = saved_reg;
18271826
} else {
18281827
regs->regs[regno] = saved_reg;
@@ -1832,7 +1831,7 @@ static void report_syscall(struct pt_regs *regs, enum ptrace_syscall_dir dir)
18321831
* tracer modifications to the registers may have rewound the
18331832
* state machine.
18341833
*/
1835-
tracehook_report_syscall_exit(regs, 1);
1834+
ptrace_report_syscall_exit(regs, 1);
18361835
}
18371836
}
18381837

arch/csky/kernel/ptrace.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <linux/sched/task_stack.h>
1313
#include <linux/signal.h>
1414
#include <linux/smp.h>
15-
#include <linux/tracehook.h>
1615
#include <linux/uaccess.h>
1716
#include <linux/user.h>
1817

@@ -321,7 +320,7 @@ long arch_ptrace(struct task_struct *child, long request,
321320
asmlinkage int syscall_trace_enter(struct pt_regs *regs)
322321
{
323322
if (test_thread_flag(TIF_SYSCALL_TRACE))
324-
if (tracehook_report_syscall_entry(regs))
323+
if (ptrace_report_syscall_entry(regs))
325324
return -1;
326325

327326
if (secure_computing() == -1)
@@ -339,7 +338,7 @@ asmlinkage void syscall_trace_exit(struct pt_regs *regs)
339338
audit_syscall_exit(regs);
340339

341340
if (test_thread_flag(TIF_SYSCALL_TRACE))
342-
tracehook_report_syscall_exit(regs, 0);
341+
ptrace_report_syscall_exit(regs, 0);
343342

344343
if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
345344
trace_sys_exit(regs, syscall_get_return_value(current, regs));

arch/h8300/kernel/ptrace.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <linux/errno.h>
1313
#include <linux/ptrace.h>
1414
#include <linux/audit.h>
15-
#include <linux/tracehook.h>
1615
#include <linux/regset.h>
1716
#include <linux/elf.h>
1817

@@ -174,7 +173,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
174173
long ret = 0;
175174

176175
if (test_thread_flag(TIF_SYSCALL_TRACE) &&
177-
tracehook_report_syscall_entry(regs))
176+
ptrace_report_syscall_entry(regs))
178177
/*
179178
* Tracing decided this syscall should not happen.
180179
* We'll return a bogus call number to get an ENOSYS
@@ -196,5 +195,5 @@ asmlinkage void do_syscall_trace_leave(struct pt_regs *regs)
196195

197196
step = test_thread_flag(TIF_SINGLESTEP);
198197
if (step || test_thread_flag(TIF_SYSCALL_TRACE))
199-
tracehook_report_syscall_exit(regs, step);
198+
ptrace_report_syscall_exit(regs, step);
200199
}

arch/hexagon/kernel/traps.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <linux/kdebug.h>
1515
#include <linux/syscalls.h>
1616
#include <linux/signal.h>
17-
#include <linux/tracehook.h>
17+
#include <linux/ptrace.h>
1818
#include <asm/traps.h>
1919
#include <asm/vm_fault.h>
2020
#include <asm/syscall.h>
@@ -348,7 +348,7 @@ void do_trap0(struct pt_regs *regs)
348348

349349
/* allow strace to catch syscall args */
350350
if (unlikely(test_thread_flag(TIF_SYSCALL_TRACE) &&
351-
tracehook_report_syscall_entry(regs)))
351+
ptrace_report_syscall_entry(regs)))
352352
return; /* return -ENOSYS somewhere? */
353353

354354
/* Interrupts should be re-enabled for syscall processing */
@@ -386,7 +386,7 @@ void do_trap0(struct pt_regs *regs)
386386

387387
/* allow strace to get the syscall return state */
388388
if (unlikely(test_thread_flag(TIF_SYSCALL_TRACE)))
389-
tracehook_report_syscall_exit(regs, 0);
389+
ptrace_report_syscall_exit(regs, 0);
390390

391391
break;
392392
case TRAP_DEBUG:

arch/ia64/kernel/ptrace.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@ syscall_trace_enter (long arg0, long arg1, long arg2, long arg3,
12171217
struct pt_regs regs)
12181218
{
12191219
if (test_thread_flag(TIF_SYSCALL_TRACE))
1220-
if (tracehook_report_syscall_entry(&regs))
1220+
if (ptrace_report_syscall_entry(&regs))
12211221
return -ENOSYS;
12221222

12231223
/* copy user rbs to kernel rbs */
@@ -1243,7 +1243,7 @@ syscall_trace_leave (long arg0, long arg1, long arg2, long arg3,
12431243

12441244
step = test_thread_flag(TIF_SINGLESTEP);
12451245
if (step || test_thread_flag(TIF_SYSCALL_TRACE))
1246-
tracehook_report_syscall_exit(&regs, step);
1246+
ptrace_report_syscall_exit(&regs, step);
12471247

12481248
/* copy user rbs to kernel rbs */
12491249
if (test_thread_flag(TIF_RESTORE_RSE))

arch/m68k/kernel/ptrace.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <linux/ptrace.h>
2020
#include <linux/user.h>
2121
#include <linux/signal.h>
22-
#include <linux/tracehook.h>
22+
#include <linux/ptrace.h>
2323

2424
#include <linux/uaccess.h>
2525
#include <asm/page.h>
@@ -282,13 +282,13 @@ asmlinkage int syscall_trace_enter(void)
282282
int ret = 0;
283283

284284
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));
286286
return ret;
287287
}
288288

289289
asmlinkage void syscall_trace_leave(void)
290290
{
291291
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);
293293
}
294294
#endif /* CONFIG_COLDFIRE */

arch/microblaze/kernel/ptrace.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include <linux/elf.h>
3434
#include <linux/audit.h>
3535
#include <linux/seccomp.h>
36-
#include <linux/tracehook.h>
3736

3837
#include <linux/errno.h>
3938
#include <asm/processor.h>
@@ -140,7 +139,7 @@ asmlinkage unsigned long do_syscall_trace_enter(struct pt_regs *regs)
140139
secure_computing_strict(regs->r12);
141140

142141
if (test_thread_flag(TIF_SYSCALL_TRACE) &&
143-
tracehook_report_syscall_entry(regs))
142+
ptrace_report_syscall_entry(regs))
144143
/*
145144
* Tracing decided this syscall should not happen.
146145
* We'll return a bogus call number to get an ENOSYS
@@ -161,7 +160,7 @@ asmlinkage void do_syscall_trace_leave(struct pt_regs *regs)
161160

162161
step = test_thread_flag(TIF_SINGLESTEP);
163162
if (step || test_thread_flag(TIF_SYSCALL_TRACE))
164-
tracehook_report_syscall_exit(regs, step);
163+
ptrace_report_syscall_exit(regs, step);
165164
}
166165

167166
void ptrace_disable(struct task_struct *child)

arch/mips/kernel/ptrace.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <linux/smp.h>
2828
#include <linux/security.h>
2929
#include <linux/stddef.h>
30-
#include <linux/tracehook.h>
3130
#include <linux/audit.h>
3231
#include <linux/seccomp.h>
3332
#include <linux/ftrace.h>
@@ -1317,7 +1316,7 @@ asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall)
13171316
current_thread_info()->syscall = syscall;
13181317

13191318
if (test_thread_flag(TIF_SYSCALL_TRACE)) {
1320-
if (tracehook_report_syscall_entry(regs))
1319+
if (ptrace_report_syscall_entry(regs))
13211320
return -1;
13221321
syscall = current_thread_info()->syscall;
13231322
}
@@ -1376,7 +1375,7 @@ asmlinkage void syscall_trace_leave(struct pt_regs *regs)
13761375
trace_sys_exit(regs, regs_return_value(regs));
13771376

13781377
if (test_thread_flag(TIF_SYSCALL_TRACE))
1379-
tracehook_report_syscall_exit(regs, 0);
1378+
ptrace_report_syscall_exit(regs, 0);
13801379

13811380
user_enter();
13821381
}

arch/nds32/include/asm/syscall.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
3939
*
4040
* It's only valid to call this when @task is stopped for system
4141
* 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
4343
* the system call from taking place.
4444
*
4545
* This rolls back the register state in @regs so it's as if the

arch/nds32/kernel/ptrace.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#include <linux/ptrace.h>
55
#include <linux/regset.h>
6-
#include <linux/tracehook.h>
76
#include <linux/elf.h>
87
#include <linux/sched/task_stack.h>
98

@@ -103,7 +102,7 @@ void user_disable_single_step(struct task_struct *child)
103102
asmlinkage int syscall_trace_enter(struct pt_regs *regs)
104103
{
105104
if (test_thread_flag(TIF_SYSCALL_TRACE)) {
106-
if (tracehook_report_syscall_entry(regs))
105+
if (ptrace_report_syscall_entry(regs))
107106
forget_syscall(regs);
108107
}
109108
return regs->syscallno;
@@ -113,6 +112,6 @@ asmlinkage void syscall_trace_leave(struct pt_regs *regs)
113112
{
114113
int step = test_thread_flag(TIF_SINGLESTEP);
115114
if (step || test_thread_flag(TIF_SYSCALL_TRACE))
116-
tracehook_report_syscall_exit(regs, step);
115+
ptrace_report_syscall_exit(regs, step);
117116

118117
}

arch/nios2/kernel/ptrace.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <linux/regset.h>
1616
#include <linux/sched.h>
1717
#include <linux/sched/task_stack.h>
18-
#include <linux/tracehook.h>
1918
#include <linux/uaccess.h>
2019
#include <linux/user.h>
2120

@@ -134,13 +133,13 @@ asmlinkage int do_syscall_trace_enter(void)
134133
int ret = 0;
135134

136135
if (test_thread_flag(TIF_SYSCALL_TRACE))
137-
ret = tracehook_report_syscall_entry(task_pt_regs(current));
136+
ret = ptrace_report_syscall_entry(task_pt_regs(current));
138137

139138
return ret;
140139
}
141140

142141
asmlinkage void do_syscall_trace_exit(void)
143142
{
144143
if (test_thread_flag(TIF_SYSCALL_TRACE))
145-
tracehook_report_syscall_exit(task_pt_regs(current), 0);
144+
ptrace_report_syscall_exit(task_pt_regs(current), 0);
146145
}

arch/openrisc/kernel/ptrace.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <linux/ptrace.h>
2323
#include <linux/audit.h>
2424
#include <linux/regset.h>
25-
#include <linux/tracehook.h>
2625
#include <linux/elf.h>
2726

2827
#include <asm/thread_info.h>
@@ -159,7 +158,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
159158
long ret = 0;
160159

161160
if (test_thread_flag(TIF_SYSCALL_TRACE) &&
162-
tracehook_report_syscall_entry(regs))
161+
ptrace_report_syscall_entry(regs))
163162
/*
164163
* Tracing decided this syscall should not happen.
165164
* We'll return a bogus call number to get an ENOSYS
@@ -181,5 +180,5 @@ asmlinkage void do_syscall_trace_leave(struct pt_regs *regs)
181180

182181
step = test_thread_flag(TIF_SINGLESTEP);
183182
if (step || test_thread_flag(TIF_SYSCALL_TRACE))
184-
tracehook_report_syscall_exit(regs, step);
183+
ptrace_report_syscall_exit(regs, step);
185184
}

arch/parisc/kernel/ptrace.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <linux/elf.h>
1616
#include <linux/errno.h>
1717
#include <linux/ptrace.h>
18-
#include <linux/tracehook.h>
1918
#include <linux/user.h>
2019
#include <linux/personality.h>
2120
#include <linux/regset.h>
@@ -316,7 +315,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
316315
long do_syscall_trace_enter(struct pt_regs *regs)
317316
{
318317
if (test_thread_flag(TIF_SYSCALL_TRACE)) {
319-
int rc = tracehook_report_syscall_entry(regs);
318+
int rc = ptrace_report_syscall_entry(regs);
320319

321320
/*
322321
* As tracesys_next does not set %r28 to -ENOSYS
@@ -327,7 +326,7 @@ long do_syscall_trace_enter(struct pt_regs *regs)
327326
if (rc) {
328327
/*
329328
* A nonzero return code from
330-
* tracehook_report_syscall_entry() tells us
329+
* ptrace_report_syscall_entry() tells us
331330
* to prevent the syscall execution. Skip
332331
* the syscall call and the syscall restart handling.
333332
*
@@ -381,7 +380,7 @@ void do_syscall_trace_exit(struct pt_regs *regs)
381380
#endif
382381

383382
if (stepping || test_thread_flag(TIF_SYSCALL_TRACE))
384-
tracehook_report_syscall_exit(regs, stepping);
383+
ptrace_report_syscall_exit(regs, stepping);
385384
}
386385

387386

0 commit comments

Comments
 (0)