2.1.111 fix for arch/i386/kernel/ptrace.c

Eric PAIRE (e.paire@opengroup.org)
Tue, 28 Jul 1998 16:10:11 +0200


Hi Linus,

I am still in the process of using GDB on an SMP machine. By looking at the
sys_ptrace() system call, I noticed the following potential problem: the
tracing process calls "wake_up_process(child)" before having completed
the modification of the child status (which could lead to incoherencies
of child status). The following patch fixes this potential problem for the
i386. I have not included any patch for the other architectures, but there
is a similar problem for all of them in their machine-dependent ptrace.c
files (since mostly copied from the i386 ptrace.c)

Best regards,
-Eric
+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ Eric PAIRE
Email : e.paire@gr.opengroup.org | THE Open GROUP - Grenoble Research Institute
Phone : +33 (0) 476 63 48 71 | 2, avenue de Vignate
Fax : +33 (0) 476 51 05 32 | F-38610 Gieres FRANCE

------ Cut here ------ Cut here ------ Cut here ------ Cut here ------
--- arch/i386/kernel/ptrace.c.OLD Wed Jul 22 08:10:00 1998
+++ arch/i386/kernel/ptrace.c Tue Jul 28 15:59:19 1998
@@ -508,10 +508,10 @@
else
child->flags &= ~PF_TRACESYS;
child->exit_code = data;
- wake_up_process(child);
/* make sure the single step bit is not set. */
tmp = get_stack_long(child, EFL_OFFSET) & ~TRAP_FLAG;
put_stack_long(child, EFL_OFFSET,tmp);
+ wake_up_process(child);
ret = 0;
goto out;
}
@@ -527,11 +527,11 @@
ret = 0;
if (child->state == TASK_ZOMBIE) /* already dead */
goto out;
- wake_up_process(child);
child->exit_code = SIGKILL;
/* make sure the single step bit is not set. */
tmp = get_stack_long(child, EFL_OFFSET) & ~TRAP_FLAG;
put_stack_long(child, EFL_OFFSET, tmp);
+ wake_up_process(child);
goto out;
}

@@ -544,9 +544,9 @@
child->flags &= ~PF_TRACESYS;
tmp = get_stack_long(child, EFL_OFFSET) | TRAP_FLAG;
put_stack_long(child, EFL_OFFSET, tmp);
- wake_up_process(child);
child->exit_code = data;
/* give it a chance to run. */
+ wake_up_process(child);
ret = 0;
goto out;
}
@@ -559,16 +559,17 @@
if ((unsigned long) data > _NSIG)
goto out;
child->flags &= ~(PF_PTRACED|PF_TRACESYS);
- wake_up_process(child);
child->exit_code = data;
write_lock_irqsave(&tasklist_lock, flags);
REMOVE_LINKS(child);
child->p_pptr = child->p_opptr;
SET_LINKS(child);
write_unlock_irqrestore(&tasklist_lock, flags);
- /* make sure the single step bit is not set. */
+
+ /* make sure the single step bit is not set. */
tmp = get_stack_long(child, EFL_OFFSET) & ~TRAP_FLAG;
put_stack_long(child, EFL_OFFSET, tmp);
+ wake_up_process(child);
ret = 0;
goto out;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html