Skip to content

Commit 0693bf6

Browse files
Wade FarnsworthRussell King
authored andcommitted
ARM: 7374/1: add TRACEHOOK support
Add calls to tracehook_report_syscall_{entry,exit} and tracehook_signal_handler Signed-off-by: Steven Walter <stevenrwalter@gmail.com> Signed-off-by: Wade Farnsworth <wade_farnsworth@mentor.com> Reviewed-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent bf2c9f9 commit 0693bf6

4 files changed

Lines changed: 14 additions & 15 deletions

File tree

‎arch/arm/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ config ARM
1111
select HAVE_OPROFILE if (HAVE_PERF_EVENTS)
1212
select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL
1313
select HAVE_ARCH_KGDB
14+
select HAVE_ARCH_TRACEHOOK
1415
select HAVE_KPROBES if !XIP_KERNEL
1516
select HAVE_KRETPROBES if (HAVE_KPROBES)
1617
select HAVE_FUNCTION_TRACER if (!XIP_KERNEL)

‎arch/arm/include/asm/ptrace.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,11 @@ static inline unsigned long kernel_stack_pointer(struct pt_regs *regs)
249249
return regs->ARM_sp;
250250
}
251251

252+
static inline unsigned long user_stack_pointer(struct pt_regs *regs)
253+
{
254+
return regs->ARM_sp;
255+
}
256+
252257
#endif /* __KERNEL__ */
253258

254259
#endif /* __ASSEMBLY__ */

‎arch/arm/kernel/ptrace.c‎

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/hw_breakpoint.h>
2525
#include <linux/regset.h>
2626
#include <linux/audit.h>
27+
#include <linux/tracehook.h>
2728

2829
#include <asm/pgtable.h>
2930
#include <asm/traps.h>
@@ -931,24 +932,14 @@ asmlinkage int syscall_trace(int why, struct pt_regs *regs, int scno)
931932

932933
if (!test_thread_flag(TIF_SYSCALL_TRACE))
933934
return scno;
934-
if (!(current->ptrace & PT_PTRACED))
935-
return scno;
936935

937936
current_thread_info()->syscall = scno;
938937

939-
/* the 0x80 provides a way for the tracing parent to distinguish
940-
between a syscall stop and SIGTRAP delivery */
941-
ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
942-
? 0x80 : 0));
943-
/*
944-
* this isn't the same as continuing with a signal, but it will do
945-
* for normal use. strace only continues with a signal if the
946-
* stopping signal is not SIGTRAP. -brl
947-
*/
948-
if (current->exit_code) {
949-
send_sig(current->exit_code, current, 1);
950-
current->exit_code = 0;
951-
}
938+
if (why)
939+
tracehook_report_syscall_exit(regs, 0);
940+
else if (tracehook_report_syscall_entry(regs))
941+
current_thread_info()->syscall = -1;
942+
952943
regs->ARM_ip = ip;
953944

954945
return current_thread_info()->syscall;

‎arch/arm/kernel/signal.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,8 @@ handle_signal(unsigned long sig, struct k_sigaction *ka,
636636
*/
637637
block_sigmask(ka, sig);
638638

639+
tracehook_signal_handler(sig, info, ka, regs, 0);
640+
639641
return 0;
640642
}
641643

0 commit comments

Comments
 (0)