Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp10630199rwp; Fri, 21 Jul 2023 02:16:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlENQql9T3JgI0arXwQ1Onwv5AeFT2s8IGGq8fd9zqiZOi4509QPMYXoTX9anFhiAtPUNrLI X-Received: by 2002:a1f:4392:0:b0:47e:f7e:d2e9 with SMTP id q140-20020a1f4392000000b0047e0f7ed2e9mr825329vka.3.1689930994494; Fri, 21 Jul 2023 02:16:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689930994; cv=none; d=google.com; s=arc-20160816; b=L4rLz3vM30D3Q1wPVdtCjuJGZIJli4UrhCGA5C7ULQvFrgMXU91JFMQ1y4Qp++YiGs ZpAIfODGqLbbtHWXc3WQ5s1F8gqIuJNtpz84eu67KCF9aPUMKkFHW/AdEY51q0k0GeK6 VgYhfRsepeet8LeObPegKKVhh1rpqOUmIVBb3WIrUZspyYSlrkFxlZ+I2Vgsd1arejPZ KIJP2pbxTzSltb0D2/5Z33xJBXXbN5kayZFXXJPErY6SatyElywPMy4YGBQbGk6aYmMJ bDYmXDZAgh6fBtKNlY9lG2UKjkM3v1tH5dJdv6+rXaE40BOlSyqIJKJucB4q1vi4RLLZ HFLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=LXZDkbE1yGQqYEm081f2soMgVUBEksVq85+edYsEhZU=; fh=MlGqaUnvBjpXmiP990bdf+mzv9VjPrVaE5OVdv29XYE=; b=w2eOopZpTf40Z1e1K1OOKdFh3wZgxOaKKynY3PmAo6aYGpecOtCduAFgGaWDUcMYbU SYyH1/AgpxYKrDWxERGDZ9SPWiy4n++CKO2FQIvFZD85b2lqgEOQa9n/NogNRrqnj7gY wf+F8dmHGxeiYf7ebAurvS2HbVq9gIdizWKJubWBmINF7+y/igBxp51ptJaImhIPyowo yzqrGgNrLvS1KdDweT93cbPkSSnahaTGsRdo2qjKHleqn/UpPu7HEDokZZKpBzvkVFY6 pXKWc4SPwKTH+kEGF+Psl03yKuvR+pJloKLTNzOdwmMwhJHYNboDmpdccdkFm06K+H+6 EtYQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nu10-20020a17090b1b0a00b0026764aac11bsi5691513pjb.29.2023.07.21.02.16.20; Fri, 21 Jul 2023 02:16:34 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231470AbjGUJJp (ORCPT + 99 others); Fri, 21 Jul 2023 05:09:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231343AbjGUJJm (ORCPT ); Fri, 21 Jul 2023 05:09:42 -0400 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF6BB30C0; Fri, 21 Jul 2023 02:09:40 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4R6kJt34nwz4f3mLw; Fri, 21 Jul 2023 17:09:34 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP4 (Coremail) with SMTP id gCh0CgAHvrFPS7pkqi7fOQ--.527S3; Fri, 21 Jul 2023 17:09:36 +0800 (CST) From: Kemeng Shi To: tytso@mit.edu, adilger.kernel@dilger.ca, ritesh.list@gmail.com, ojaswin@linux.ibm.com, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Cc: shikemeng@huaweicloud.com Subject: [PATCH 01/10] ext4: correct grp validation in ext4_mb_good_group Date: Sat, 22 Jul 2023 01:09:58 +0800 Message-Id: <20230721171007.2065423-2-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230721171007.2065423-1-shikemeng@huaweicloud.com> References: <20230721171007.2065423-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgAHvrFPS7pkqi7fOQ--.527S3 X-Coremail-Antispam: 1UD129KBjvdXoWruryxZrWUXFWrJF1fZF48tFb_yoW3Xwb_Ga 4DAr4kAFZ3J34Ik3WIyws7try0ga1xGr45J39xtr45ZF98WF4kAa4kJryfAF4xWrWav345 Za45GryUKrWSvjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUb6AFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M28IrcIa0xkI8V A2jI8067AKxVWUGwA2048vs2IY020Ec7CjxVAFwI0_JFI_Gr1l8cAvFVAK0II2c7xJM28C jxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI 8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E 87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64 kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm 72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYx C7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_ Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x 0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8 JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIx AIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7sREgyCDUUUUU= = X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Group corruption check will access memory of grp and will trigger kernel crash if grp is NULL. So do NULL check before corruption check. Signed-off-by: Kemeng Shi --- fs/ext4/mballoc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 3ab37533349f..90ffabac100b 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -2554,7 +2554,7 @@ static bool ext4_mb_good_group(struct ext4_allocation_context *ac, BUG_ON(cr < CR_POWER2_ALIGNED || cr >= EXT4_MB_NUM_CRS); - if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(grp) || !grp)) + if (!grp || unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(grp))) return false; free = grp->bb_free; -- 2.30.0