/[linux-patches]/genpatches-2.6/trunk/2.6.14/1445_15.5_zap_thread-ptrace.patch
Gentoo

Contents of /genpatches-2.6/trunk/2.6.14/1445_15.5_zap_thread-ptrace.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 328 - (show annotations) (download) (as text)
Tue Mar 14 13:34:17 2006 UTC (14 years, 7 months ago) by johnm
File MIME type: text/x-diff
File size: 2933 byte(s)
2.6.14-11, rebase against local tree
1 From: Oleg Nesterov <oleg@tv-sign.ru>
2 Date: Wed, 15 Feb 2006 19:50:10 +0000 (+0300)
3 Subject: [PATCH] fix zap_thread's ptrace related problems
4 X-Git-Url: http://www.kernel.org/git/?p=linux/kernel/git/chrisw/linux-2.6.15.y.git;a=commitdiff;h=80a16577362b3eafa2f390d5e1ffb268464ccedb
5
6 [PATCH] fix zap_thread's ptrace related problems
7
8 1. The tracee can go from ptrace_stop() to do_signal_stop()
9 after __ptrace_unlink(p).
10
11 2. It is unsafe to __ptrace_unlink(p) while p->parent may wait
12 for tasklist_lock in ptrace_detach().
13
14 Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
15 Cc: Roland McGrath <roland@redhat.com>
16 Cc: Ingo Molnar <mingo@elte.hu>
17 Cc: Christoph Hellwig <hch@lst.de>
18 Cc: Eric W. Biederman <ebiederm@xmission.com>
19 Signed-off-by: Linus Torvalds <torvalds@osdl.org>
20 Signed-off-by: Chris Wright <chrisw@sous-sol.org>
21 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
22 ---
23
24 --- a/fs/exec.c
25 +++ b/fs/exec.c
26 @@ -1403,7 +1403,7 @@ static void zap_threads (struct mm_struc
27 do_each_thread(g,p) {
28 if (mm == p->mm && p != tsk &&
29 p->ptrace && p->parent->mm == mm) {
30 - __ptrace_unlink(p);
31 + __ptrace_detach(p, 0);
32 }
33 } while_each_thread(g,p);
34 write_unlock_irq(&tasklist_lock);
35 --- a/include/linux/ptrace.h
36 +++ b/include/linux/ptrace.h
37 @@ -84,6 +84,7 @@ extern int ptrace_readdata(struct task_s
38 extern int ptrace_writedata(struct task_struct *tsk, char __user *src, unsigned long dst, int len);
39 extern int ptrace_attach(struct task_struct *tsk);
40 extern int ptrace_detach(struct task_struct *, unsigned int);
41 +extern void __ptrace_detach(struct task_struct *, unsigned int);
42 extern void ptrace_disable(struct task_struct *);
43 extern int ptrace_check_attach(struct task_struct *task, int kill);
44 extern int ptrace_request(struct task_struct *child, long request, long addr, long data);
45 --- a/kernel/ptrace.c
46 +++ b/kernel/ptrace.c
47 @@ -71,8 +71,8 @@ void ptrace_untrace(task_t *child)
48 */
49 void __ptrace_unlink(task_t *child)
50 {
51 - if (!child->ptrace)
52 - BUG();
53 + BUG_ON(!child->ptrace);
54 +
55 child->ptrace = 0;
56 if (!list_empty(&child->ptrace_list)) {
57 list_del_init(&child->ptrace_list);
58 @@ -183,22 +183,27 @@ bad:
59 return retval;
60 }
61
62 +void __ptrace_detach(struct task_struct *child, unsigned int data)
63 +{
64 + child->exit_code = data;
65 + /* .. re-parent .. */
66 + __ptrace_unlink(child);
67 + /* .. and wake it up. */
68 + if (child->exit_state != EXIT_ZOMBIE)
69 + wake_up_process(child);
70 +}
71 +
72 int ptrace_detach(struct task_struct *child, unsigned int data)
73 {
74 if (!valid_signal(data))
75 - return -EIO;
76 + return -EIO;
77
78 /* Architecture-specific hardware disable .. */
79 ptrace_disable(child);
80
81 - /* .. re-parent .. */
82 - child->exit_code = data;
83 -
84 write_lock_irq(&tasklist_lock);
85 - __ptrace_unlink(child);
86 - /* .. and wake it up. */
87 - if (child->exit_state != EXIT_ZOMBIE)
88 - wake_up_process(child);
89 + if (child->ptrace)
90 + __ptrace_detach(child, data);
91 write_unlock_irq(&tasklist_lock);
92
93 return 0;

  ViewVC Help
Powered by ViewVC 1.1.20