summaryrefslogtreecommitdiff
blob: bbe8813557ba9893a87da89fa2552d5747a29651 (plain)
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
Index: vserver-sources-2.1.1_2.6.15.4/kernel/exit.c
===================================================================
--- vserver-sources-2.1.1_2.6.15.4.orig/kernel/exit.c
+++ vserver-sources-2.1.1_2.6.15.4/kernel/exit.c
@@ -608,13 +608,13 @@ static inline void reparent_thread(task_
 }
 
 static inline
-struct task_struct *vchild_reaper(struct task_struct *father)
+struct task_struct *vchild_reaper(struct task_struct *task)
 {
 	struct vx_info *vxi;
 	struct task_struct *reaper, *init;
 
 	reaper = child_reaper;
-	vxi = task_get_vx_info(father);
+	vxi = task_get_vx_info(task);
 	if (!vxi)
 		goto out;
 
@@ -622,7 +622,7 @@ struct task_struct *vchild_reaper(struct
 		goto out_put;
 
 	init = find_task_by_real_pid(vxi->vx_initpid);
-	if (init && (init != father))
+	if (init && (init != task))
 		reaper = init;
 
 out_put:
@@ -666,12 +666,15 @@ static inline void forget_original_paren
 
 		ptrace = p->ptrace;
 
+		/* check for reaper context */
+		BUG_ON(p->xid != 1 && p->xid != reaper->xid);
+
 		/* if father isn't the real parent, then ptrace must be enabled */
 		BUG_ON(father != p->real_parent && !ptrace);
 
 		if (father == p->real_parent) {
 			/* reparent with a reaper, real father it's us */
-			choose_new_parent(p, reaper);
+			choose_new_parent(p, (p == reaper) ? child_reaper : reaper);
 			reparent_thread(p, father, 0);
 		} else {
 			/* reparent ptraced task to its real parent */
@@ -692,6 +695,10 @@ static inline void forget_original_paren
 	}
 	list_for_each_safe(_p, _n, &father->ptrace_children) {
 		p = list_entry(_p,struct task_struct,ptrace_list);
+
+		/* check for reaper context */
+		BUG_ON(p->xid != 1 && p->xid != reaper->xid);
+
 		choose_new_parent(p, reaper);
 		reparent_thread(p, father, 1);
 	}