Re: [PATCH v14] exec: Fix dead-lock in de_thread with ptrace_attach

2024-01-23 Thread Kees Cook
On Tue, Jan 23, 2024 at 07:30:52PM +0100, Bernd Edlinger wrote: > - Currently a non-privileged program can potentially send such a privileged > tracer into a deadlock. > - With the alternative patch below that non-privileged can no longer send the > tracer into a deadlock, but it can still quickly

Re: [PATCH v14] exec: Fix dead-lock in de_thread with ptrace_attach

2024-01-23 Thread Bernd Edlinger
On 1/22/24 22:30, Kees Cook wrote: > On Mon, Jan 22, 2024 at 02:24:37PM +0100, Bernd Edlinger wrote: >> The main concern was when a set-suid program is executed by execve. >> Then it makes a difference if the current thread is traced before the >> execve or not. That means if the current thread is

Re: [PATCH v14] exec: Fix dead-lock in de_thread with ptrace_attach

2024-01-22 Thread Kees Cook
On Mon, Jan 22, 2024 at 02:24:37PM +0100, Bernd Edlinger wrote: > The main concern was when a set-suid program is executed by execve. > Then it makes a difference if the current thread is traced before the > execve or not. That means if the current thread is already traced, > the decision, which c

Re: [PATCH v14] exec: Fix dead-lock in de_thread with ptrace_attach

2024-01-22 Thread Oleg Nesterov
I'll try to read your email later, just one note for now... On 01/22, Bernd Edlinger wrote: > > > I didn't say that t is a group leader. I said it can be a zombie sub-thread > > with ->exit_state != 0. > > the condition here is > > (t != tsk->group_leader || !t->exit_state) > > so in other words,

Re: [PATCH v14] exec: Fix dead-lock in de_thread with ptrace_attach

2024-01-22 Thread Bernd Edlinger
On 1/17/24 17:38, Oleg Nesterov wrote: > On 01/17, Bernd Edlinger wrote: >> Yes. but the tracer has to do its job, and that is ptrace_attach the >> remaining treads, it does not know that it would avoid a dead-lock >> when it calls wait(), instead of ptrace_attach. It does not know >> that the tra

Re: [PATCH v14] exec: Fix dead-lock in de_thread with ptrace_attach

2024-01-17 Thread Oleg Nesterov
On 01/17, Bernd Edlinger wrote: > > >> > >> The problem happens when a tracer tries to ptrace_attach > >> to a multi-threaded process, that does an execve in one of > >> the threads at the same time, without doing that in a forked > >> sub-process. That means: There is a race condition, when one >

Re: [PATCH v14] exec: Fix dead-lock in de_thread with ptrace_attach

2024-01-17 Thread Bernd Edlinger
On 1/16/24 16:22, Oleg Nesterov wrote: > I'll try to recall this problem and actually read the patch tommorrow... > > Hmm. but it doesn't apply to Linus's tree, you need to rebase it. > In particular, please note the recent commit 5431fdd2c181dd2eac2 > ("ptrace: Convert ptrace_attach() to use lock

Re: [PATCH v14] exec: Fix dead-lock in de_thread with ptrace_attach

2024-01-17 Thread Bernd Edlinger
On 1/15/24 20:37, Matthew Wilcox wrote: > On Mon, Jan 15, 2024 at 08:22:19PM +0100, Bernd Edlinger wrote: >> This introduces signal->exec_bprm, which is used to >> fix the case when at least one of the sibling threads >> is traced, and therefore the trace process may dead-lock >> in ptrace_attach,

Re: [PATCH v14] exec: Fix dead-lock in de_thread with ptrace_attach

2024-01-16 Thread Oleg Nesterov
I'll try to recall this problem and actually read the patch tommorrow... Hmm. but it doesn't apply to Linus's tree, you need to rebase it. In particular, please note the recent commit 5431fdd2c181dd2eac2 ("ptrace: Convert ptrace_attach() to use lock guards") On 01/15, Bernd Edlinger wrote: > > Th

Re: [PATCH v14] exec: Fix dead-lock in de_thread with ptrace_attach

2024-01-15 Thread Matthew Wilcox
On Mon, Jan 15, 2024 at 08:22:19PM +0100, Bernd Edlinger wrote: > This introduces signal->exec_bprm, which is used to > fix the case when at least one of the sibling threads > is traced, and therefore the trace process may dead-lock > in ptrace_attach, but de_thread will need to wait for the > trac

[PATCH v14] exec: Fix dead-lock in de_thread with ptrace_attach

2024-01-15 Thread Bernd Edlinger
This introduces signal->exec_bprm, which is used to fix the case when at least one of the sibling threads is traced, and therefore the trace process may dead-lock in ptrace_attach, but de_thread will need to wait for the tracer to continue execution. The problem happens when a tracer tries to ptra