From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753377AbbJOOlZ (ORCPT ); Thu, 15 Oct 2015 10:41:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53247 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751860AbbJOOlY (ORCPT ); Thu, 15 Oct 2015 10:41:24 -0400 Date: Thu, 15 Oct 2015 16:37:57 +0200 From: Oleg Nesterov To: Andrew Morton Cc: Frederic Weisbecker , Rik van Riel , Christoph Lameter , Tejun Heo , Rusty Russell , linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/1] kmod: don't run async usermode helper as a child of kworker thread Message-ID: <20151015143757.GB20060@redhat.com> References: <20151014185153.GA8117@redhat.com> <20151015143739.GA20060@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151015143739.GA20060@redhat.com> 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 call_usermodehelper_exec_sync() does fork() + wait() with "unignored" SIGCHLD. What we have missed is that this worker thread can have other children previously forked by call_usermodehelper_exec_work() without UMH_WAIT_PROC. If such a child exits in between it becomes a zombie and nobody can reap it (unless/until this worker thread exits too). Change the !UMH_WAIT_PROC case to use CLONE_PARENT. Note: this is only first step. All PF_KTHREAD tasks, even created by kernel_thread() should have ->parent == kthreadd by default. Signed-off-by: Oleg Nesterov --- kernel/kmod.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/kmod.c b/kernel/kmod.c index da98d05..e7185a2 100644 --- a/kernel/kmod.c +++ b/kernel/kmod.c @@ -327,9 +327,13 @@ static void call_usermodehelper_exec_work(struct work_struct *work) call_usermodehelper_exec_sync(sub_info); } else { pid_t pid; - + /* + * Use CLONE_PARENT to reparent it to kthreadd; we do not + * want to pollute current->children, in particular because + * call_usermodehelper_exec_sync() assumes it is empty. + */ pid = kernel_thread(call_usermodehelper_exec_async, sub_info, - SIGCHLD); + CLONE_PARENT | SIGCHLD); if (pid < 0) { sub_info->retval = pid; umh_complete(sub_info); -- 2.4.3