Re: [PATCH 0/2] proc: protect ptrace_may_access() with exec_update_lock
From: Oleg Nesterov
Date: Tue May 26 2026 - 07:11:15 EST
On 05/25, Eric W. Biederman wrote:
>
> The ugly with PTRACE_EVENT_EXIT as I recall is that if ptrace stops one
> of the threads (not the one calling exec) at PTRACE_EVENT_EXIT it can
> block de_thread, which blocks the rest of exec. But there is something
> in there where the ptracer hangs waiting for the exec to complete. So
> everything just stalls. The ptracer waiting for exec the exec waiting
> for the ptracer. SIGKILL can get you out of that mess last I looked.
> Still it is an ugly mess.
Yes... note that even without PTRACE_EVENT_EXIT a traced sub-thread won't
autoreap, so de_thread which waits for --sig->notify_count in __exit_signal()
will block anyway.
Perhaps we can change ptrace_attach() to detect this case somehow and return
-EWOULDBLOCK... Yes this can confuse strace/gdb, but this is better than
the deadlock, even if it is killable.
Oleg.