public inbox for ntfs3@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 5.15 1/8] fs/ntfs3: Check if more than chunk-size bytes are written
@ 2024-10-14  3:59 Sasha Levin
  2024-10-14  3:59 ` [PATCH AUTOSEL 5.15 2/8] fs/ntfs3: Fix warning possible deadlock in ntfs_set_state Sasha Levin
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sasha Levin @ 2024-10-14  3:59 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Andrew Ballance, Konstantin Komarov, Sasha Levin, ntfs3

From: Andrew Ballance <andrewjballance@gmail.com>

[ Upstream commit 9931122d04c6d431b2c11b5bb7b10f28584067f0 ]

A incorrectly formatted chunk may decompress into
more than LZNT_CHUNK_SIZE bytes and a index out of bounds
will occur in s_max_off.

Signed-off-by: Andrew Ballance <andrewjballance@gmail.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/ntfs3/lznt.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/ntfs3/lznt.c b/fs/ntfs3/lznt.c
index 28f654561f279..09db01c1098cd 100644
--- a/fs/ntfs3/lznt.c
+++ b/fs/ntfs3/lznt.c
@@ -236,6 +236,9 @@ static inline ssize_t decompress_chunk(u8 *unc, u8 *unc_end, const u8 *cmpr,
 
 	/* Do decompression until pointers are inside range. */
 	while (up < unc_end && cmpr < cmpr_end) {
+		// return err if more than LZNT_CHUNK_SIZE bytes are written
+		if (up - unc > LZNT_CHUNK_SIZE)
+			return -EINVAL;
 		/* Correct index */
 		while (unc + s_max_off[index] < up)
 			index += 1;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-10-14  3:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-14  3:59 [PATCH AUTOSEL 5.15 1/8] fs/ntfs3: Check if more than chunk-size bytes are written Sasha Levin
2024-10-14  3:59 ` [PATCH AUTOSEL 5.15 2/8] fs/ntfs3: Fix warning possible deadlock in ntfs_set_state Sasha Levin
2024-10-14  3:59 ` [PATCH AUTOSEL 5.15 3/8] fs/ntfs3: Fix possible deadlock in mi_read Sasha Levin
2024-10-14  3:59 ` [PATCH AUTOSEL 5.15 4/8] fs/ntfs3: Additional check in ni_clear() Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox