mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: liubaolin <liubaolin12138@163.com>
To: Namjae Jeon <linkinjeon@kernel.org>, theBIT5 x3zk <x3zk@outlook.com>
Cc: "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"open list:NTFS FILESYSTEM" <ntfs@lists.linux.dev>,
	Hyunchul Lee <hyc.lee@gmail.com>,
	Baolin Liu <liubaolin@kylinos.cn>
Subject: Re: ntfs: deleting $Extend breaks subsequent mount
Date: Tue, 24 Nov 2026 15:08:11 +0800	[thread overview]
Message-ID: <a2f75e81-b012-4bb1-8885-a2ed310fa988@163.com> (raw)
In-Reply-To: <CAKYAXd-MHxzjvc20J-x4VYBnuk3sVpzmHo+zrHb8n3nx8Aav6g@mail.gmail.com>



在 2026/11/24 09:40, Namjae Jeon 写道:
> On Tue, Nov 24, 2026 at 5:01 AM theBIT5 x3zk <x3zk@outlook.com> wrote:
>>
>> Hi,
> Hi,
>>
>> Was messing around with the new ntfs driver (fs/ntfs) on 7.4.0-rc3-1-mainline
>> and noticed you can just rm -rf '$Extend' even without show_sys_files.
>> After umount, the filesystem fails to mount again.
>>
>> Steps:
>>
>> # mount -t ntfs /root/ntfs.img /mnt -o loop
>> # cd /mnt
>> # ls '$Extend'
>> '$ObjId'  '$Quota'  '$Reparse'
>> # rm -rf '$Extend'
>> # cd /
>> # umount /mnt
>> # mount -t ntfs /root/ntfs.img /mnt -o loop
>> mount: /mnt: wrong fs type, bad option, bad superblock on /dev/loop0,
>>         missing codepage or helper program, or other error.
>>
>> dmesg:
>> ntfs: volume version 3.1, dev loop0, cluster size 4096
>> ntfs: (device loop0): load_system_files(): Failed to load $Extend.
>> ntfs: (device loop0): ntfs_fill_super(): Failed to load system files (-22).
> Please check the attached patch.
> Thanks for the report.

Hi Namjae,
   I noticed that NInoSetExtendSys() is only reached when looking up the
unnamed $DATA attribute returns -ENOENT. A file directly under $Extend
that has an unnamed $DATA attribute skips this path and never gets
NI_ExtendSys set, leaving it mutable without sys_immutable.

   I reproduced this with your patch applied, using default mount options
and a synthetic NTFS image containing a SYSTEM-marked file with unnamed
$DATA directly under $Extend. After remounting, this write still succeeds:
     echo changed > '/mnt/$Extend/review-data'

   Could we move the direct-child classification into the common
inode-loading path, so that setting NI_ExtendSys does not depend on
whether the unnamed $DATA attribute exists?
   I tested the change below in QEMU. The write above is now rejected
with EPERM, and normal file, hard-link, symlink and remount checks pass.

Thanks,
Baolin

You may consider applying the following change on top of your attached 
patch:
**************************************************************************
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index e1c5a767e62b..c0e2535401bb 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -959,6 +959,15 @@ static int ntfs_read_locked_inode(struct inode *vi)
                 goto unm_err_out;
         }

+       /* Classify $Extend children regardless of their data/index 
layout. */
+       if (ni->mft_no >= FILE_first_user) {
+               err = ntfs_is_extended_system_file(ctx);
+               if (err < 0)
+                       goto unm_err_out;
+               if (err > 0)
+                       NInoSetExtendSys(ni);
+       }
+
         if (ni->flags & FILE_ATTR_REPARSE_POINT) {
                 unsigned int mode;

@@ -1163,7 +1172,6 @@ static int ntfs_read_locked_inode(struct inode *vi)
                          */
                         extend_sys = ntfs_is_extended_system_file(ctx);
                         if (extend_sys > 0) {
-                               NInoSetExtendSys(ni);
                                 if (m->flags & MFT_RECORD_IS_VIEW_INDEX) {
                                         if (extend_sys == 2) {
                                                 name = reparse_index_name;


      reply	other threads:[~2026-11-24  7:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 20:01 theBIT5 x3zk
2026-11-24  1:40 ` Namjae Jeon
2026-11-24  7:08   ` 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=a2f75e81-b012-4bb1-8885-a2ed310fa988@163.com \
    --to=liubaolin12138@163.com \
    --cc=hyc.lee@gmail.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liubaolin@kylinos.cn \
    --cc=ntfs@lists.linux.dev \
    --cc=x3zk@outlook.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

all inboxes | Powered by JetHome®