From: liubaolin <liubaolin12138@163.com>
To: shaos <shawnq1@163.com>, linkinjeon@kernel.org
Cc: hyc.lee@gmail.com, ntfs@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] ntfs: guard the final LZNT1 sub-block header read
Date: Wed, 25 Nov 2026 20:41:57 +0800 [thread overview]
Message-ID: <9cb7cd4e-a7ba-4d14-bf39-2910181e8a78@163.com> (raw)
In-Reply-To: <20261125085004.1816027-1-shawnq1@163.com>
在 2026/11/25 16:50, shaos 写道:
> The legacy NTFS LZNT1 decompressor reads a 16-bit sub-block header
> before checking that the full header remains in the compression
> buffer. If only one byte remains, the read crosses the end of the
> 64 KiB buffer.
>
> Return -EOVERFLOW for an incomplete header while preserving successful
> termination when the buffer is exactly exhausted. Validate phrase-token
> length against the sub-block boundary before reading it.
>
> Tested on x86-64 with QEMU. The original header-boundary reproducer
> and a phrase-token boundary reproducer no longer fault; both malformed
> streams are rejected with -EOVERFLOW. The one-byte control still
> returns byte 'A'.
>
> Fixes: 1e9ea7e04472 ("Revert "fs: Remove NTFS classic"")
> Signed-off-by: shaos <shawnq1@163.com>
> ---
> fs/ntfs/compress.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c
> index 82c7c7d290737..c7c520d31c53d 100644
> --- a/fs/ntfs/compress.c
> +++ b/fs/ntfs/compress.c
> @@ -200,10 +200,11 @@ do_next_sb:
> cb - cb_start);
> /*
> * Have we reached the end of the compression block or the end of the
> - * decompressed data? The latter can happen for example if the current
> - * position in the compression block is one byte before its end so the
> - * first two checks do not detect it.
> + * decompressed data?
> */
> + if (cb != cb_end && cb_end - cb < sizeof(__le16))
> + goto return_overflow;
> +
> if (cb == cb_end || !le16_to_cpup((__le16 *)cb) ||
> (*dest_index == dest_max_index &&
> *dest_ofs == dest_max_ofs)) {
> @@ -384,6 +385,10 @@ do_next_tag:
> for (i = *dest_ofs - do_sb_start - 1; i >= 0x10; i >>= 1)
> lg++;
>
> + /* Make sure the phrase token is fully within the sub-block. */
> + if (cb_sb_end - cb < sizeof(__le16))
> + goto return_overflow;
> +
> /* Get the phrase token into i. */
> pt = le16_to_cpup((__le16 *)cb);
>
Looks good to me.
Reviewed-by: Baolin Liu <liubaolin@kylinos.cn>
next prev parent reply other threads:[~2026-11-25 12:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 5:17 [PATCH] ntfs: guard the final LZNT1 sub-block header read shaos
2026-11-25 7:39 ` Hyunchul Lee
2026-11-25 8:50 ` [PATCH v2] " shaos
2026-11-25 12:41 ` liubaolin [this message]
2026-11-26 1:46 ` Hyunchul Lee
2026-11-26 5:09 ` Namjae Jeon
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=9cb7cd4e-a7ba-4d14-bf39-2910181e8a78@163.com \
--to=liubaolin12138@163.com \
--cc=hyc.lee@gmail.com \
--cc=linkinjeon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ntfs@lists.linux.dev \
--cc=shawnq1@163.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.