]> git.ipfire.org Git - ipfire-2.x.git/blob - src/patches/suse-2.6.27.39/patches.arch/x86-self-ptrace.patch
Imported linux-2.6.27.39 suse/xen patches.
[ipfire-2.x.git] / src / patches / suse-2.6.27.39 / patches.arch / x86-self-ptrace.patch
1 From: Gerald Schaefer <geraldsc@de.ibm.com>
2 Subject: [x86] system call notification with self_ptrace
3 References: bnc#417299
4
5 Implement PTRACE SELF for x86. See patches.suse/self-ptrace.patch
6 for more documentation.
7
8 Signed-off-by: Pierre Morel <pmorel@fr.ibm.com>
9 Signed-off-by: Volker Sameske <sameske@de.ibm.com>
10
11 Acked-by: John Jolly <jjolly@suse.de>
12 ---
13
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(+)
18
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);
24
25 + if (is_self_ptracing(regs->orig_ax)) {
26 + struct siginfo info;
27 +
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. */
34 + }
35 +
36 if (unlikely(test_thread_flag(TIF_SYSCALL_EMU)))
37 ret = -1L;
38
39 @@ -1455,6 +1466,9 @@ asmregparm long syscall_trace_enter(stru
40
41 asmregparm void syscall_trace_leave(struct pt_regs *regs)
42 {
43 + if (is_self_ptracing(regs->orig_ax)) {
44 + return;
45 + }
46 if (unlikely(current->audit_context))
47 audit_syscall_exit(AUDITSC_RESULT(regs->ax), regs->ax);
48
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
52 recalc_sigpending();
53 spin_unlock_irq(&current->sighand->siglock);
54
55 + if (current->instrumentation & PTS_SELF) {
56 + clear_thread_flag(TIF_SYSCALL_TRACE);
57 + current->instrumentation &= ~PTS_SELF;
58 + }
59 +
60 return 0;
61 }
62
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(&current->sighand->siglock);
67 }
68
69 + if (current->instrumentation & PTS_SELF) {
70 + clear_thread_flag(TIF_SYSCALL_TRACE);
71 + current->instrumentation &= ~PTS_SELF;
72 + }
73 +
74 return ret;
75 }
76