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 2A3D28BE8; Tue, 30 Jul 2024 16:33:46 +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=1722357226; cv=none; b=pHnptHH0+Ef/qNV7XmmH0g6MX6q+uF8CMlgpXx2Ksk/6tYc5dxFhUQuyduQxc/q8tG9LbBxI9UBa0WCHLU4ANGv6F6bML2mTo/wbC2P0tKdkqcpCuUnJq35rBO+EKZygjm0trTsCjU+/7zUq6ls7yRG3F02MSppW2RTVGlCkwAo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722357226; c=relaxed/simple; bh=8xRlvFmHmTCf1i3b7vY5vqSCXhOS5IYh5B1g/QDiln8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W/IdN9k0ZJZIL97dm8J2ja0AiIyQefh7alMgsNWdf3cbfDXX1YGTU46kojUJJ9v708Le+oSGTHmKNmO5/7IRIJQSWbJtyforv20RMtoCRLs/4RmngkmFtITaB0y5YwOe3aFHfOmAaI5hwLrulnIVCgyiVizx0X2Wb8GBNq/m5GA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=eSv8hQSM; 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="eSv8hQSM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4D97C32782; Tue, 30 Jul 2024 16:33:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1722357226; bh=8xRlvFmHmTCf1i3b7vY5vqSCXhOS5IYh5B1g/QDiln8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eSv8hQSMzq4fiqVPj0q0qimfnih0NZgDEBDNNS19DQnkk/XCexyQxeM7RmsDZR9Ay XeMaAi8RN9SdXNFSk0shHIIo9rvgjaHaKAoJZnX8wS5UrIn4T+WHVHYyHmwXr+stpE dkbhzYNTH08R7lnVzaP/6M1Gh425kciWri6BR7UA= 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.6 231/568] ext4: fix infinite loop when replaying fast_commit Date: Tue, 30 Jul 2024 17:45:38 +0200 Message-ID: <20240730151648.910591769@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240730151639.792277039@linuxfoundation.org> References: <20240730151639.792277039@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.6-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 f4b50652f0cce..d9d5cfb9c951a 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