[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACT4Y+aDeSED9pnERC+gyHAEV=+n+awJ-s-8QGBQWMzuww894A@mail.gmail.com>
Date: Mon, 19 Oct 2015 22:17:20 +0200
From: Dmitry Vyukov <dvyukov@...gle.com>
To: Oleg Nesterov <oleg@...hat.com>
Cc: LKML <linux-kernel@...r.kernel.org>, roland@...k.frob.com,
syzkaller@...glegroups.com, Kostya Serebryany <kcc@...gle.com>,
Alexander Potapenko <glider@...gle.com>,
Robert Swiecki <swiecki@...gle.com>,
Kees Cook <keescook@...gle.com>,
Julien Tinnes <jln@...gle.com>,
Eric Dumazet <edumazet@...gle.com>
Subject: Re: Unkillable processes due to PTRACE_TRACEME
On Mon, Oct 19, 2015 at 9:49 PM, Oleg Nesterov <oleg@...hat.com> wrote:
> On 10/19, Dmitry Vyukov wrote:
>>
>> The following program hangs in some interesting state and is not
>> killable (started by a normal user, not root):
>
> Thanks.
>
>> #include <pthread.h>
>> #include <unistd.h>
>> #include <sys/ptrace.h>
>> #include <stdio.h>
>> #include <signal.h>
>>
>> void *thr(void *arg) {
>> ptrace(PTRACE_TRACEME, 0, 0, 0);
>> sleep(3);
>> kill(getpid(), SIGCHLD);
>> return 0;
>> }
>>
>> int main() {
>> if (fork() == 0) {
>> sleep(1);
>> pthread_t th;
>> pthread_create(&th, 0, thr, 0);
>> sleep(1);
>> }
>> return 0;
>> }
>>
>>
>> The child process attaches as tracee to init process
>
> Yes, although in a racy manner, the parent can exit after
> PTRACE_TRACEME in this case the kernel will untrace the task
> before reparenting. Not that this matters.
>
>> and then hangs in
>> a state that I don't understand. When I did a similar thing but
>> attached it to a normal parent process (shell), I still was able to
>> get rid of it by killing parent (shell).
>
> See above.
>
> So I bet the problem is that your /sbin/init doesn't use __WALL,
> so wait() doesn't reap the traced zombie sub-thread, and thus it
> can't release the non-empty thread group.
>
> Could you please verify? Just do "strace -p1" and send SIGCHLD to
> init.
>
> perhaps eligible_child() should assume WALL if ptrace && ZOMBIE...
I am using Ubuntu.
Here strace output from init:
waitid(P_ALL, 0, {}, WNOHANG|WEXITED|WSTOPPED|WCONTINUED, NULL) = 0
So what should be fixed here? Kernel of distro init?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists