File: patch-linux-2.6.30.5-ptrace1-vm1

package info (click to toggle)
kernel-patch-viewos 0.20141201-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 1,352 kB
  • ctags: 22
  • sloc: sh: 494; makefile: 95
file content (87 lines) | stat: -rw-r--r-- 2,688 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
diff -Naur linux-2.6.30.5/include/linux/ptrace.h linux-2.6.30.5.vm1/include/linux/ptrace.h
--- linux-2.6.30.5/include/linux/ptrace.h	2009-08-16 23:19:38.000000000 +0200
+++ linux-2.6.30.5.vm1/include/linux/ptrace.h	2009-09-04 10:42:24.000000000 +0200
@@ -46,6 +46,11 @@
 #define PTRACE_EVENT_VFORK_DONE	5
 #define PTRACE_EVENT_EXIT	6
 
+/* options for new PTRACE_SYSCALL syntax*/
+#define PTRACE_SYSCALL_SKIPEXIT  0x2
+#define PTRACE_SYSCALL_SKIPCALL  0x6
+#define PTRACE_SYSCALL_MASK    0x00000006
+
 #include <asm/ptrace.h>
 
 #ifdef __KERNEL__
@@ -68,6 +73,11 @@
 #define PT_TRACE_VFORK_DONE	0x00000100
 #define PT_TRACE_EXIT	0x00000200
 
+#define PT_SYSCALL_SKIPEXIT  0x60000000
+#define PT_SYSCALL_SKIPCALL  0x40000000
+#define PT_SYSCALL_MASK      0x60000000
+#define PTRACE2PT_SYSCALL(X)	(((X) & PTRACE_SYSCALL_MASK) << 28)
+
 #define PT_TRACE_MASK	0x000003f4
 
 /* single stepping state bits (used on ARM and PA-RISC) */
diff -Naur linux-2.6.30.5/include/linux/tracehook.h linux-2.6.30.5.vm1/include/linux/tracehook.h
--- linux-2.6.30.5/include/linux/tracehook.h	2009-08-16 23:19:38.000000000 +0200
+++ linux-2.6.30.5.vm1/include/linux/tracehook.h	2009-09-04 10:42:24.000000000 +0200
@@ -112,7 +112,7 @@
 	struct pt_regs *regs)
 {
 	ptrace_report_syscall(regs);
-	return 0;
+	return (task_ptrace(current) & PT_SYSCALL_SKIPCALL) ? 1 : 0;
 }
 
 /**
@@ -134,7 +134,8 @@
  */
 static inline void tracehook_report_syscall_exit(struct pt_regs *regs, int step)
 {
-	ptrace_report_syscall(regs);
+	if (!(task_ptrace(current) & PT_SYSCALL_SKIPEXIT))
+		ptrace_report_syscall(regs);
 }
 
 /**
diff -Naur linux-2.6.30.5/kernel/ptrace.c linux-2.6.30.5.vm1/kernel/ptrace.c
--- linux-2.6.30.5/kernel/ptrace.c	2009-08-16 23:19:38.000000000 +0200
+++ linux-2.6.30.5.vm1/kernel/ptrace.c	2009-09-04 10:42:24.000000000 +0200
@@ -471,7 +471,8 @@
 #define is_sysemu_singlestep(request)	0
 #endif
 
-static int ptrace_resume(struct task_struct *child, long request, long data)
+static int ptrace_resume(struct task_struct *child, long request, 
+		   long addr, long data)
 {
 	if (!valid_signal(data))
 		return -EIO;
@@ -500,6 +501,9 @@
 		user_disable_single_step(child);
 	}
 
+	child->ptrace &= ~PT_SYSCALL_MASK;
+	child->ptrace |= PTRACE2PT_SYSCALL(addr);
+
 	child->exit_code = data;
 	wake_up_process(child);
 
@@ -561,12 +565,12 @@
 #endif
 	case PTRACE_SYSCALL:
 	case PTRACE_CONT:
-		return ptrace_resume(child, request, data);
+		return ptrace_resume(child, request, addr, data);
 
 	case PTRACE_KILL:
 		if (child->exit_state)	/* already dead */
 			return 0;
-		return ptrace_resume(child, request, SIGKILL);
+		return ptrace_resume(child, request, addr, SIGKILL);
 
 	default:
 		break;