Re: [PATCH] Revert "exec: make de_thread() freezable (was: Re: Linux 4.20-rc4)
From: Ingo Molnar
Date: Tue Dec 04 2018 - 04:17:43 EST
* Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
> > I reviewed the ->cred_guard_mutex code, and the mutex is held across all
> > of exec() - and we always did this.
>
> Yes, and this was always wrong. For example, this test-case hangs:
>
> #include <unistd.h>
> #include <signal.h>
> #include <sys/ptrace.h>
> #include <pthread.h>
>
> void *thread(void *arg)
> {
> ptrace(PTRACE_TRACEME, 0,0,0);
> return NULL;
> }
>
> int main(void)
> {
> int pid = fork();
>
> if (!pid) {
> pthread_t pt;
> pthread_create(&pt, NULL, thread, NULL);
> pthread_join(pt, NULL);
> execlp("echo", "echo", "passed", NULL);
> }
>
> sleep(1);
> // or anything else which needs ->cred_guard_mutex,
> // say open(/proc/$pid/mem)
> ptrace(PTRACE_ATTACH, pid, 0,0);
> kill(pid, SIGCONT);
>
> return 0;
> }
>
> we really need to narrow the (huge) scope of ->cred_guard_mutex in exec paths.
>
> my attempt to fix this was nacked, and nobody suggested a better solution so far.
Any link to your patch and the NAK?
Thanks,
Ingo