* [PATCH] fs/ntfs3: keep the current mount options on remount
@ 2026-12-03 21:20 Yifan Feng
0 siblings, 0 replies; only message in thread
From: Yifan Feng @ 2026-12-03 21:20 UTC (permalink / raw)
To: Konstantin Komarov
Cc: Christian Brauner, ntfs3, linux-fsdevel, linux-kernel, Yifan Feng
ntfs_init_fs_context() fills every new context with the default
options, and ntfs_fs_reconfigure() installs them as they are. So a
remount that does not repeat uid=, gid=, umask= and the other options
resets them, and files that the masks protected become readable by
everyone:
# mount -t ntfs3 -o umask=077 /dev/vda /mnt
# findmnt -no OPTIONS /mnt
rw,relatime,uid=0,gid=0,dmask=0077,fmask=0077,iocharset=utf8,prealloc,ads
# mount -o remount,noatime /dev/vda /mnt
# findmnt -no OPTIONS /mnt
rw,noatime,uid=0,gid=0,iocharset=utf8,prealloc,ads
With an iocharset other than the default, the same remount fails with
EINVAL. mount(8) hides both when it is given the mount point only,
because it then passes the current options again. The emergency
remount (sysrq u) passes no options: it resets them as well, and with
such an iocharset it triggers the "forced remount of a ntfs3 fs
returned -22" warning in reconfigure_super().
For a remount, start from the options in use. The iocharset cannot be
changed by a remount, so take over its name in ntfs_fs_reconfigure()
when the remount does not give one.
Fixes: 82cae269cfa9 ("fs/ntfs3: Add initialization of super block")
Signed-off-by: Yifan Feng <evanfengff@gmail.com>
---
Tested in QEMU (KASAN, lockdep) with mount(2), mount(8) from util-linux 2.38.1, fspick()/fsconfig() and sysrq u, and with 900 remounts during path lookups. Options without a "no" form (discard, nocase, ...) now stay set over a remount.
Found and written with the help of an AI coding assistant.
fs/ntfs3/super.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 29aabdc8a801..2203703ebf1c 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -483,6 +483,11 @@ static int ntfs_fs_reconfigure(struct fs_context *fc)
return -EINVAL;
}
+ if (!new_opts->nls_name && sbi->options->nls_name) {
+ new_opts->nls_name = kstrdup(sbi->options->nls_name, GFP_KERNEL);
+ if (!new_opts->nls_name)
+ return -ENOMEM;
+ }
new_opts->nls = ntfs_load_nls(new_opts->nls_name);
if (IS_ERR(new_opts->nls)) {
new_opts->nls = NULL;
@@ -1957,8 +1962,14 @@ static int ntfs_init_fs_context(struct fs_context *fc)
fc->sb_flags |= SB_POSIXACL;
#endif
- if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE)
+ if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE) {
+ rcu_read_lock();
+ *opts = *READ_ONCE(ntfs_sb(fc->root->d_sb)->options);
+ rcu_read_unlock();
+ opts->nls_name = NULL;
+ opts->nls = NULL;
goto ok;
+ }
sbi = kzalloc_obj(struct ntfs_sb_info, GFP_NOFS);
if (!sbi)
base-commit: d06ce6f1eb5eeffd4ebcfde345dc34a98131d106
--
2.39.3 (Apple Git-146)
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-03 21:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 21:20 [PATCH] fs/ntfs3: keep the current mount options on remount Yifan Feng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox