Re: PT_EXITKILL (Was: pdeath_signal)

2012-11-08 Thread Amnon Shiloh
Hi Again, > Or the child can check getppid() == saved_parent_pid after PTRACE_TRACEME. In fact that's what I did when I tested the new option - the child ran: volatile long ready = 0; int saved_parent_pid = getpid(); if(!(son = fork()) {

Re: PT_EXITKILL (Was: pdeath_signal)

2012-11-08 Thread Pedro Alves
On 11/08/2012 12:44 PM, Oleg Nesterov wrote: > On 11/08, Pedro Alves wrote: >> If this isn't inherited by the ptrace child's children, a fork child can >> end up detached if the tracer dies before it had a chance of setting >> the PTRACE_O_EXITKILL on the new auto-attached child. > > It is

Re: PT_EXITKILL (Was: pdeath_signal)

2012-11-08 Thread Oleg Nesterov
On 11/08, Pedro Alves wrote: > > On 11/07/2012 03:09 PM, Oleg Nesterov wrote: > > > OK. Please see the untested/uncompiled (but trivial) patch below > > > > - it adds PTRACE_O_EXITKILL. A better name? > > > > - A better numeric value? Note that the new option is not equal to > > the

Re: PT_EXITKILL (Was: pdeath_signal)

2012-11-08 Thread Oleg Nesterov
Hi Amnon, On 11/08, Amnon Shiloh wrote: > > Thanks for the patch, I tried it and it works nicely! OK, thanks. I'll wait for other comments a bit and then send the patch to Andrew. > Also, I just noticed that this new option (PTRACE_O_EXITKILL) is not > safe with ptrace(PTRACE_TRACEME)+execve,

Re: PT_EXITKILL (Was: pdeath_signal)

2012-11-08 Thread Pedro Alves
On 11/07/2012 03:09 PM, Oleg Nesterov wrote: >> > > > > What I would IDEALLY like to have is a call, probably a ptrace >> > > > > option, >> > > > > where the parent can request: "If I am ever to terminate or be >> > > > > killed, >> > > > > then my ptraced son MUST die as well". >> > > >> > >

Re: PT_EXITKILL (Was: pdeath_signal)

2012-11-08 Thread Pedro Alves
On 11/07/2012 03:09 PM, Oleg Nesterov wrote: What I would IDEALLY like to have is a call, probably a ptrace option, where the parent can request: If I am ever to terminate or be killed, then my ptraced son MUST die as well. Perhaps this makes sense... Chris,

Re: PT_EXITKILL (Was: pdeath_signal)

2012-11-08 Thread Oleg Nesterov
Hi Amnon, On 11/08, Amnon Shiloh wrote: Thanks for the patch, I tried it and it works nicely! OK, thanks. I'll wait for other comments a bit and then send the patch to Andrew. Also, I just noticed that this new option (PTRACE_O_EXITKILL) is not safe with ptrace(PTRACE_TRACEME)+execve,

Re: PT_EXITKILL (Was: pdeath_signal)

2012-11-08 Thread Oleg Nesterov
On 11/08, Pedro Alves wrote: On 11/07/2012 03:09 PM, Oleg Nesterov wrote: OK. Please see the untested/uncompiled (but trivial) patch below - it adds PTRACE_O_EXITKILL. A better name? - A better numeric value? Note that the new option is not equal to the

Re: PT_EXITKILL (Was: pdeath_signal)

2012-11-08 Thread Pedro Alves
On 11/08/2012 12:44 PM, Oleg Nesterov wrote: On 11/08, Pedro Alves wrote: If this isn't inherited by the ptrace child's children, a fork child can end up detached if the tracer dies before it had a chance of setting the PTRACE_O_EXITKILL on the new auto-attached child. It is copied like

Re: PT_EXITKILL (Was: pdeath_signal)

2012-11-08 Thread Amnon Shiloh
Hi Again, Or the child can check getppid() == saved_parent_pid after PTRACE_TRACEME. In fact that's what I did when I tested the new option - the child ran: volatile long ready = 0; int saved_parent_pid = getpid(); if(!(son = fork()) {

Re: PT_EXITKILL (Was: pdeath_signal)

2012-11-07 Thread Amnon Shiloh
Dear Oleg, Thanks for the patch, I tried it and it works nicely! (except that I have no "include/uapi/" directory for "include/uapi/linux/ptrace.h", so I applied that part of the patch to "include/linux/ptrace.h" as well). Also, I just noticed that this new option (PTRACE_O_EXITKILL) is not

PT_EXITKILL (Was: pdeath_signal)

2012-11-07 Thread Oleg Nesterov
(add lkml/cc's) On 11/07, Amnon Shiloh wrote: > > > Quoting Oleg Nesterov (o...@redhat.com): > > > > > > On 11/06, Amnon Shiloh wrote: > > > > > > > > What I would IDEALLY like to have is a call, probably a ptrace option, > > > > where the parent can request: "If I am ever to terminate or be

PT_EXITKILL (Was: pdeath_signal)

2012-11-07 Thread Oleg Nesterov
(add lkml/cc's) On 11/07, Amnon Shiloh wrote: Quoting Oleg Nesterov (o...@redhat.com): On 11/06, Amnon Shiloh wrote: What I would IDEALLY like to have is a call, probably a ptrace option, where the parent can request: If I am ever to terminate or be killed, then my

Re: PT_EXITKILL (Was: pdeath_signal)

2012-11-07 Thread Amnon Shiloh
Dear Oleg, Thanks for the patch, I tried it and it works nicely! (except that I have no include/uapi/ directory for include/uapi/linux/ptrace.h, so I applied that part of the patch to include/linux/ptrace.h as well). Also, I just noticed that this new option (PTRACE_O_EXITKILL) is not safe with