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 53FE61420DD; Tue, 27 Feb 2024 14:22:26 +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=1709043746; cv=none; b=Cb5R78orUybn0Y+ssqreAyVAjeperviYdNA2No9w63ZhrdlT9N6F1FttfH69bsNhjIfT5JSpGHfTu4N3k5YUK73Atp4AW+O47fFCxmOe8vISj/VVCTBwvUy77JFlD2UWDtNaaOdUIFFvmqIHCNBdXkvOYyUOPbURuoiL0hlwJ0M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709043746; c=relaxed/simple; bh=/7zTOv46Gl+ngMKCx6LWHVDgcfJK9yxqYVuaQ5ieZaU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y7T0uMKjhj0x6jon67HJcuHaavOFGuFni49violbqj8AiXP3mtmeZkbf3msZJ/ZLQVzltaxfHi22dC44fasAt0Rbjg2U9IeD2q2LXxXK8nepLTo+uuUa7tx9eWB9WajZ48yWP+rjMk/o/DVyLsPV3VsX1dnw/y99tXhvQWyuJm0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=VZrrqTG0; 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="VZrrqTG0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4FF9C433F1; Tue, 27 Feb 2024 14:22:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1709043746; bh=/7zTOv46Gl+ngMKCx6LWHVDgcfJK9yxqYVuaQ5ieZaU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VZrrqTG0Uniy/vyX+yUDjbkEid6XnIjkDNQ67WE5IajPVMtQMCHu7wftf2QGkAbug nuUSPRVrBm9PgS8aXrgzgjfLvOYY+WwmvbADIETAzlUkxkOBXm1aqnhXMyiyqC5yjP XFzzNJHToAK9x8k/exldOEAgQdtaXMnutF6N0YWI= 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 5.4 22/84] ext4: avoid allocating blocks from corrupted group in ext4_mb_find_by_goal() Date: Tue, 27 Feb 2024 14:26:49 +0100 Message-ID: <20240227131553.588673260@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240227131552.864701583@linuxfoundation.org> References: <20240227131552.864701583@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-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 1af9daaff8ba2..e823731110e3e 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