From: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
To: Pengpeng Hou <pengpeng@iscas.ac.cn>
Cc: <ntfs3@lists.linux.dev>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] fs/ntfs3: terminate the cached volume label after UTF-8 conversion
Date: Tue, 7 Apr 2026 19:14:54 +0200 [thread overview]
Message-ID: <fe332d91-fd72-4499-9997-94593aabe786@paragon-software.com> (raw)
In-Reply-To: <20260327061955.46242-1-pengpeng@iscas.ac.cn>
On 3/27/26 07:19, Pengpeng Hou wrote:
> [You don't often get email from pengpeng@iscas.ac.cn. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> ntfs_fill_super() loads the on-disk volume label with utf16s_to_utf8s()
> and stores the result in sbi->volume.label. The converted label is later
> exposed through ntfs3_label_show() using %s, but utf16s_to_utf8s() only
> returns the number of bytes written and does not add a trailing NUL.
>
> If the converted label fills the entire fixed buffer,
> ntfs3_label_show() can read past the end of sbi->volume.label while
> looking for a terminator.
>
> Terminate the cached label explicitly after a successful conversion and
> clamp the exact-full case to the last byte of the buffer.
>
> Fixes: 82cae269cfa9 ("fs/ntfs3: Add initialization of super block")
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
> ---
> fs/ntfs3/super.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
> index 174a7cb202a0..9ed485f9efba 100644
> --- a/fs/ntfs3/super.c
> +++ b/fs/ntfs3/super.c
> @@ -1339,8 +1339,13 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
> le32_to_cpu(attr->res.data_size) >> 1,
> UTF16_LITTLE_ENDIAN, sbi->volume.label,
> sizeof(sbi->volume.label));
> - if (err < 0)
> + if (err < 0) {
> sbi->volume.label[0] = 0;
> + } else if (err >= sizeof(sbi->volume.label)) {
> + sbi->volume.label[sizeof(sbi->volume.label) - 1] = 0;
> + } else {
> + sbi->volume.label[err] = 0;
> + }
> } else {
> /* Should we break mounting here? */
> //err = -EINVAL;
> --
> 2.50.1 (Apple Git-155)
>
Hello,
Applied, thanks for the patch.
Regards,
Konstantin
prev parent reply other threads:[~2026-04-07 17:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-27 6:19 Pengpeng Hou
2026-04-07 17:14 ` Konstantin Komarov [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=fe332d91-fd72-4499-9997-94593aabe786@paragon-software.com \
--to=almaz.alexandrovich@paragon-software.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ntfs3@lists.linux.dev \
--cc=pengpeng@iscas.ac.cn \
/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
all inboxes | Powered by JetHome®