Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3877162rwi; Sun, 16 Oct 2022 20:37:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM44XnLsdoVhMnVa7r2jvFAwWJUMVRA+VNuSl8u+yw3iAjh0vSYTmLmp+8+3cg/0VQ7us7km X-Received: by 2002:a17:90b:268b:b0:20c:e5fa:db70 with SMTP id pl11-20020a17090b268b00b0020ce5fadb70mr11504271pjb.23.1665977826286; Sun, 16 Oct 2022 20:37:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665977826; cv=none; d=google.com; s=arc-20160816; b=fZ+mwb0RUxfTg7U0Y7fGaqbl2587lG7hwdBuT/cdD/YVsEZqhpcS5rpLzf9dXlBIWp nN1ca1my6DURsfwMhnEkpfz9Nf5DS5LxjufAtLqCln5bIfefzZAOON+wvBSBKeWbSOXc jiKNmwN7KcHxKMaMY1WYFc6SBfnkOG2+yuGnZnl6fXXZXEj3KsNZ1HgEr+LbszND5uDp Slv0cgerI+nsXWZJsxqd/IQbO4Jdw5NrxG5ek1fHcPcycwtMWXu/fxD5JPh1q84tF3v8 NGYYzIogJq947OC5z2bybp4Otjejnea+U5kS69vMAWg81udVFZrklJXOsS+8V/rbamij SYtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:subject:user-agent:mime-version:date:message-id; bh=AgQ44m4V4t4OK4qbLIvpLngn5d7Lxrqyd0shi8+tCfI=; b=xihxDvfCTi1NGKyWPqBwFaY1LUGsyqMkqaM2purpjgexpqkXcYLKAsAEQv2PfLlUu6 qYXmnWjGawpOBcQllZCvFy/YN5r7vUOVrfqmkvw6o6m4X3JWLRZ94cBgyi6RtoZWTFqz GxWI/a77vG2eadjEf6JizfDbO2Gzxp3BNdsNUOIlBbnyA7v7VbE74TTbKExfx1vm6tnD I+GqCXMVbfgVU2WQC5zx1SrGtDfHQ6Rc15dDq/7QlgFCADOm4o9ENaxy6rJKtmBAvkbW 0C9vVMBeWVr27acfgtPxaCzJa8/ecyd0MZAdr9N3BgavMz7QaktQeO/R6FUgBN2/PcpX qIrQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h13-20020a170902f54d00b00179f3da346bsi12227419plf.39.2022.10.16.20.36.45; Sun, 16 Oct 2022 20:37:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232439AbiJQDgk (ORCPT + 99 others); Sun, 16 Oct 2022 23:36:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232432AbiJQDgi (ORCPT ); Sun, 16 Oct 2022 23:36:38 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C2FA4F39C for ; Sun, 16 Oct 2022 20:36:36 -0700 (PDT) Received: from dggpeml500025.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MrMx54vrczmVww; Mon, 17 Oct 2022 11:31:53 +0800 (CST) Received: from dggpeml500016.china.huawei.com (7.185.36.70) by dggpeml500025.china.huawei.com (7.185.36.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 17 Oct 2022 11:36:14 +0800 Received: from [10.174.176.102] (10.174.176.102) by dggpeml500016.china.huawei.com (7.185.36.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 17 Oct 2022 11:36:13 +0800 Message-ID: <1a96f570-cdb4-35e7-60ad-d1a9d8b03ce4@huawei.com> Date: Mon, 17 Oct 2022 11:36:13 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH v2] misc/fsck.c: Processes may kill other processes. From: zhanchengbin To: Theodore Ts'o CC: , Lukas Czerner , , linfeilong References: <2c8f3b3a-b6d1-9b8b-27c7-2df51236fe8c@huawei.com> In-Reply-To: <2c8f3b3a-b6d1-9b8b-27c7-2df51236fe8c@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.176.102] X-ClientProxiedBy: dggpeml500012.china.huawei.com (7.185.36.15) To dggpeml500016.china.huawei.com (7.185.36.70) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org friendly ping, thanks. On 2022/10/10 16:56, zhanchengbin wrote: > I find a error in misc/fsck.c, if run the fsck -N command, processes > don't execute, just show what would be done. However, the pid whose > value is -1 is added to the instance_list list in the execute > function,if the kill_all function is called later, kill(-1, signum) > is executed, Signals are sent to all processes except the number one > process and itself. Other processes will be killed if they use the > default signal processing function. > > Signed-off-by: zhanchengbin > Signed-off-by: Lukas Czerner > --- > V1->V2: >   Anything <= 0 is a bug and can have unexpected consequences if > we actually call the kill(). So change inst->pid==-1 to inst->pid<=0. > >  misc/fsck.c | 2 ++ >  1 file changed, 2 insertions(+) > > diff --git a/misc/fsck.c b/misc/fsck.c > index 4efe10ec..c56d1b00 100644 > --- a/misc/fsck.c > +++ b/misc/fsck.c > @@ -546,6 +546,8 @@ static int kill_all(int signum) >      for (inst = instance_list; inst; inst = inst->next) { >          if (inst->flags & FLAG_DONE) >              continue; > +        if (inst->pid <= 0) > +            continue; >          kill(inst->pid, signum); >          n++; >      }