Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp421785rwi; Mon, 10 Oct 2022 02:17:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7snmdnR5hseWiJm5+9WQez53a1yuwQmpWePFGB6y/Bdj7wAv4tMWNVhbvrSjoRfePafaj/ X-Received: by 2002:a05:6402:2146:b0:458:15d7:b99a with SMTP id bq6-20020a056402214600b0045815d7b99amr17085432edb.24.1665393434443; Mon, 10 Oct 2022 02:17:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665393434; cv=none; d=google.com; s=arc-20160816; b=rjBcUoCs7qHfhiBBY2hLe5IYYgzq63UY661r1/W8DcXCibIMiIexEEzpcZLncQsWa0 1AL5Ln25njg2muJTiYkwNWlYE1VlPYdFA9S8FOa30Ki2q0GrKH1wrI2vTVe4+uInTQyw bhhgNpECSeHGjY4nkqhlmvS79XdwYAD/Mp7aYYlqFO6WI0imuZAXPbRWFcb+gLP+c3pw r6hjYXdIw9uB9vAyOcK5jiTxkXnTMlFFzv/eP5BQMW5v/d8uaTP/K08AABFLQVWVF36Z Bf7z2D7RcG+KbiYu2D+dmni1Voz4Xtu+f4MJZRO415AW20U1nQAEJn+VlKIwG9QmI+7+ 8wKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:subject:from:cc:to :user-agent:mime-version:date:message-id; bh=GGztlki/aCapDO4sVU/HX1I1qPPFG0iS6mITqG31+i0=; b=djlXpNV1My/GIu3MvJdxu0h5hFWz5r0BS5kQrxSsGvr8juCgzT4pWSrIVWkGT3OQ5c uDJcb37Ihd04mK8CWFF9x0rLw+CwHXjTs5nA4TUHGqYPd+gJWinrFcp9Sf/DrjonAif4 NflM8yN+b30ndcr8tJzeaOeqAazvUuLzeevqGx4Z6lxDPYk86Hfz/VKkocVb7qb7cYpu 5/mFGn81DX+B/V0phn0Xh5NpIAxru1+2O/G4J41aHWwU9JQvnqqwru8QCCyxoJcUw2Px inxtrkxKlH9ZRYqEdyxwknscllidtAfm/uRpn4mkZj0z/VOgrfH2Q4ktGwiCr1EvQetx 53zQ== 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 d24-20020aa7c1d8000000b0044e9f8ecd96si8113182edp.609.2022.10.10.02.16.42; Mon, 10 Oct 2022 02:17:14 -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 S231215AbiJJI5E (ORCPT + 99 others); Mon, 10 Oct 2022 04:57:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230437AbiJJI5D (ORCPT ); Mon, 10 Oct 2022 04:57:03 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 940A8631CA for ; Mon, 10 Oct 2022 01:57:01 -0700 (PDT) Received: from dggpeml500023.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MmCMj43KzzHtsr; Mon, 10 Oct 2022 16:52:01 +0800 (CST) Received: from dggpeml500016.china.huawei.com (7.185.36.70) by dggpeml500023.china.huawei.com (7.185.36.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 10 Oct 2022 16:56:59 +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, 10 Oct 2022 16:56:59 +0800 Message-ID: <2c8f3b3a-b6d1-9b8b-27c7-2df51236fe8c@huawei.com> Date: Mon, 10 Oct 2022 16:56:58 +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 To: Theodore Ts'o CC: , Lukas Czerner , , linfeilong From: zhanchengbin Subject: [PATCH v2] misc/fsck.c: Processes may kill other processes. Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.176.102] X-ClientProxiedBy: dggpeml100022.china.huawei.com (7.185.36.176) 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,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 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++; } -- 2.27.0