Re: [RFC PATCH] ptrace: make ptrace() fail if the tracee changed its pid unexpectedly

2020-12-21 Thread Eric W. Biederman
Oleg Nesterov writes: > On 12/17, Eric W. Biederman wrote: >> >> Oleg Nesterov writes: >> >> > Suppose we have 2 threads, the group-leader L and a sub-theread T, >> > both parked in ptrace_stop(). Debugger tries to resume both threads >> > and does >> > >> >ptrace(PTRACE_CONT, T); >> >pt

Re: [RFC PATCH] ptrace: make ptrace() fail if the tracee changed its pid unexpectedly

2020-12-19 Thread Simon Marchi
On 2020-12-19 2:33 p.m., Oleg Nesterov wrote: > OOPS! Sorry Simon, yes I forgot to add reported-by. Andrew, or Eric, if > you take this patch, could you also add > > Reported-by: Simon Marchi I tried the original reproducer on a patched kernel, and it looks good. GDB's behavior is still no

Re: [RFC PATCH] ptrace: make ptrace() fail if the tracee changed its pid unexpectedly

2020-12-19 Thread Oleg Nesterov
On 12/19, Pedro Alves wrote: > > BTW, the problem was discovered by Simon Marchi when he tried to write > a GDB testcase for a multi-threaded exec scenario: OOPS! Sorry Simon, yes I forgot to add reported-by. Andrew, or Eric, if you take this patch, could you also add Reported-by: Simon M

Re: [RFC PATCH] ptrace: make ptrace() fail if the tracee changed its pid unexpectedly

2020-12-19 Thread Pedro Alves
On 12/17/20 11:39 PM, Eric W. Biederman wrote: >> resume the old leader L, it resumes the post-exec thread T which was >> actually now stopped in PTHREAD_EVENT_EXEC. In this case the >> PTHREAD_EVENT_EXEC event is lost, and the tracer can't know that the >> tracee changed its pid. > > The change

Re: [RFC PATCH] ptrace: make ptrace() fail if the tracee changed its pid unexpectedly

2020-12-18 Thread Oleg Nesterov
On 12/17, Eric W. Biederman wrote: > > Oleg Nesterov writes: > > > Suppose we have 2 threads, the group-leader L and a sub-theread T, > > both parked in ptrace_stop(). Debugger tries to resume both threads > > and does > > > > ptrace(PTRACE_CONT, T); > > ptrace(PTRACE_CONT, L); > > > > If

Re: [RFC PATCH] ptrace: make ptrace() fail if the tracee changed its pid unexpectedly

2020-12-17 Thread Eric W. Biederman
Oleg Nesterov writes: > Suppose we have 2 threads, the group-leader L and a sub-theread T, > both parked in ptrace_stop(). Debugger tries to resume both threads > and does > > ptrace(PTRACE_CONT, T); > ptrace(PTRACE_CONT, L); > > If the sub-thread T execs in between, the 2nd PTRACE_CO

[RFC PATCH] ptrace: make ptrace() fail if the tracee changed its pid unexpectedly

2020-12-17 Thread Oleg Nesterov
Suppose we have 2 threads, the group-leader L and a sub-theread T, both parked in ptrace_stop(). Debugger tries to resume both threads and does ptrace(PTRACE_CONT, T); ptrace(PTRACE_CONT, L); If the sub-thread T execs in between, the 2nd PTRACE_CONT doesn not resume the old leader