From: Petr Tesarik <ptesarik@suse.cz>
To: Roland McGrath <roland@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Linux Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] prevent sending wrong signals to a traced process whose tracer gets killed
Date: Tue, 04 Dec 2007 14:27:25 +0100 [thread overview]
Message-ID: <1196774846.19677.3.camel@elijah.suse.cz> (raw)
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 {
next reply other threads:[~2007-12-04 13:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-04 13:27 Petr Tesarik [this message]
2007-12-05 16:57 ` Petr Tesarik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1196774846.19677.3.camel@elijah.suse.cz \
--to=ptesarik@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=roland@redhat.com \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®