From: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
To: "Alexandro Calò" <alexandro.calo@nozominetworks.com>
Cc: "ntfs3@lists.linux.dev" <ntfs3@lists.linux.dev>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH] Fix OOB write if err == buflen in ntfs_readlink_hlp()
Date: Thu, 24 Sep 2026 17:37:05 +0200 [thread overview]
Message-ID: <63dedf61-1e76-421f-9b7f-c4e463f21aa8@paragon-software.com> (raw)
In-Reply-To: <029C54CF-FC6C-4BFA-854C-847F8E656626@nozominetworks.com>
On 7/8/26 13:30, Alexandro Calò wrote:
> [You don't often get email from alexandro.calo@nozominetworks.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> From 64361f8e12081dc8828480588bc48c2c931ffc91 Mon Sep 17 00:00:00 2001
> From: Alexandro Calo <alexandro.calo@nozominetworks.com>
> Date: Wed, 8 Jul 2026 12:04:37 +0200
> Subject: [PATCH] Fix OOB write if err == buflen in ntfs_readlink_hlp()
>
> ntfs_utf16_to_nls() may return buflen. The caller later uses the returned
> length as the index for writing the trailing NUL byte,
> so err == buflen writes one byte past the end of buffer.
>
> Fix this by limiting err to the last valid buffer index before writing
> NUL.
>
> ntfs_utf16_to_nls() returning a negative value is already handled by
> if (err < 0) goto out;
> As long as buflen is guaranteed to be nonzero the patch is fine.
> As a defensive fix if(buflen==0) could be added.
>
> This heap out-of-bounds write requires a crafted filesystem image,
> which is not in the kernel threat model, but fixing memory errors would
> be nice to keep things secure.
>
> Signed-off-by: Alexandro Calo <alexandro.calo@nozominetworks.com>
> ---
> fs/ntfs3/inode.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
> index 0c9bd669117d..d4803e1625fe 100644
> --- a/fs/ntfs3/inode.c
> +++ b/fs/ntfs3/inode.c
> @@ -2029,6 +2029,9 @@ static noinline int ntfs_readlink_hlp(const struct dentry *link_de,
> if (err < 0)
> goto out;
>
> + if (err >= buflen)
> + err = buflen - 1;
> +
> /* Translate Windows '\' into Linux '/'. */
> for (i = 0; i < err; i++) {
> if (buffer[i] == '\\')
>
> base-commit: 0e35b9b6ec0ffcc5e23cbdec09f5c622ad532b53
> --
> 2.47.3
Hello,
Sorry for the delay.
The patch is applied, thanks.
Regards,
Konstantin
prev parent reply other threads:[~2026-09-24 15:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 11:30 Alexandro Calò
2026-09-24 15:37 ` 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=63dedf61-1e76-421f-9b7f-c4e463f21aa8@paragon-software.com \
--to=almaz.alexandrovich@paragon-software.com \
--cc=alexandro.calo@nozominetworks.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ntfs3@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
all inboxes | Powered by JetHome®