From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D3C0C4332E for ; Wed, 10 Mar 2021 19:08:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1CAE964FD0 for ; Wed, 10 Mar 2021 19:08:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233485AbhCJTHb (ORCPT ); Wed, 10 Mar 2021 14:07:31 -0500 Received: from out01.mta.xmission.com ([166.70.13.231]:49030 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233610AbhCJTHZ (ORCPT ); Wed, 10 Mar 2021 14:07:25 -0500 Received: from in01.mta.xmission.com ([166.70.13.51]) by out01.mta.xmission.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lK4B0-00EQ1X-Q9; Wed, 10 Mar 2021 12:07:23 -0700 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=fess.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.87) (envelope-from ) id 1lK4Az-0001C2-U2; Wed, 10 Mar 2021 12:07:22 -0700 From: ebiederm@xmission.com (Eric W. Biederman) To: Oleg Nesterov Cc: qianli zhao , christian@brauner.io, axboe@kernel.dk, Thomas Gleixner , Peter Collingbourne , linux-kernel@vger.kernel.org, Qianli Zhao References: <1615296712-175334-1-git-send-email-zhaoqianligood@gmail.com> <20210309182657.GA1408@redhat.com> <20210310173236.GB8973@redhat.com> Date: Wed, 10 Mar 2021 13:07:26 -0600 In-Reply-To: <20210310173236.GB8973@redhat.com> (Oleg Nesterov's message of "Wed, 10 Mar 2021 18:32:37 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1lK4Az-0001C2-U2;;;mid=;;;hst=in01.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX197e9Zu2/idl9WAj6+hcO+r4gTwQm4FBHA= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: [PATCH] exit: trigger panic when init process is set to SIGNAL_GROUP_EXIT X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Oleg Nesterov writes: > On 03/10, Eric W. Biederman wrote: >> >> /* If global init has exited, >> * panic immediately to get a useable coredump. >> */ >> if (unlikely(is_global_init(tsk) && >> (thread_group_empty(tsk) || >> (tsk->signal->flags & SIGNAL_GROUP_EXIT)))) { >> panic("Attempted to kill init! exitcode=0x%08x\n", >> tsk->signal->group_exit_code ?: (int)code); >> } >> >> The thread_group_empty test is needed to handle single threaded >> inits. > > But we can't rely on thread_group_empty(). Just suppose that the main > thread exit first, then the 2nd (last) thread exits too. My code above is designed so that every thread calls panic. Only the first thread into panic actually writes the panic (That is in panic itself). By testing for thread_group_empty() || SIGNAL_GROUP_EXIT I am just trying to allow threads of init to exit. Maybe thread_group_empty isn't the exact test we need to allow those. Eric