]> git.hungrycats.org Git - linux/commitdiff
[PATCH] ptrace-fix-2.5.34-A2, BK-curr
authorIngo Molnar <mingo@elte.hu>
Fri, 13 Sep 2002 04:36:00 +0000 (21:36 -0700)
committerIngo Molnar <mingo@elte.hu>
Fri, 13 Sep 2002 04:36:00 +0000 (21:36 -0700)
I distilled the attached fix-patch from Daniel's bigger patch - it
includes all fixes for all currently known ptrace related breakages,
which include things like bad behavior (crash) if the tracer process
dies unexpectedly.

kernel/exit.c
kernel/fork.c

index 1b7179147f68ee79b75aa51b9964474f6192f8a7..a305043a5d0de9e6ac14088898a1c3c7d594db0f 100644 (file)
@@ -465,7 +465,8 @@ static inline void forget_original_parent(struct task_struct * father)
         */
        list_for_each(_p, &father->children) {
                p = list_entry(_p,struct task_struct,sibling);
-               reparent_thread(p, reaper, child_reaper);
+               if (father == p->real_parent)
+                       reparent_thread(p, reaper, child_reaper);
        }
        list_for_each(_p, &father->ptrace_children) {
                p = list_entry(_p,struct task_struct,ptrace_list);
@@ -485,9 +486,16 @@ static inline void zap_thread(task_t *p, task_t *father, int traced)
                p->ptrace = ptrace_flag;
                __ptrace_link(p, trace_task);
        } else {
-               /* Otherwise, if we were tracing this thread, untrace it.  */
+               /*
+                * Otherwise, if we were tracing this thread, untrace it.
+                * If we were only tracing the thread (i.e. not its real
+                * parent), stop here.
+                */
                ptrace_unlink (p);
-
+               if (p->parent != father) {
+                       BUG_ON(p->parent != p->real_parent);
+                       return;
+               }
                list_del_init(&p->sibling);
                p->parent = p->real_parent;
                list_add_tail(&p->sibling, &p->parent->children);
index 282f04370e5ea1fb6b16c2defc42ec353e0c42aa..bd902cc45283c54e64da006022e4cfcd97f5df65 100644 (file)
@@ -790,6 +790,12 @@ static struct task_struct *copy_process(unsigned long clone_flags,
        if (clone_flags & CLONE_CLEARTID)
                p->user_tid = user_tid;
 
+       /*
+        * Syscall tracing should be turned off in the child regardless
+        * of CLONE_PTRACE.
+        */
+       clear_tsk_thread_flag(p, TIF_SYSCALL_TRACE);
+
        /* Our parent execution domain becomes current domain
           These must match for thread signalling to apply */