]> git.pld-linux.org Git - packages/kernel.git/blame - linux-ptrace.patch
- obsolete
[packages/kernel.git] / linux-ptrace.patch
CommitLineData
eab03de1
JR
1diff -urN linux249ac18/arch/s390/kernel/signal.c linux2410ac7/arch/s390/kernel/signal.c
2--- linux249ac18/arch/s390/kernel/signal.c Thu Oct 4 14:25:04 2001
3+++ linux2410ac7/arch/s390/kernel/signal.c Sat Oct 6 22:09:44 2001
4@@ -24,6 +24,7 @@
5 #include <linux/ptrace.h>
6 #include <linux/unistd.h>
7 #include <linux/stddef.h>
8+#include <linux/personality.h>
9 #include <asm/ucontext.h>
10 #include <asm/uaccess.h>
11
12@@ -543,13 +544,16 @@
13 continue;
14 /* FALLTHRU */
15
16- case SIGSTOP:
17+ case SIGSTOP: {
18+ struct signal_struct *sig;
19 set_current_state(TASK_STOPPED);
20 current->exit_code = signr;
21- if (!(current->p_pptr->sig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP))
22+ sig = current->p_pptr->sig;
23+ if (sig && !(sig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP))
24 notify_parent(current, SIGCHLD);
25 schedule();
26 continue;
27+ }
28
29 case SIGQUIT: case SIGILL: case SIGTRAP:
30 case SIGABRT: case SIGFPE: case SIGSEGV:
31diff -urN linux249ac18/arch/i386/kernel/ptrace.c linux2410ac7/arch/i386/kernel/ptrace.c
32--- linux249ac18/arch/i386/kernel/ptrace.c Thu Oct 4 14:24:59 2001
33+++ linux2410ac7/arch/i386/kernel/ptrace.c Wed Sep 19 01:04:23 2001
34@@ -134,6 +134,19 @@
35 return retval;
36 }
37
38+/*
39+ * Called by kernel/ptrace.c when detaching..
40+ *
41+ * Make sure the single step bit is not set.
42+ */
43+void ptrace_disable(struct task_struct *child)
44+{
45+ long tmp;
46+
47+ tmp = get_stack_long(child, EFL_OFFSET) & ~TRAP_FLAG;
48+ put_stack_long(child, EFL_OFFSET, tmp);
49+}
50+
51 asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
52 {
53 struct task_struct *child;
54@@ -320,26 +333,10 @@
55 break;
56 }
57
58- case PTRACE_DETACH: { /* detach a process that was attached. */
59- long tmp;
60-
61- ret = -EIO;
62- if ((unsigned long) data > _NSIG)
63- break;
64- child->ptrace = 0;
65- child->exit_code = data;
66- write_lock_irq(&tasklist_lock);
67- REMOVE_LINKS(child);
68- child->p_pptr = child->p_opptr;
69- SET_LINKS(child);
70- write_unlock_irq(&tasklist_lock);
71- /* make sure the single step bit is not set. */
72- tmp = get_stack_long(child, EFL_OFFSET) & ~TRAP_FLAG;
73- put_stack_long(child, EFL_OFFSET, tmp);
74- wake_up_process(child);
75- ret = 0;
76+ case PTRACE_DETACH:
77+ /* detach a process that was attached. */
78+ ret = ptrace_detach(child, data);
79 break;
80- }
81
82 case PTRACE_GETREGS: { /* Get all gp regs from the child. */
83 if (!access_ok(VERIFY_WRITE, (unsigned *)data, FRAME_SIZE*sizeof(long))) {
84diff -urN linux249ac18/arch/s390x/kernel/ptrace.c linux2410ac7/arch/s390x/kernel/ptrace.c
85--- linux249ac18/arch/s390x/kernel/ptrace.c Fri Jul 20 20:39:55 2001
86+++ linux2410ac7/arch/s390x/kernel/ptrace.c Wed Sep 19 00:56:19 2001
87@@ -216,6 +216,17 @@
88 return(0);
89 }
90
91+/*
92+ * Called by kernel/ptrace.c when detaching..
93+ *
94+ * Make sure single step bits etc are not set.
95+ */
96+void ptrace_disable(struct task_struct *child)
97+{
98+ /* make sure the single step bit is not set. */
99+ clear_single_step(child);
100+}
101+
102 asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
103 {
104 struct task_struct *child;
105@@ -341,21 +352,9 @@
106 break;
107
108 case PTRACE_DETACH: /* detach a process that was attached. */
109- ret = -EIO;
110- if ((unsigned long) data >= _NSIG)
111- break;
112- child->ptrace &= ~(PT_PTRACED|PT_TRACESYS);
113- child->exit_code = data;
114- write_lock_irqsave(&tasklist_lock, flags);
115- REMOVE_LINKS(child);
116- child->p_pptr = child->p_opptr;
117- SET_LINKS(child);
118- write_unlock_irqrestore(&tasklist_lock, flags);
119- /* make sure the single step bit is not set. */
120- clear_single_step(child);
121- wake_up_process(child);
122- ret = 0;
123+ ret = ptrace_detach(child, data);
124 break;
125+
126 case PTRACE_PEEKUSR_AREA:
127 case PTRACE_POKEUSR_AREA:
128 if((ret=copy_from_user(&parea,(void *)addr,sizeof(parea)))==0)
129diff -urN linux249ac18/arch/s390x/kernel/signal.c linux2410ac7/arch/s390x/kernel/signal.c
130--- linux249ac18/arch/s390x/kernel/signal.c Thu Oct 4 14:25:04 2001
131+++ linux2410ac7/arch/s390x/kernel/signal.c Sat Oct 6 22:09:45 2001
132@@ -24,6 +24,7 @@
133 #include <linux/ptrace.h>
134 #include <linux/unistd.h>
135 #include <linux/stddef.h>
136+#include <linux/personality.h>
137 #include <asm/ucontext.h>
138 #include <asm/uaccess.h>
139
140@@ -549,13 +550,16 @@
141 continue;
142 /* FALLTHRU */
143
144- case SIGSTOP:
145+ case SIGSTOP: {
146+ struct signal_struct *sig;
147 set_current_state(TASK_STOPPED);
148 current->exit_code = signr;
149- if (!(current->p_pptr->sig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP))
150+ sig = current->p_pptr->sig;
151+ if (sig && !(sig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP))
152 notify_parent(current, SIGCHLD);
153 schedule();
154 continue;
155+ }
156
157 case SIGQUIT: case SIGILL: case SIGTRAP:
158 case SIGABRT: case SIGFPE: case SIGSEGV:
159diff -urN linux249ac18/arch/i386/kernel/signal.c linux2410ac7/arch/i386/kernel/signal.c
160--- linux249ac18/arch/i386/kernel/signal.c Thu Oct 4 14:24:59 2001
161+++ linux2410ac7/arch/i386/kernel/signal.c Fri Sep 14 22:15:40 2001
162@@ -666,13 +666,16 @@
163 continue;
164 /* FALLTHRU */
165
166- case SIGSTOP:
167+ case SIGSTOP: {
168+ struct signal_struct *sig;
169 current->state = TASK_STOPPED;
170 current->exit_code = signr;
171- if (!(current->p_pptr->sig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP))
172+ sig = current->p_pptr->sig;
173+ if (sig && !(sig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP))
174 notify_parent(current, SIGCHLD);
175 schedule();
176 continue;
177+ }
178
179 case SIGQUIT: case SIGILL: case SIGTRAP:
180 case SIGABRT: case SIGFPE: case SIGSEGV:
181diff -urN linux249ac18/fs/exec.c linux2410ac7/fs/exec.c
182--- linux249ac18/fs/exec.c Thu Oct 4 14:25:28 2001
183+++ linux2410ac7/fs/exec.c Tue Sep 18 21:39:32 2001
184@@ -34,6 +34,7 @@
185 #include <linux/pagemap.h>
186 #include <linux/highmem.h>
187 #include <linux/spinlock.h>
188+#include <linux/personality.h>
189 #define __NO_VERSION__
190 #include <linux/module.h>
191
192@@ -186,7 +187,7 @@
193 int len;
194 unsigned long pos;
195
196- if (get_user(str, argv+argc) || !str || !(len = strnlen_user(str, bprm->p)))
197+ if (get_user(str, argv+argc) || !(len = strnlen_user(str, bprm->p)))
198 return -EFAULT;
199 if (bprm->p < len)
200 return -E2BIG;
201@@ -597,7 +598,7 @@
202 */
203 static inline int must_not_trace_exec(struct task_struct * p)
204 {
205- return (p->ptrace & PT_PTRACED) && !cap_raised(p->p_pptr->cap_effective, CAP_SYS_PTRACE);
206+ return (p->ptrace & PT_PTRACED) && !(p->ptrace & PT_PTRACE_CAP);
207 }
208
209 /*
210diff -urN linux249ac18/arch/ia64/kernel/ptrace.c linux2410ac7/arch/ia64/kernel/ptrace.c
211--- linux249ac18/arch/ia64/kernel/ptrace.c Tue Jul 31 18:30:08 2001
212+++ linux2410ac7/arch/ia64/kernel/ptrace.c Wed Sep 19 01:03:51 2001
213@@ -789,6 +789,21 @@
214 return 0;
215 }
216
217+/*
218+ * Called by kernel/ptrace.c when detaching..
219+ *
220+ * Make sure the single step bit is not set.
221+ */
222+void ptrace_disable(struct task_struct *child)
223+{
224+ /* make sure the single step/take-branch tra bits are not set: */
225+ ia64_psr(pt)->ss = 0;
226+ ia64_psr(pt)->tb = 0;
227+
228+ /* Turn off flag indicating that the KRBS is sync'd with child's VM: */
229+ child->thread.flags &= ~IA64_THREAD_KRBS_SYNCED;
230+}
231+
232 asmlinkage long
233 sys_ptrace (long request, pid_t pid, unsigned long addr, unsigned long data,
234 long arg4, long arg5, long arg6, long arg7, long stack)
235@@ -965,27 +980,7 @@
236 goto out_tsk;
237
238 case PTRACE_DETACH: /* detach a process that was attached. */
239- ret = -EIO;
240- if (data > _NSIG)
241- goto out_tsk;
242-
243- child->ptrace &= ~(PT_PTRACED|PT_TRACESYS);
244- child->exit_code = data;
245- write_lock_irqsave(&tasklist_lock, flags);
246- REMOVE_LINKS(child);
247- child->p_pptr = child->p_opptr;
248- SET_LINKS(child);
249- write_unlock_irqrestore(&tasklist_lock, flags);
250-
251- /* make sure the single step/take-branch tra bits are not set: */
252- ia64_psr(pt)->ss = 0;
253- ia64_psr(pt)->tb = 0;
254-
255- /* Turn off flag indicating that the KRBS is sync'd with child's VM: */
256- child->thread.flags &= ~IA64_THREAD_KRBS_SYNCED;
257-
258- wake_up_process(child);
259- ret = 0;
260+ ret = ptrace_detach(child, data);
261 goto out_tsk;
262
263 default:
264diff -urN linux249ac18/include/linux/mm.h linux2410ac7/include/linux/mm.h
265--- linux249ac18/include/linux/mm.h Thu Oct 4 14:25:37 2001
266+++ linux2410ac7/include/linux/mm.h Sat Oct 6 22:10:14 2001
267@@ -450,6 +450,8 @@
268 extern int ptrace_readdata(struct task_struct *tsk, unsigned long src, char *dst, int len);
269 extern int ptrace_writedata(struct task_struct *tsk, char * src, unsigned long dst, int len);
270 extern int ptrace_attach(struct task_struct *tsk);
271+extern int ptrace_detach(struct task_struct *, unsigned int);
272+extern void ptrace_disable(struct task_struct *);
273
274 /*
275 * On a two-level page table, this ends up being trivial. Thus the
276diff -urN linux249ac18/include/linux/sched.h linux2410ac7/include/linux/sched.h
277--- linux249ac18/include/linux/sched.h Thu Oct 4 14:25:37 2001
278+++ linux2410ac7/include/linux/sched.h Sat Oct 6 22:10:14 2001
279@@ -432,6 +432,7 @@
280 #define PT_TRACESYS 0x00000002
281 #define PT_DTRACE 0x00000004 /* delayed trace (used on m68k, i386) */
282 #define PT_TRACESYSGOOD 0x00000008
283+#define PT_PTRACE_CAP 0x00000010 /* ptracer can follow suid-exec */
284
285 /*
286 * Limit the stack by to some sane default: root can always
287diff -urN linux249ac18/arch/ppc/kernel/ptrace.c linux2410ac7/arch/ppc/kernel/ptrace.c
288--- linux249ac18/arch/ppc/kernel/ptrace.c Fri Jul 20 20:39:55 2001
289+++ linux2410ac7/arch/ppc/kernel/ptrace.c Wed Sep 19 00:56:19 2001
290@@ -89,6 +89,17 @@
291 regs->msr &= ~MSR_SE;
292 }
293
294+/*
295+ * Called by kernel/ptrace.c when detaching..
296+ *
297+ * Make sure single step bits etc are not set.
298+ */
299+void ptrace_disable(struct task_struct *child)
300+{
301+ /* make sure the single step bit is not set. */
302+ clear_single_step(child);
303+}
304+
305 int sys_ptrace(long request, long pid, long addr, long data)
306 {
307 struct task_struct *child;
308@@ -249,23 +260,9 @@
309 break;
310 }
311
312- case PTRACE_DETACH: { /* detach a process that was attached. */
313- ret = -EIO;
314- if ((unsigned long) data > _NSIG)
315- break;
316- child->ptrace &= ~(PT_PTRACED|PT_TRACESYS);
317- child->exit_code = data;
318- write_lock_irq(&tasklist_lock);
319- REMOVE_LINKS(child);
320- child->p_pptr = child->p_opptr;
321- SET_LINKS(child);
322- write_unlock_irq(&tasklist_lock);
323- /* make sure the single step bit is not set. */
324- clear_single_step(child);
325- wake_up_process(child);
326- ret = 0;
327+ case PTRACE_DETACH:
328+ ret = ptrace_detach(child, data);
329 break;
330- }
331
332 default:
333 ret = -EIO;
334diff -urN linux249ac18/arch/s390/kernel/ptrace.c linux2410ac7/arch/s390/kernel/ptrace.c
335--- linux249ac18/arch/s390/kernel/ptrace.c Fri Jul 20 20:39:55 2001
336+++ linux2410ac7/arch/s390/kernel/ptrace.c Wed Sep 19 00:58:03 2001
337@@ -202,6 +202,17 @@
338 return(0);
339 }
340
341+/*
342+ * Called by kernel/ptrace.c when detaching..
343+ *
344+ * Make sure single step bits etc are not set.
345+ */
346+void ptrace_disable(struct task_struct *child)
347+{
348+ /* make sure the single step bit is not set. */
349+ clear_single_step(child);
350+}
351+
352 asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
353 {
354 struct task_struct *child;
355@@ -327,20 +338,7 @@
356 break;
357
358 case PTRACE_DETACH: /* detach a process that was attached. */
359- ret = -EIO;
360- if ((unsigned long) data >= _NSIG)
361- break;
362- child->ptrace &= ~(PT_PTRACED|PT_TRACESYS);
363- child->exit_code = data;
364- write_lock_irqsave(&tasklist_lock, flags);
365- REMOVE_LINKS(child);
366- child->p_pptr = child->p_opptr;
367- SET_LINKS(child);
368- write_unlock_irqrestore(&tasklist_lock, flags);
369- /* make sure the single step bit is not set. */
370- clear_single_step(child);
371- wake_up_process(child);
372- ret = 0;
373+ ret = ptrace_detach(child, data);
374 break;
375 case PTRACE_PEEKUSR_AREA:
376 case PTRACE_POKEUSR_AREA:
377diff -urN linux249ac18/arch/s390/kernel/s390_ksyms.c linux2410ac7/arch/s390/kernel/s390_ksyms.c
378--- linux249ac18/arch/s390/kernel/s390_ksyms.c Thu Oct 4 14:25:04 2001
379+++ linux2410ac7/arch/s390/kernel/s390_ksyms.c Sat Oct 6 22:09:44 2001
380@@ -58,9 +58,5 @@
381 EXPORT_SYMBOL(console_device);
382 EXPORT_SYMBOL_NOVERS(do_call_softirq);
383
384-#if CONFIG_IP_MULTICAST
385-/* Required for lcs gigabit ethernet multicast support */
386-EXPORT_SYMBOL(arp_mc_map);
387-#endif
388
389
390diff -urN linux249ac18/kernel/ptrace.c linux2410ac7/kernel/ptrace.c
391--- linux249ac18/kernel/ptrace.c Fri Jul 20 20:39:56 2001
392+++ linux2410ac7/kernel/ptrace.c Wed Sep 19 00:32:16 2001
393@@ -42,6 +42,8 @@
394
395 /* Go */
396 task->ptrace |= PT_PTRACED;
397+ if (capable(CAP_SYS_PTRACE))
398+ task->ptrace |= PT_PTRACE_CAP;
399 task_unlock(task);
400
401 write_lock_irq(&tasklist_lock);
402@@ -60,6 +62,27 @@
403 return -EPERM;
404 }
405
406+int ptrace_detach(struct task_struct *child, unsigned int data)
407+{
408+ if ((unsigned long) data > _NSIG)
409+ return -EIO;
410+
411+ /* Architecture-specific hardware disable .. */
412+ ptrace_disable(child);
413+
414+ /* .. re-parent .. */
415+ child->ptrace = 0;
416+ child->exit_code = data;
417+ write_lock_irq(&tasklist_lock);
418+ REMOVE_LINKS(child);
419+ child->p_pptr = child->p_opptr;
420+ SET_LINKS(child);
421+ write_unlock_irq(&tasklist_lock);
422+
423+ /* .. and wake it up. */
424+ wake_up_process(child);
425+ return 0;
426+}
427
428 /*
429 * Access another process' address space, one page at a time.
430diff -urN linux249ac18/arch/alpha/kernel/ptrace.c linux2410ac7/arch/alpha/kernel/ptrace.c
431--- linux249ac18/arch/alpha/kernel/ptrace.c Fri Jul 20 20:39:55 2001
432+++ linux2410ac7/arch/alpha/kernel/ptrace.c Wed Sep 19 01:03:51 2001
433@@ -233,6 +233,16 @@
434 return (nsaved != 0);
435 }
436
437+/*
438+ * Called by kernel/ptrace.c when detaching..
439+ *
440+ * Make sure the single step bit is not set.
441+ */
442+void ptrace_disable(struct task_struct *child)
443+{
444+ ptrace_cancel_bpt(child);
445+}
446+
447 asmlinkage long
448 sys_ptrace(long request, long pid, long addr, long data,
449 int a4, int a5, struct pt_regs regs)
450@@ -362,21 +372,8 @@
451 ret = 0;
452 goto out;
453
454- case PTRACE_DETACH: /* detach a process that was attached. */
455- ret = -EIO;
456- if ((unsigned long) data > _NSIG)
457- goto out;
458- child->ptrace &= ~(PT_PTRACED|PT_TRACESYS);
459- wake_up_process(child);
460- child->exit_code = data;
461- write_lock_irq(&tasklist_lock);
462- REMOVE_LINKS(child);
463- child->p_pptr = child->p_opptr;
464- SET_LINKS(child);
465- write_unlock_irq(&tasklist_lock);
466- /* make sure single-step breakpoint is gone. */
467- ptrace_cancel_bpt(child);
468- ret = 0;
469+ case PTRACE_DETACH: /* detach a process that was attached. */
470+ ret = ptrace_detach(child, data);
471 goto out;
472
473 default:
474
475--- linux/arch/ia64/kernel/ptrace.c~ Sun Oct 7 14:03:08 2001
476+++ linux/arch/ia64/kernel/ptrace.c Sun Oct 7 14:15:24 2001
477@@ -797,6 +797,8 @@
478 void ptrace_disable(struct task_struct *child)
479 {
480 /* make sure the single step/take-branch tra bits are not set: */
481+ struct pt_regs *pt;
482+ pt = ia64_task_regs(child);
483 ia64_psr(pt)->ss = 0;
484 ia64_psr(pt)->tb = 0;
485
486--- linux/arch/alpha/kernel/signal.c~ Wed Jan 24 23:16:23 2001
487+++ linux/arch/alpha/kernel/signal.c Mon Oct 8 18:13:55 2001
488@@ -697,15 +697,18 @@
489 continue;
490 /* FALLTHRU */
491
492- case SIGSTOP:
493+ case SIGSTOP: {
494+ struct signal_struct *sig;
495 current->state = TASK_STOPPED;
496 current->exit_code = signr;
497- if (!(current->p_pptr->sig->action[SIGCHLD-1]
498+ sig = current->p_pptr->sig;
499+ if (sig && !(sig->action[SIGCHLD-1]
500 .sa.sa_flags & SA_NOCLDSTOP))
501 notify_parent(current, SIGCHLD);
502 schedule();
503 single_stepping |= ptrace_cancel_bpt(current);
504 continue;
505+ }
506
507 case SIGQUIT: case SIGILL: case SIGTRAP:
508 case SIGABRT: case SIGFPE: case SIGSEGV:
509--- linux/arch/ppc/kernel/signal.c~ Tue May 22 01:04:47 2001
510+++ linux/arch/ppc/kernel/signal.c Mon Oct 8 19:26:20 2001
511@@ -625,14 +625,16 @@
512 continue;
513 /* FALLTHRU */
514
515- case SIGSTOP:
516+ case SIGSTOP: {
517+ struct signal_struct *sig;
518 current->state = TASK_STOPPED;
519 current->exit_code = signr;
520- if (!(current->p_pptr->sig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP))
521+ sig = current->p_pptr->sig;
522+ if (sig && !(sig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP))
523 notify_parent(current, SIGCHLD);
524 schedule();
525 continue;
526-
527+ }
528 case SIGQUIT: case SIGILL: case SIGTRAP:
529 case SIGABRT: case SIGFPE: case SIGSEGV:
530 case SIGBUS: case SIGSYS: case SIGXCPU: case SIGXFSZ:
This page took 0.431173 seconds and 4 git commands to generate.