From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D91E41170E for ; Mon, 11 Sep 2023 14:09:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57479C433C8; Mon, 11 Sep 2023 14:09:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1694441385; bh=DZ+FriIvgNX1eXp1t6VzSgiFABfBWHvkafED/e8pK3k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jbQN8XAeNXyS/WnpXWLFoPWo0LnrdJ8gjF5rmG2fetfTGHJhuI6hK4r9mGWbwA2ac qFYBXN8iAjlELk0AbjLgXqW30b4/NDPB+/zWdljya10HntrJqa6Xt3QwuTczwye/QG FGjAZYvodAa1R6cPZiLWE/IPYFw+WIpEi6iu6jAo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kemeng Shi , "Ritesh Harjani (IBM)" , Theodore Tso , Sasha Levin Subject: [PATCH 6.5 394/739] ext4: correct grp validation in ext4_mb_good_group Date: Mon, 11 Sep 2023 15:43:13 +0200 Message-ID: <20230911134702.192245975@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230911134650.921299741@linuxfoundation.org> References: <20230911134650.921299741@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.5-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kemeng Shi [ Upstream commit a9ce5993a0f5c0887c8a1b4ffa3b8046fbcfdc93 ] 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 Reviewed-by: Ritesh Harjani (IBM) Link: https://lore.kernel.org/r/20230801143204.2284343-2-shikemeng@huaweicloud.com Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- 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 21b903fe546e8..b00b7adf1461d 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.40.1