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 F246118801A; Tue, 30 Jul 2024 16:53:13 +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=1722358394; cv=none; b=WUqhMLlUZZrUCC/gdc0G+DZ8Mk8pdsWrxPLtRzkxlGiOuqOnPy1ClmfTWD/Ky3wZFddfMIoLzS0bJQ4PU59rNtSdDwxjdVaZe1a39QHsdi0P1VEX7EPMcp6CooPwytDoG9n8bw4AhPoEe3coxGwrk3/4zhZhqHjA+LdI6/Z0naU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722358394; c=relaxed/simple; bh=R8C0Tch6IO/vZCz9z5Fv3ZiPDkLoE685/XueCs0BzZE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RQGUGzTkStanxZemUlTdufU/W8ILD2PRbSw4BqA0vjZpXqu87Ee0XZsoy24BV3dUGkn5BpQoV7COVPmOomPnhEH54JOVg+WQiw2j5d7+nucDuWoDVf6yPcMUajKsObeEWKUQ/ZOuKgloD1rGGHRxqaDFDpWPmrSGxQPoFp2Ki08= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=mFt8vKFU; 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="mFt8vKFU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 682FFC32782; Tue, 30 Jul 2024 16:53:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1722358393; bh=R8C0Tch6IO/vZCz9z5Fv3ZiPDkLoE685/XueCs0BzZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mFt8vKFUpO1mmghGQC/s2b8DECz0ZZkXEaDeNl0D3XH8dPJsnFMxNzqSOGKBalC/V RE9EupiabXlB+a+vlGNugXTeUhVagxJ1Xzk71coYiZU5IEO26t98Gi8pyx/34VkMbh nFLMEo0T9rov3cjX7BKthPuFLGeQlymSG9UV48qQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Luis Henriques (SUSE)" , Zhang Yi , Theodore Tso , Sasha Levin Subject: [PATCH 6.10 355/809] ext4: fix infinite loop when replaying fast_commit Date: Tue, 30 Jul 2024 17:43:51 +0200 Message-ID: <20240730151738.664904323@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240730151724.637682316@linuxfoundation.org> References: <20240730151724.637682316@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.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Luis Henriques (SUSE) [ Upstream commit 907c3fe532253a6ef4eb9c4d67efb71fab58c706 ] When doing fast_commit replay an infinite loop may occur due to an uninitialized extent_status struct. ext4_ext_determine_insert_hole() does not detect the replay and calls ext4_es_find_extent_range(), which will return immediately without initializing the 'es' variable. Because 'es' contains garbage, an integer overflow may happen causing an infinite loop in this function, easily reproducible using fstest generic/039. This commit fixes this issue by unconditionally initializing the structure in function ext4_es_find_extent_range(). Thanks to Zhang Yi, for figuring out the real problem! Fixes: 8016e29f4362 ("ext4: fast commit recovery path") Signed-off-by: Luis Henriques (SUSE) Reviewed-by: Zhang Yi Link: https://patch.msgid.link/20240515082857.32730-1-luis.henriques@linux.dev Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- fs/ext4/extents_status.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c index 4a00e2f019d93..3a53dbb85e15b 100644 --- a/fs/ext4/extents_status.c +++ b/fs/ext4/extents_status.c @@ -310,6 +310,8 @@ void ext4_es_find_extent_range(struct inode *inode, ext4_lblk_t lblk, ext4_lblk_t end, struct extent_status *es) { + es->es_lblk = es->es_len = es->es_pblk = 0; + if (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY) return; -- 2.43.0