public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Roland McGrath <roland@redhat.com>
Cc: Christoph Hellwig <hch@infradead.org>,
	Ingo Molnar <mingo@elte.hu>,
	linux-kernel@vger.kernel.org, jan.kratochvil@redhat.com,
	Denys Vlasenko <dvlasenk@redhat.com>
Subject: Re: ptrace && task->exit_code
Date: Fri, 29 May 2009 21:06:27 +0200	[thread overview]
Message-ID: <20090529190627.GA7017@redhat.com> (raw)
In-Reply-To: <20090527232141.8B24DFC2BD@magilla.sf.frob.com>

On 05/27, Roland McGrath wrote:
>
> > I didn't realize this until yesterday, but perhaps it makes sense
> > to decouple ptrace && task_struct->exit_code?
>
> I've long thought this was an attractive idea.  But it seems to have lots
> of complications at least as long as ptrace-wait shares so much code with
> normal wait.  I'd figured this might be one of the last things we clean up
> after ptrace is disentangled from core data structures in most every other
> way.
>
> > This is not completely trivial, needs another short series.
>
> I suspect it is more hassle than benefit to do this now.
> I don't think it is the right priority.
>
> > And. I spent a lot of time, but I can't see how to solve the problems
> > with TASK_STOPPED tasks if we do this change.
>
> I bet the complications of this all will be substantially different after
> we change the ptrace locking.  So let's not worry about it yet.

I just can't stop thinking of it ;)

Perhaps I missed something, but except the problem above this does not
look too hard. How about something like this:

	--- a/kernel/ptrace.c
	+++ b/kernel/ptrace.c
	@@ -228,7 +228,11 @@ int ptrace_attach(struct task_struct *task)
	 
		__ptrace_link(task, current);
	 
	-	send_sig_info(SIGSTOP, SEND_SIG_FORCED, task);
	+	spin_lock(task->signal->siglock);
	+	if (task_is_stopped(task) && !task->exit_code)
	+		task->exit_code = SIGSTOP;
	+	specific_send_sig_info(SIGSTOP, SEND_SIG_FORCED, task);
	+	spin_unlock(task->signal->siglock);
	 bad:
		write_unlock_irqrestore(&tasklist_lock, flags);
		task_unlock(task);

?

If we attach, and the task is already stopped, this really means
it was traced and untraced. We can set ->exit_code = SIGSTOP to
ensure do_wait() will succeed.

This also relates to attach-wait-on-stopped test-case, I cc'ed
Jan and Denys.

Note also that after

	do_wait: fix waiting for the group stop with the dead leader
	commit: 90bc8d8b1a38f1ab131a2399a202e1889db95de8

we can't confuse task->real_parent waiting for jctl stop.

What do you think?

Oleg.


  reply	other threads:[~2009-05-29 19:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-25  0:00 [RFC PATCH 7/X] ptrace: mv task->parent ptrace_task->pt_tracer Oleg Nesterov
2009-05-25 21:59 ` Oleg Nesterov
2009-05-25 22:39   ` [RFC PATCH 8/X] ptrace: introduce ptrace_tracer() helper Oleg Nesterov
2009-05-27  2:45     ` Roland McGrath
2009-05-27 21:45       ` Oleg Nesterov
2009-05-27 22:24         ` Roland McGrath
2009-05-27  2:11   ` [RFC PATCH 7/X] ptrace: mv task->parent ptrace_task->pt_tracer Roland McGrath
2009-05-27 22:41     ` Oleg Nesterov
2009-05-27 23:05       ` ptrace && task->exit_code Oleg Nesterov
2009-05-27 23:21         ` Roland McGrath
2009-05-29 19:06           ` Oleg Nesterov [this message]
2009-06-01  2:16             ` Roland McGrath
2009-05-27 23:07       ` [RFC PATCH 7/X] ptrace: mv task->parent ptrace_task->pt_tracer Roland McGrath
2009-05-27 23:59         ` Oleg Nesterov
2009-05-28  0:32           ` Roland McGrath
2009-05-28  2:54             ` Oleg Nesterov
2009-05-28  3:19               ` Roland McGrath
2009-05-28  3:35                 ` Oleg Nesterov
2009-05-28 19:28                   ` Roland McGrath

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=20090529190627.GA7017@redhat.com \
    --to=oleg@redhat.com \
    --cc=dvlasenk@redhat.com \
    --cc=hch@infradead.org \
    --cc=jan.kratochvil@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=roland@redhat.com \
    /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