From: liubaolin <liubaolin12138@163.com>
To: Hyunchul Lee <hyc.lee@gmail.com>, Namjae Jeon <linkinjeon@kernel.org>
Cc: Baolin Liu <liubaolin@kylinos.cn>,
ntfs@lists.linux.dev, stable@vger.kernel.org
Subject: Re: [PATCH 1/4] ntfs: validate phrase output before advancing
Date: Fri, 4 Dec 2026 17:56:53 +0800 [thread overview]
Message-ID: <5b126fe9-7bde-4712-8efa-e1cacca08033@163.com> (raw)
In-Reply-To: <20261204055442.3619912-1-hyc.lee@gmail.com>
在 2026/12/4 13:54, Hyunchul Lee 写道:
> The LZNT1 phrase-token path advanced *dest_ofs before checking that the
> result fit in the current sub-block. On malformed input,
> ntfs_decompress() therefore returned with the caller's cur_ofs beyond
> the failed sub-block even though no phrase bytes had been copied.
>
> Check the phrase length against the sub-block bound first, copy it, and
> update *dest_ofs only after the copy succeeds, so a failure never leaves
> the destination position past the failed sub-block.
>
> Fixes: 1e9ea7e04472 ("Revert "fs: Remove NTFS classic"")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
> ---
> fs/ntfs/compress.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c
> index 2f11206b7428..86381ca2b878 100644
> --- a/fs/ntfs/compress.c
> +++ b/fs/ntfs/compress.c
> @@ -408,9 +408,8 @@ static int ntfs_decompress(struct page *dest_pages[], int completed_pages[],
> /* Now calculate the length of the byte sequence. */
> length = (pt & (0xfff >> lg)) + 3;
>
> - /* Advance destination position and verify it is in range. */
> - *dest_ofs += length;
> - if (*dest_ofs > do_sb_end)
> + /* Verify destination is in range. */
> + if (*dest_ofs + length > do_sb_end)
> goto return_overflow;
>
> /* The number of non-overlapping bytes. */
> @@ -432,11 +431,14 @@ static int ntfs_decompress(struct page *dest_pages[], int completed_pages[],
> memcpy(dp_addr, dp_back_addr, max_non_overlap);
> dp_addr += max_non_overlap;
> dp_back_addr += max_non_overlap;
> - length -= max_non_overlap;
> - while (length--)
> + i = length - max_non_overlap;
> + while (i--)
> *dp_addr++ = *dp_back_addr++;
> }
>
> + /* Advance destination offset after the copy succeeds. */
> + *dest_ofs += length;
> +
> /* Advance source position and continue with the next token. */
> cb += 2;
> }
Looks good to me.
Reviewed-by: Baolin Liu <liubaolin@kylinos.cn>
prev parent reply other threads:[~2026-12-04 9:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 5:54 [PATCH 1/4] ntfs: validate phrase output before advancing Hyunchul Lee
2026-12-04 5:54 ` [PATCH 2/4] ntfs: stop processing after a decompression failure Hyunchul Lee
2026-12-04 10:07 ` liubaolin
2026-12-04 5:54 ` [PATCH 3/4] ntfs: zero hole-filled pages above initialized_size Hyunchul Lee
2026-12-04 10:08 ` liubaolin
2026-12-04 5:54 ` [PATCH 4/4] ntfs: treat compression blocks beyond EOF as sparse Hyunchul Lee
2026-12-04 10:19 ` liubaolin
2026-12-04 9:56 ` liubaolin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5b126fe9-7bde-4712-8efa-e1cacca08033@163.com \
--to=liubaolin12138@163.com \
--cc=hyc.lee@gmail.com \
--cc=linkinjeon@kernel.org \
--cc=liubaolin@kylinos.cn \
--cc=ntfs@lists.linux.dev \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox