NTFS3 file system kernel mode driver
 help / color / mirror / Atom feed
From: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
To: ZhengYuan Huang <gality369@gmail.com>
Cc: <ntfs3@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
	<baijiaju1990@gmail.com>, <r33s3n6@gmail.com>,
	<zzzccc427@gmail.com>
Subject: Re: [PATCH] fs/ntfs3: preserve non-DOS attribute bits in system.dos_attrib
Date: Fri, 22 May 2026 15:49:34 +0200	[thread overview]
Message-ID: <48aecc55-eca1-4bcc-82cb-e24c7d03365f@paragon-software.com> (raw)
In-Reply-To: <20260427032418.2678198-1-gality369@gmail.com>

On 4/27/26 05:24, ZhengYuan Huang wrote:

> [You don't often get email from gality369@gmail.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> [BUG]
> A corrupted ntfs3 image can hit a NULL function pointer call in
> generic_perform_write() after toggling system.ntfs_attrib and then
> overwriting system.dos_attrib on the same file.
>
> BUG: kernel NULL pointer dereference, address: 0000000000000000
> \#PF: supervisor instruction fetch in kernel mode
> \#PF: error_code(0x0010) - not-present page
> PGD bed5067 P4D bed5067 PUD 0
> Oops: Oops: 0010 [#1] SMP KASAN NOPTI
> RIP: 0010:0x0
> Code: Unable to access opcode bytes at 0xffffffffffffffd6.
> RSP: 0018:ffff88801025f988 EFLAGS: 00010246
> Call Trace:
>   generic_perform_write+0x409/0x8c0 mm/filemap.c:4255
>   __generic_file_write_iter+0x1bb/0x200 mm/filemap.c:4372
>   ntfs_file_write_iter+0xcd9/0x1c20 fs/ntfs3/file.c:1253
>   new_sync_write fs/read_write.c:593 [inline]
>   vfs_write+0x63b/0xf70 fs/read_write.c:686
>   ksys_write+0x133/0x250 fs/read_write.c:738
>   __do_sys_write fs/read_write.c:749 [inline]
>   __se_sys_write fs/read_write.c:746 [inline]
>   __x64_sys_write+0x77/0xc0 fs/read_write.c:746
>   ...
>
> [CAUSE]
> system.ntfs_attrib updates ATTR_DATA flags via ni_new_attr_flags()
> and switches i_mapping->a_ops to ntfs_aops_cmpr when
> FILE_ATTRIBUTE_COMPRESSED is set. system.dos_attrib then overwrites
> ni->std_fa from a one-byte DOS attribute value, clearing the compression
> bit without updating ATTR_DATA or the mapping operations.
>
> Old buffered writes use is_compressed(ni) to choose
> __generic_file_write_iter(). That leaves generic_perform_write() calling
> a NULL write_begin callback from ntfs_aops_cmpr.
>
> [FIX]
> Treat system.dos_attrib as a low-byte DOS attribute update and preserve the
> existing non-DOS attribute bits in ni->std_fa. This keeps compressed and
> sparse state consistent with ATTR_DATA and the mapping operations while
> keeping the existing DOS attribute semantics intact.
>
> Signed-off-by: ZhengYuan Huang <gality369@gmail.com>
> ---
>   fs/ntfs3/xattr.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
> index 9eeac0a..7e51182 100644
> --- a/fs/ntfs3/xattr.c
> +++ b/fs/ntfs3/xattr.c
> @@ -867,7 +867,9 @@ static noinline int ntfs_setxattr(const struct xattr_handler *handler,
>          if (!strcmp(name, SYSTEM_DOS_ATTRIB)) {
>                  if (sizeof(u8) != size)
>                          goto out;
> -               new_fa = cpu_to_le32(*(u8 *)value);
> +               /* system.dos_attrib only covers the low DOS attribute byte. */
> +               new_fa = (ni->std_fa & ~cpu_to_le32(0xff)) |
> +                        cpu_to_le32(*(u8 *)value);
>                  goto set_new_fa;
>          }
>
> --
> 2.43.0
>
Hello,

Sorry for the delay.
Queued for the next merge window, thank you.

Regards,
Konstantin


      reply	other threads:[~2026-05-22 13:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-27  3:24 [PATCH] fs/ntfs3: preserve non-DOS attribute bits in system.dos_attrib ZhengYuan Huang
2026-05-22 13:49 ` 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=48aecc55-eca1-4bcc-82cb-e24c7d03365f@paragon-software.com \
    --to=almaz.alexandrovich@paragon-software.com \
    --cc=baijiaju1990@gmail.com \
    --cc=gality369@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    --cc=r33s3n6@gmail.com \
    --cc=zzzccc427@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox