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 1129C1420A8; Tue, 27 Feb 2024 14:04:59 +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=1709042699; cv=none; b=Ot1tx+GQwwfUvv/dJKNNFbCLgA2B9CjZJnI3ZNltm/TjDmyGIGR9VfXDhzDwU7Sz3knNdjd6bdc4SHydwy69oSYzjL84KObVrl6Jdgw66ZZC48FO7nx0eR5ZbWA0uE7HYoCINrRiYyudhuNF9NdMdFpbE7NDhFbeIbUtR1cRNYU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709042699; c=relaxed/simple; bh=nbnnXqHwj7eDmXGnqVBQazOjKY7+6tK50wck8iSzPfI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gRGXY9BiKCE+t01iHGh0V2NviQ/2EEFFZmYakEcbfyEGxGhK1MvxxohQe7CDHIV9PZuvq/LceVTGzjsAnuTHEikazsi54/gHaus7/Nz6wDG1rOI+dSiZwcR10jZee2DSm6/JJyIWfQNk0d/Z81daDV6FrfFNEpe8JRIQr6d7hmY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=qMsE+pXK; 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="qMsE+pXK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F724C433F1; Tue, 27 Feb 2024 14:04:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1709042698; bh=nbnnXqHwj7eDmXGnqVBQazOjKY7+6tK50wck8iSzPfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qMsE+pXKZWNs9Kz2L6Y6T+JkiFjy8E076+VrB88OyYDhcRRS4ks+TryObSGHYUvYE 28HI8zax7Gv8EcsNVWhShMA9p0E1+WmNA4LMDjje7iKSu7hIRoywd2ojmrcd3Xix2I dCJR3fLZqEDrrtkhaGjsxuE+2txD1DuuXM/C2Xlk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Robert Morris , Konstantin Komarov , Sasha Levin Subject: [PATCH 5.15 061/245] fs/ntfs3: Correct function is_rst_area_valid Date: Tue, 27 Feb 2024 14:24:09 +0100 Message-ID: <20240227131617.225221638@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240227131615.098467438@linuxfoundation.org> References: <20240227131615.098467438@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.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Konstantin Komarov [ Upstream commit 1b7dd28e14c4728ae1a815605ca33ffb4ce1b309 ] Reported-by: Robert Morris Signed-off-by: Konstantin Komarov Signed-off-by: Sasha Levin --- fs/ntfs3/fslog.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c index 8b95c06e5a4c5..6ba1357f3ed4c 100644 --- a/fs/ntfs3/fslog.c +++ b/fs/ntfs3/fslog.c @@ -465,7 +465,7 @@ static inline bool is_rst_area_valid(const struct RESTART_HDR *rhdr) { const struct RESTART_AREA *ra; u16 cl, fl, ul; - u32 off, l_size, file_dat_bits, file_size_round; + u32 off, l_size, seq_bits; u16 ro = le16_to_cpu(rhdr->ra_off); u32 sys_page = le32_to_cpu(rhdr->sys_page_size); @@ -511,13 +511,15 @@ static inline bool is_rst_area_valid(const struct RESTART_HDR *rhdr) /* Make sure the sequence number bits match the log file size. */ l_size = le64_to_cpu(ra->l_size); - file_dat_bits = sizeof(u64) * 8 - le32_to_cpu(ra->seq_num_bits); - file_size_round = 1u << (file_dat_bits + 3); - if (file_size_round != l_size && - (file_size_round < l_size || (file_size_round / 2) > l_size)) { - return false; + seq_bits = sizeof(u64) * 8 + 3; + while (l_size) { + l_size >>= 1; + seq_bits -= 1; } + if (seq_bits != ra->seq_num_bits) + return false; + /* The log page data offset and record header length must be quad-aligned. */ if (!IS_ALIGNED(le16_to_cpu(ra->data_off), 8) || !IS_ALIGNED(le16_to_cpu(ra->rec_hdr_len), 8)) -- 2.43.0