From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754129AbbJSTwo (ORCPT ); Mon, 19 Oct 2015 15:52:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55584 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751358AbbJSTwn (ORCPT ); Mon, 19 Oct 2015 15:52:43 -0400 Date: Mon, 19 Oct 2015 21:49:11 +0200 From: Oleg Nesterov To: Dmitry Vyukov Cc: LKML , roland@hack.frob.com, syzkaller@googlegroups.com, Kostya Serebryany , Alexander Potapenko , Robert Swiecki , Kees Cook , Julien Tinnes , Eric Dumazet Subject: Re: Unkillable processes due to PTRACE_TRACEME Message-ID: <20151019194911.GA20063@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > #include > #include > #include > #include > > 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... Oleg.