lkml.org 
[lkml]   [2002]   [Mar]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH] ptrace on stopped processes (2.4)
From
Date
This is a repost of the ptrace patch to 2.4 kernels
we've discussed in recent months.

Since the last post, I have updated it to linux 2.4.18
(no changes) and tested it with subterfuge and uml.

Subterfuge seems to be unaffected.

UML needs minor modifications; I've discussed them with
Jeff Dike and (I believe) he is happy.

I believe I have addressed everyone's concerns.

The patch fixes these two bugs:

1. gdb and other tools cannot attach to a stopped
process. The wait that follows the PTRACE_ATTACH
will block indefinitely.

2. It is not possible to use PTRACE_DETACH to leave
a process stopped, because ptrace ignores SIGSTOPs
sent by the tracing process.

Vic

--- /home/vic/p/linux-2.4.18.orig/kernel/ptrace.c Wed Mar 13 13:14:54 2002
+++ /home/vic/p/linux-2.4.18/kernel/ptrace.c Mon Mar 18 21:58:11 2002
@@ -54,6 +54,7 @@

int ptrace_attach(struct task_struct *task)
{
+ int stopped;
task_lock(task);
if (task->pid <= 1)
goto bad;
@@ -90,7 +91,13 @@
}
write_unlock_irq(&tasklist_lock);

+ stopped = (task->state == TASK_STOPPED);
send_sig(SIGSTOP, task, 1);
+ /* If it was stopped when we got here,
+ clear the pending SIGSTOP. */
+ if (stopped)
+ wake_up_process(task);
+
return 0;

bad:
--- /home/vic/p/linux-2.4.18.orig/arch/i386/kernel/signal.c Wed Mar 13 13:16:44 2002
+++ /home/vic/p/linux-2.4.18/arch/i386/kernel/signal.c Wed Mar 13 16:31:38 2002
@@ -620,9 +620,9 @@
continue;
current->exit_code = 0;

- /* The debugger continued. Ignore SIGSTOP. */
- if (signr == SIGSTOP)
- continue;
+ /* The debugger continued. */
+ if (signr == SIGSTOP && current->ptrace & PT_PTRACED)
+ continue; /* ignore SIGSTOP */

/* Update the siginfo structure. Is this good? */
if (signr != info.si_signo) {
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 13:25    [W:0.093 / U:4.252 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site