Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp4287388rwo; Tue, 25 Jul 2023 03:57:08 -0700 (PDT) X-Google-Smtp-Source: APBJJlF1ti1/6hekw/aDMlJYDTPrerk2nbp4/qMCofwULMnYZCYcmwBw0RT3Oabnj0XBZyiO2PBu X-Received: by 2002:a17:902:dac9:b0:1b8:7613:594d with SMTP id q9-20020a170902dac900b001b87613594dmr3033924plx.24.1690282628068; Tue, 25 Jul 2023 03:57:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690282628; cv=none; d=google.com; s=arc-20160816; b=oviAzeHc3c6XnaUnbasrwvVswgqWBACl1eCdCN+0UY09itzmd9Jfyf9DP4e69ZQymq DcmLyf0AkWu3noRlkGKbVxQQbTTVqCPG3gKlCDj0gJ0lBed/cs0RIhafBXmio+t6lQNa /joCx1EiQjpFPswHsnymh64/9/X4ZRNz10+8Lha940Zr2J7oZOBh97Vlqt5XqhKUiXHp EwtMdRoSOYlSPwiKS9/4TCrGXU3OIfKDdiv2H/2hAA9gZmxJhP6pa0tilFd2rfJW+FH/ JemSZC8g6tkJJ34A13uXQWWzSdRzWjfeVPQLZo0cT0ML9OvzytfuqbvTb429Wh4xO37y iCbA== 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=Es6z/R6ul/+apTi6bSNtyEIICMgGSyS+J4p1vOv8wac=; fh=MlGqaUnvBjpXmiP990bdf+mzv9VjPrVaE5OVdv29XYE=; b=OY0+3kLjQcFHzXU3CbXPpOg2ok3SgWKc33C++xkJsZyGYv5YUiCrKwVrHFzNAWIPKr 20VYgpMGWdFBb5Jv6MOtD4DcJQ6QWG9QkARZT8P0wfUEm0aSL2IJDlBs5ciL19zdB6FJ 3lLg+qkjy7x11oCzGYlVq9cOV+I2BEqMDZup6Tv7whn2sq0M8vc9kqCBmkZ2vWUFOoXf ihKSMyG0aUpeBbdUNM6O+HgAepceaBcNRgtew24JJvWR1rdNoKqFZa+E6aJPx0TdZLd5 n1yGfnstwu3qVFctIqx5KjaMMVInqYaWX77ffBLQD3tHeE63ShWd10fbZ5YdaWBHCgW5 ueTw== 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 kn8-20020a170903078800b001b8922e82e3si10318835plb.297.2023.07.25.03.56.53; Tue, 25 Jul 2023 03:57:08 -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 S232356AbjGYKva (ORCPT + 99 others); Tue, 25 Jul 2023 06:51:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233784AbjGYKvJ (ORCPT ); Tue, 25 Jul 2023 06:51:09 -0400 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C43751FDB; Tue, 25 Jul 2023 03:50:43 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4R9DMg32S7z4f3pJ4; Tue, 25 Jul 2023 18:50:39 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP2 (Coremail) with SMTP id Syh0CgC3quj+qL9kl7XQOg--.17520S3; Tue, 25 Jul 2023 18:50:40 +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 v2 01/10] ext4: correct grp validation in ext4_mb_good_group Date: Wed, 26 Jul 2023 02:50:57 +0800 Message-Id: <20230725185106.2147273-2-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230725185106.2147273-1-shikemeng@huaweicloud.com> References: <20230725185106.2147273-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: Syh0CgC3quj+qL9kl7XQOg--.17520S3 X-Coremail-Antispam: 1UD129KBjvdXoW7XF13WFy3tr1xZr48Zr17Awb_yoW3tFX_Ga yDArs7AFZ3J340k3WIqw4vyrW0gF4fXr45Ja93tF43ZFW5WF4kAa4kJr13AFs7WayayFy5 Za45JryUKrWSvjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-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_Gr0_Cr1lIx 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, KHOP_HELO_FCRDNS,MAY_BE_FORGED,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. Fixes: 5354b2af3406 ("ext4: allow ext4_get_group_info() to fail") 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 456150ef6111..62e7a045ad79 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -2553,7 +2553,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 (unlikely(!grp || EXT4_MB_GRP_BBITMAP_CORRUPT(grp))) return false; free = grp->bb_free; -- 2.30.0