linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Denys Vlasenko <vda.linux@googlemail.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Tejun Heo <tj@kernel.org>,
	jan.kratochvil@redhat.com, linux-kernel@vger.kernel.org,
	torvalds@linux-foundation.org, akpm@linux-foundation.org,
	indan@nul.nu
Subject: Re: [PATCH 04/11] ptrace: implement PTRACE_INTERRUPT
Date: Tue, 10 May 2011 23:59:58 +0200	[thread overview]
Message-ID: <201105102359.58900.vda.linux@googlemail.com> (raw)
In-Reply-To: <20110510140620.GB21834@redhat.com>

On Tuesday 10 May 2011 16:06, Oleg Nesterov wrote:
> On 05/10, Tejun Heo wrote:
> > On Mon, May 09, 2011 at 06:58:57PM +0200, Oleg Nesterov wrote:
> > > Right now I am a bit puzzled why do we have 2 bits, JOBCTL_TRAP_INTERRUPT
> > > and JOBCTL_TRAP_SEIZE... But I didn't read this + other patches yet.
> >
> > It eventually ends up with three trap flags - SEIZE, INTERRUPT and
> > NOTIFY.  They all use PTRACE_EVENT_INTERRUPT trap but are different as
> > for when they're cleared.  SEIZE is cleared after any trap.  INTERRUPT
> > is cleared after an INTERRUPT trap
> 
> Yes, I see, but still can't understand. OK, please ignore, let me read
> other patches first.
> 
> Well, in fact I seem to understand why do we have 2 bits. Unless I misread
> the code, PTRACE_INTERRUPT is sticky. It can't be lost even if the tracee
> can report another event before. Contrary, SEIZE is cleared if the tracee
> reports something else right after attach, but they both report the same
> PTRACE_EVENT_INTERRUPT. So, if the user does
> 
> 	ptrace(PTRACE_SEIZE);
> 	ptrace(PTRACE_INTERRUPT);
> 
> we need 2 bits to ensure PTRACE_EVENT_INTERRUPT will be reported in any
> case.
> 
> And, you know, I am not sure this is very clear. What if we change the
> rules so that PTRACE_SEIZE always reports PTRACE_EVENT_INTERRUPT like
> PTRACE_INTERRUPT? This looks more symmetrical and simple to me. IOW,
> ptrace(PTRACE_SEIZE) simply implies the implicit PTRACE_INTERRUPT.
> 
> Oh. And this reminds me the previous discussion. Should PTRACE_SEIZE
> stop the tracee? Perhaps it should only attach or do PTRACE_INTERRUPT
> depending on flags? Personally I think it should stop...

Off the top of my head, I don't see the use case for non-stopping
SEIZE right not, but arguably some people might want that.

Regarding three SEIZE/INTERRUPT/NOTIFY bits. Let's see whether
we really need them.

Tejun, why exactly do you want userspace to always see INTERRUPT stop?

If tracer did ptrace(PTRACE_INTERRUPT), it wants tracee to stop.
It then goes to waitpid, and whatever stop it sees, it handles.
I don't see any problem if it instead happens to see, say, a signal delivery
stop, and no INTERRUPT stop after that, ever. No information is lost.

Therefore, we can merge SEIZE and INTERRUPT bits into one
(or drop SEIZE bit altogether, if we decide that SEIZE doesn't stop).

Then, NOTIFY bit.
Tejun, let us know why did you design group stop notification
in a "sticky" way. Is it because of some races with SIGSTOP/SIGCONT?
>From userspace POV, it's not obvious why we can't just have
*one* INTERRUPT stop (that is, non-sticky one) every time there
is a group stop state change. Tracer can retrieve status via
GETSIGINFO just like as provided by your patch, but it doesn't
absolutely has to: it can simply CONT the tracee.

(
No, a bit different. Not
"every time there is a group stop state change"
but
"every time there is a SIGCONT which releases tracee from group stop"
- because group stop notification is _already_ delivered
to the tracer, even by the current kernel's code,
and it is already detectable (by observing that GETSIGINFO
fails on it) and we can avoid changing this.
)

Therefore, NOTIFY bit is also not needed. Only INTERRUPT bit is.
Unless I miss something...

Another note: even though PTRACE_INTERRUPT solves the problem that
PTRACE_DETACH of a running tracee was butt-ugly thing to do correctly,
the "new" way is still a bit ugly: tracer needs PTRACE_INTERRUPT,
waitpid, and only then PTRACE_DETACH. Why not go all the way
and make PTRACE_DETACH work on running tracee too?

-- 
vda

  parent reply	other threads:[~2011-05-10 22:00 UTC|newest]

Thread overview: 115+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-08 15:48 [PATCHSET ptrace] ptrace: implement PTRACE_SEIZE/INTERRUPT and group stop notification Tejun Heo
2011-05-08 15:48 ` [PATCH 01/11] job control: rename signal->group_stop and flags to jobctl and rearrange flags Tejun Heo
2011-05-08 15:48 ` [PATCH 02/11] ptrace: implement PTRACE_SEIZE Tejun Heo
2011-05-09 16:18   ` Oleg Nesterov
2011-05-10  9:46     ` Tejun Heo
2011-05-10 13:20       ` Oleg Nesterov
2011-05-10 13:47         ` Tejun Heo
2011-05-10 18:19           ` Oleg Nesterov
2011-05-15 15:56   ` PTRACE_SEIZE should not stop [Re: [PATCH 02/11] ptrace: implement PTRACE_SEIZE] Jan Kratochvil
2011-05-15 16:26     ` Tejun Heo
2011-05-15 17:15       ` Jan Kratochvil
2011-05-15 17:25         ` Tejun Heo
2011-05-15 19:48           ` Jan Kratochvil
2011-05-16  8:31             ` Tejun Heo
2011-05-16 12:26               ` Jan Kratochvil
2011-05-16 12:42                 ` Tejun Heo
2011-05-16 13:03                   ` Jan Kratochvil
2011-05-16 13:51                     ` Tejun Heo
2011-05-16 13:21               ` Jan Kratochvil
2011-05-16 13:45                 ` Tejun Heo
2011-05-16 13:48                   ` Jan Kratochvil
2011-05-16 13:54                     ` Tejun Heo
2011-05-08 15:48 ` [PATCH 03/11] ptrace: ptrace_check_attach(): rename @kill to @ignore_state and add comments Tejun Heo
2011-05-08 15:48 ` [PATCH 04/11] ptrace: implement PTRACE_INTERRUPT Tejun Heo
2011-05-08 21:58   ` Denys Vlasenko
2011-05-09 10:09     ` Tejun Heo
2011-05-09 10:55       ` Denys Vlasenko
2011-05-09 16:58   ` Oleg Nesterov
2011-05-10  9:50     ` Tejun Heo
2011-05-10 14:06       ` Oleg Nesterov
2011-05-10 14:20         ` Tejun Heo
2011-05-10 18:08           ` Oleg Nesterov
2011-05-11  8:29             ` Tejun Heo
2011-05-12 17:06               ` Oleg Nesterov
2011-05-12 17:21                 ` Tejun Heo
2011-05-10 21:59         ` Denys Vlasenko [this message]
2011-05-11  9:19           ` Tejun Heo
2011-05-11 12:23             ` Denys Vlasenko
2011-05-11 13:22               ` Tejun Heo
2011-05-11 16:20                 ` Bryan Donlan
2011-05-11 19:24                   ` Tejun Heo
2011-05-15 16:10             ` PTRACE_DETACH without stop [Re: [PATCH 04/11] ptrace: implement PTRACE_INTERRUPT] Jan Kratochvil
2011-05-15 16:35               ` Tejun Heo
2011-05-15 17:39                 ` Jan Kratochvil
2011-05-16  9:01                   ` Tejun Heo
2011-05-16 12:08                     ` Jan Kratochvil
2011-05-16 12:24                       ` Tejun Heo
2011-05-08 15:48 ` [PATCH 05/11] ptrace: restructure ptrace_getsiginfo() Tejun Heo
2011-05-08 15:49 ` [PATCH 06/11] ptrace: make group stop state visible via PTRACE_GETSIGINFO Tejun Heo
2011-05-10 16:55   ` Oleg Nesterov
2011-05-10 17:11     ` Oleg Nesterov
2011-05-11  8:08     ` Tejun Heo
2011-05-12 16:47       ` Oleg Nesterov
2011-05-12 17:15         ` Tejun Heo
2011-05-08 15:49 ` [PATCH 07/11] ptrace: add JOBCTL_TRAPPED Tejun Heo
2011-05-08 15:49 ` [PATCH 08/11] ptrace: move fallback JOBCTL_TRAPPING clearing to get_signal_to_deliver() Tejun Heo
2011-05-11 15:48   ` Oleg Nesterov
2011-05-11 19:17     ` Tejun Heo
2011-05-12 15:40       ` Oleg Nesterov
2011-05-08 15:49 ` [PATCH 09/11] job control: reorganize wait_task_stopped() Tejun Heo
2011-05-11 15:48   ` Oleg Nesterov
2011-05-11 19:29     ` Tejun Heo
2011-05-12 15:42       ` Oleg Nesterov
2011-05-12 16:02         ` Tejun Heo
2011-05-12 17:25           ` Oleg Nesterov
2011-05-12 17:32             ` Tejun Heo
2011-05-12 17:33               ` Tejun Heo
2011-05-12 18:33               ` Oleg Nesterov
2011-05-13  8:46                 ` Tejun Heo
2011-05-13 17:21                   ` Oleg Nesterov
2011-05-14 10:56                     ` Tejun Heo
2011-05-15 14:40               ` waitpid(WNOHANG) should report SIGCHLD-notified signals [Re: [PATCH 09/11] job control: reorganize wait_task_stopped()] Jan Kratochvil
2011-05-15 16:47                 ` Tejun Heo
2011-05-15 17:01                   ` Tejun Heo
2011-05-15 17:47                   ` Jan Kratochvil
2011-05-16  9:13                     ` Tejun Heo
2011-05-16 12:11                       ` Jan Kratochvil
2011-05-16 12:27                         ` Tejun Heo
2011-05-16 12:39                           ` Jan Kratochvil
2011-05-16 12:46                             ` Tejun Heo
2011-05-08 15:49 ` [PATCH 10/11] ptrace: move JOBCTL_TRAPPING wait to wait(2) and ptrace_check_attach() Tejun Heo
2011-05-11 16:49   ` Oleg Nesterov
2011-05-11 17:00     ` Oleg Nesterov
2011-05-11 19:45       ` Tejun Heo
2011-05-11 19:53     ` Tejun Heo
2011-05-12 10:23       ` Tejun Heo
2011-05-12 16:06         ` Oleg Nesterov
2011-05-12 15:59       ` Oleg Nesterov
2011-05-12 16:07         ` Tejun Heo
2011-05-12 18:20           ` Oleg Nesterov
2011-05-13  9:13             ` Tejun Heo
2011-05-13 18:34               ` Oleg Nesterov
2011-05-08 15:49 ` [PATCH 11/11] ptrace: implement group stop notification for ptracer Tejun Heo
2011-05-08 22:42   ` Denys Vlasenko
2011-05-09 10:10     ` Tejun Heo
2011-05-10 22:37   ` Denys Vlasenko
2011-05-11  9:05     ` Tejun Heo
2011-05-11 12:01       ` Denys Vlasenko
2011-05-11 13:13         ` Tejun Heo
2011-05-11 19:58   ` Oleg Nesterov
2011-05-11 20:18     ` Tejun Heo
2011-05-11 20:21       ` Tejun Heo
2011-05-12 10:24         ` Tejun Heo
2011-05-15 14:02   ` getter PTRACE_GETSIGINFO should not modify anything [Re: [PATCH 11/11] ptrace: implement group stop notification for ptracer] Jan Kratochvil
2011-05-15 14:28     ` Tejun Heo
2011-05-15 17:17       ` Jan Kratochvil
2011-05-15 17:28         ` Tejun Heo
2011-05-15 20:06           ` Jan Kratochvil
2011-05-16  8:43             ` Tejun Heo
2011-05-16 12:17               ` Jan Kratochvil
2011-05-16 12:56                 ` Tejun Heo
2011-05-16 13:00                   ` Ingo Molnar
2011-05-08 22:27 ` [PATCHSET ptrace] ptrace: implement PTRACE_SEIZE/INTERRUPT and group stop notification Denys Vlasenko
2011-05-09  9:48   ` Tejun Heo
2011-05-15 13:55   ` ptrace-testsuite status [Re: [PATCHSET ptrace] ptrace: implement PTRACE_SEIZE/INTERRUPT and group stop notification] Jan Kratochvil

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=201105102359.58900.vda.linux@googlemail.com \
    --to=vda.linux@googlemail.com \
    --cc=akpm@linux-foundation.org \
    --cc=indan@nul.nu \
    --cc=jan.kratochvil@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=tj@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).