Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2988066rwb; Thu, 29 Sep 2022 18:54:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7kXTk7I6O5TqV+3O3QUOamMPckJLKnqfbj4YaG9x2xAAtuLLRh8vgUXSsaIb5MA9FPmH0V X-Received: by 2002:a17:906:4795:b0:787:434f:d754 with SMTP id cw21-20020a170906479500b00787434fd754mr5076523ejc.268.1664502865536; Thu, 29 Sep 2022 18:54:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664502865; cv=none; d=google.com; s=arc-20160816; b=gbSyZx1GNESNb0idIdFVE8BAk4PKqDDdECy3qkjug9CCapkfMSniXU9tCcxNZ6iX7i fuhmGxie7cqdMQm6P5p1Aioe6rn6bUg9thuXcyeXaA66a9JKyyhmhLvqAB6qThwzGO7B ogk9w8T9b/X4H+8mxVx//Nr3Z55lNNQGqIJrKf+amSajmRvgHQ1oH7521KvmDF8nAcDa O4MWiRlx6IpGkIuzH+vxb+IeQ6ar+ZUzqKICUfnHVrtO09rYKfOTYjOsNM70tv+bhQks h80cmjGCK3XT1jDfJhEpNxViWuRLxDWk6sCScoZbOewwX6AwJWqeJ7+f6yELo3EmbXVd zbfg== 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:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=Ux9Ny1HH4O8AIxUkKtO726+R19z2IrxzJv/gQlZeDtw=; b=VCyWTMbDbJtF+a/aoCb9xJGhv1l8cVy82hSQ4my+CKd+NQ+IzjvUQyL8AjGeUpoL5S t3uuCP1LHBAoca5Dm9ZGQeqGqSXUIIReHkn1ZT250DKH+0KAYEvcX780JAjJoLPwxRTa 5kA1YhGYXWqcTmBZXCnfCb4LenSRFxi2Bf7c4SoMSv6ilXRpKubN2F6sxZHwfvM5lgjU 4vEMOWdGGWLrkLILL2S6TOtjlih+whsRvXAh/j/7o9/qSFg6AJwXM7Hn1ZKP1sbSyUA5 hLO7pT6aKXWzv2gmHBsc4TQCn+RHZgD4tldKUsmtmAH/VREymiPms/jmzb+8hZ3+6eld +K3Q== 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 qf17-20020a1709077f1100b0073d68cdd0a8si867863ejc.9.2022.09.29.18.53.59; Thu, 29 Sep 2022 18:54:25 -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 S229449AbiI3Bm5 (ORCPT + 99 others); Thu, 29 Sep 2022 21:42:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229479AbiI3Bm4 (ORCPT ); Thu, 29 Sep 2022 21:42:56 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8E1B1FF167 for ; Thu, 29 Sep 2022 18:42:55 -0700 (PDT) Received: from dggpeml500020.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MdtDC1F2xz1P6x5; Fri, 30 Sep 2022 09:38:35 +0800 (CST) Received: from dggpeml500016.china.huawei.com (7.185.36.70) by dggpeml500020.china.huawei.com (7.185.36.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 30 Sep 2022 09:42:53 +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; Fri, 30 Sep 2022 09:42:52 +0800 Message-ID: <470ea2ee-54fd-3dd5-2500-36fb82665c11@huawei.com> Date: Fri, 30 Sep 2022 09:42:52 +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: [bug report] misc/fsck.c: Processes may kill other processes. To: Lukas Czerner CC: Theodore Ts'o , , , linfeilong References: <4ffe3143-fc53-7178-cf44-f3481eb96ae4@huawei.com> <20220929112813.6aqtktwaff2m7fh2@fedora> From: zhanchengbin In-Reply-To: <20220929112813.6aqtktwaff2m7fh2@fedora> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.176.102] X-ClientProxiedBy: dggpeml100009.china.huawei.com (7.185.36.95) To dggpeml500016.china.huawei.com (7.185.36.70) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-8.3 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 On 2022/9/29 19:28, Lukas Czerner wrote: > Hi, > > indeed we'd like to avoid killing the instance that was not ran because > of noexecute. Can you try the following patch? > > Thanks! > -Lukas Yes, you're right, I think we can fix it in this way. diff --git a/misc/fsck.c b/misc/fsck.c index 1f6ec7d9..91edbf17 100644 --- a/misc/fsck.c +++ b/misc/fsck.c @@ -547,6 +547,8 @@ static int kill_all(int signum) for (inst = instance_list; inst; inst = inst->next) { if (inst->flags & FLAG_DONE) continue; + if (inst->pid == -1) + continue; kill(inst->pid, signum); n++; } > > > diff --git a/misc/fsck.c b/misc/fsck.c > index 1f6ec7d9..8fae7730 100644 > --- a/misc/fsck.c > +++ b/misc/fsck.c > @@ -497,9 +497,10 @@ static int execute(const char *type, const char *device, const char *mntpt, > } > > /* Fork and execute the correct program. */ > - if (noexecute) > + if (noexecute) { > pid = -1; > - else if ((pid = fork()) < 0) { > + inst->flags |= FLAG_DONE; > + } else if ((pid = fork()) < 0) { > perror("fork"); > free(inst); > return errno; > @@ -544,6 +545,9 @@ static int kill_all(int signum) > struct fsck_instance *inst; > int n = 0; > > + if (noexecute) > + return 0; > + > for (inst = instance_list; inst; inst = inst->next) { > if (inst->flags & FLAG_DONE) > continue; regards, Zhan Chengbin