public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] prevent sending wrong signals to a traced process whose tracer gets killed
@ 2007-12-04 13:27 Petr Tesarik
  2007-12-05 16:57 ` Petr Tesarik
  0 siblings, 1 reply; 2+ messages in thread
From: Petr Tesarik @ 2007-12-04 13:27 UTC (permalink / raw)
  To: Roland McGrath, Andrew Morton, Linux Torvalds; +Cc: linux-kernel

Hi,

I experienced troubles when tracing a process with strace. Sometimes,
when I killed the strace process (SIGKILL), the traced process was also
killed. I found out that it was getting SIGTRAP and, indeed, when the
traced process set up a signal handler for SIGTRAP, it no longer died.

I noticed that normally, when the traced process is continued (via
PTRACE_CONT or similar), the signal to be sent to it is stored in
current->exit_code, which is then examined by the arch-specific code and
usually leads to something like:

                send_sig(current->exit_code, current, 1);

The exit_code is set in ptrace_stop(), but the tracing process may go
away while the traced process waits for it, and in that case exit_code
is left as-is. I think we must set it to zero in ptrace_untrace().

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>

 ptrace.c |    1 +
 1 file changed, 1 insertion(+)

diff -pru a/kernel/ptrace.c b/kernel/ptrace.c
--- a/kernel/ptrace.c	2007-12-04 14:12:51.000000000 +0100
+++ b/kernel/ptrace.c	2007-12-04 14:13:28.000000000 +0100
@@ -52,6 +52,7 @@ void ptrace_untrace(struct task_struct *
 {
 	spin_lock(&child->sighand->siglock);
 	if (child->state == TASK_TRACED) {
+		child->exit_code = 0;
 		if (child->signal->flags & SIGNAL_STOP_STOPPED) {
 			child->state = TASK_STOPPED;
 		} else {


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-12-05 16:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-04 13:27 [PATCH] prevent sending wrong signals to a traced process whose tracer gets killed Petr Tesarik
2007-12-05 16:57 ` Petr Tesarik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox