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 C052913DB83; Tue, 27 Feb 2024 13:44:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709041482; cv=none; b=cKkzZLD0eM3TCpl3DLxxx2tIH1lLBfG+XC/PlqJ6GeLE1dsSj4lR6NatxfduHFMZOH+TWWR8YTLZcKc6bdt9Z0A7Wv+4k5AMz1PfgpxTZUewdaIfD5/l9Qn1D0DoS8wQt6FAM8xzipu7ydiT9C3UnTX8Lj9CFrRyQqHKYF8gBio= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709041482; c=relaxed/simple; bh=KdDCwOwNcilrJyLwYGP/IDXRl77LbNLWOim0QDe9Ars=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RhmJ5fRvummxZm126DHYFz4CN2izIGhi7EJshDCXBmYm8AEUqElq75Y9hgyg6oJZFnoJHVnTHODNA+rPuepNkEyN2NyfbDBh0pI6UVAcmacuNWbqAFEReI2oG2yoJJ4WH+SLRbrsOCS/4ounA7XCmyh+iBMY9ngXrsr+/sUvPnA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ezV2hKsw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ezV2hKsw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F7B0C433F1; Tue, 27 Feb 2024 13:44:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1709041482; bh=KdDCwOwNcilrJyLwYGP/IDXRl77LbNLWOim0QDe9Ars=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ezV2hKsw1/iE9ouQEMuPdm7EXGK9C0YLdvdANQR3deQGiX0z+s1IlgXF64b/HNg0B 62ju0MyNkkTos9IjZhBeSRASmPaJaFzxowsily04OUyqEJnAWaKwl/Ay7g5vDfiKLb RmJYi0Xwwgik/lFVgVGCjb4eTqXX1iPEaHM3oBmw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Baokun Li , Jan Kara , Theodore Tso , Sasha Levin Subject: [PATCH 4.19 20/52] ext4: avoid allocating blocks from corrupted group in ext4_mb_find_by_goal() Date: Tue, 27 Feb 2024 14:26:07 +0100 Message-ID: <20240227131549.196146986@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240227131548.514622258@linuxfoundation.org> References: <20240227131548.514622258@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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Baokun Li [ Upstream commit 832698373a25950942c04a512daa652c18a9b513 ] Places the logic for checking if the group's block bitmap is corrupt under the protection of the group lock to avoid allocating blocks from the group with a corrupted block bitmap. Signed-off-by: Baokun Li Reviewed-by: Jan Kara Link: https://lore.kernel.org/r/20240104142040.2835097-8-libaokun1@huawei.com Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- fs/ext4/mballoc.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index e0dd01cb1a0e7..5af5ad53e0ada 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -1839,12 +1839,10 @@ int ext4_mb_find_by_goal(struct ext4_allocation_context *ac, if (err) return err; - if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info))) { - ext4_mb_unload_buddy(e4b); - return 0; - } - ext4_lock_group(ac->ac_sb, group); + if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info))) + goto out; + max = mb_find_extent(e4b, ac->ac_g_ex.fe_start, ac->ac_g_ex.fe_len, &ex); ex.fe_logical = 0xDEADFA11; /* debug value */ @@ -1877,6 +1875,7 @@ int ext4_mb_find_by_goal(struct ext4_allocation_context *ac, ac->ac_b_ex = ex; ext4_mb_use_best_found(ac, e4b); } +out: ext4_unlock_group(ac->ac_sb, group); ext4_mb_unload_buddy(e4b); -- 2.43.0