1 From: Gerald Schaefer <geraldsc@de.ibm.com>
2 Subject: [x86] system call notification with self_ptrace
5 Implement PTRACE SELF for x86. See patches.suse/self-ptrace.patch
6 for more documentation.
8 Signed-off-by: Pierre Morel <pmorel@fr.ibm.com>
9 Signed-off-by: Volker Sameske <sameske@de.ibm.com>
11 Acked-by: John Jolly <jjolly@suse.de>
14 arch/x86/kernel/ptrace.c | 14 ++++++++++++++
15 arch/x86/kernel/signal_32.c | 5 +++++
16 arch/x86/kernel/signal_64.c | 5 +++++
17 3 files changed, 24 insertions(+)
19 --- linux-2.6.26.orig/arch/x86/kernel/ptrace.c 2008-09-26 10:21:51.000000000 +0200
20 +++ linux-2.6.26/arch/x86/kernel/ptrace.c 2008-09-26 10:22:23.000000000 +0200
21 @@ -1429,6 +1429,17 @@ asmregparm long syscall_trace_enter(stru
22 /* do the secure computing check first */
23 secure_computing(regs->orig_ax);
25 + if (is_self_ptracing(regs->orig_ax)) {
26 + struct siginfo info;
28 + memset(&info, 0, sizeof(struct siginfo));
29 + info.si_signo = SIGSYS;
30 + info.si_code = SYS_SYSCALL;
31 + info.si_addr = (void *) regs->orig_ax;
32 + send_sig_info(SIGSYS, &info, current);
33 + return -1L; /* Skip system call, deliver signal. */
36 if (unlikely(test_thread_flag(TIF_SYSCALL_EMU)))
39 @@ -1455,6 +1466,9 @@ asmregparm long syscall_trace_enter(stru
41 asmregparm void syscall_trace_leave(struct pt_regs *regs)
43 + if (is_self_ptracing(regs->orig_ax)) {
46 if (unlikely(current->audit_context))
47 audit_syscall_exit(AUDITSC_RESULT(regs->ax), regs->ax);
49 --- linux-2.6.26.orig/arch/x86/kernel/signal_32.c 2008-09-26 10:21:51.000000000 +0200
50 +++ linux-2.6.26/arch/x86/kernel/signal_32.c 2008-09-26 10:22:23.000000000 +0200
51 @@ -568,6 +568,11 @@ handle_signal(unsigned long sig, siginfo
53 spin_unlock_irq(¤t->sighand->siglock);
55 + if (current->instrumentation & PTS_SELF) {
56 + clear_thread_flag(TIF_SYSCALL_TRACE);
57 + current->instrumentation &= ~PTS_SELF;
63 --- linux-2.6.26.orig/arch/x86/kernel/signal_64.c 2008-09-26 10:21:51.000000000 +0200
64 +++ linux-2.6.26/arch/x86/kernel/signal_64.c 2008-09-26 10:22:23.000000000 +0200
65 @@ -464,6 +464,11 @@ handle_signal(unsigned long sig, siginfo
66 spin_unlock_irq(¤t->sighand->siglock);
69 + if (current->instrumentation & PTS_SELF) {
70 + clear_thread_flag(TIF_SYSCALL_TRACE);
71 + current->instrumentation &= ~PTS_SELF;