From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796332857; b=fisnt8TDTVLy7/TrNCxDcuS82FzeZHPXb7S+ORw8Zu0TIKlQSsS3kN9BI5aS6MmmGMri vhkhAUD4gzuv2K+tKjgqf48Z2VWyJWa4atSJYJvhO0P9Lat0vhUPr1Ey4xGUwrS0n1ZVN ggTSmZADoyHprwKx5+AkgQeAYBPWqBkYCEpQHnZln5yLvrHE/reWH4VRgRyph/GzEwhdd fKMCJowdomn0328ffR/ArI28DGjvnvdvv0XaZaaTFsz4mAwbNyhz7Juo2edu8A1WBbOMZ Vg6QGWDGwcBYlhUg+Z5DI/Oc14f/LXer33bY5Wku8Du4GgPh5lVEF1c94AxA9VqKX6Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796332857; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=98cFHDttXySM8av0xO4vY7TTIU+ZXN9GGMOoDmrffLU=; b=IFzZHa0mxa0dWNGIXMDBX9FYYUfb3IQL6VIDiPpzcN0XvrEHGWYcLcL+pXGxzCELJLPB eArulcPlLdUriYXBniJ9X31b70VDMTnuFU9LvYPoSHDh9B/OnSE7q/HIyyREPzoRDpFwB i9NhBXuRpMeylObObFHWe5QH66CJrrnvb2XCTlXsNzaWlr29rOX/3pYQXzlifHYs1o1ni jECFz3wXR6ChkXbUrqmNgtk64pg8l8sGF8EPO97ZGnZADMXeMt8q/7Tlv1tUr26j66oJN 2Frq/iIVn1DKLJKJPgRgW5g/+eJTyeRtLEUTpezSGiR9AHKy/bX7zybeJ91UWLVsB7w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=BbQtnC1c; arc=none smtp.remote-ip=209.85.219.47 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7154606A335 for ; Thu, 3 Dec 2026 21:20:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C7154606A335 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=BbQtnC1c Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-921d18b2fdfso2471416d6.3 for ; Thu, 03 Dec 2026 13:20:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796332856; x=1796937656; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=98cFHDttXySM8av0xO4vY7TTIU+ZXN9GGMOoDmrffLU=; b=BbQtnC1cZhX1hI/kWkwpzJTnMOuxls8nX6zf08N9+WDSpcesohA9uWqySVA1hgDYxF jETzQCth+yG1Ew+sRFcdtjll9UyjrQfNVDITbwtp+8W40q2DkZcNjwESrjqc5ZlqEqbX Qap5psRRHwqGDCzmM0gDHJiTbuxAe+mMpZtFrM3QI7sZaVw1yYMFTQ7HLpndLsP7SU1j H52NmUYk1R/LFOTezww1PcCGeoBoGJeOtWhUWgytCyEtn38pzlXfqshpBPdgwFJjnHLr Mtjr1yjbF4ODrcaZs3FZMT5NjJp/bRCa+8QUyFLRCb4Yw41akvqL4M6ijNXnl6Hbtc7A fNLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796332856; x=1796937656; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=98cFHDttXySM8av0xO4vY7TTIU+ZXN9GGMOoDmrffLU=; b=kLHZKpf1/olyp+y9vOZht7DyozZd59fNUq6VyE6zp3cYEhBIg4nmP/Z64VESqGy+YM 5nOAUgumcUudEfJDHfD0xGsBth2RBVOEByO0370pWNsrdZOIk/9B/luVW1j5L0YC8N6l ZDqJ5bhUmADJBXaCP6mDXZinQeR/54cdVvGVnz3D9V0SIxkkgsWNbUZefP/BwiCHQ3xH jYpPSaPHmbP++YhS7EXAAI/eJ1qUU1dE42F7bEpA42KPO0jmGLfFkjfrPIXH1mzG4GZi a26qVisOJPN6xczZD7+lvf6Hirj69Ea50XlK+wXNkyVIgVTJDRA0CR0xessUg2MfBTLU WdCw== X-Forwarded-Encrypted: i=1; AL+hErHmDahqb6S28NTYISRDG8pw3pOItDJhlyPYWbvEb8b4YD2lgjnKMaVBJ+KX6yfWnS+7bh739B4ENqCBa5qJ@vger.kernel.org X-Gm-Message-State: APuU4Z/WaHq8QDKeGt2mHHvIiAEOK5FBLVLLQ/csiTK/3t0k6T0orpcq fjOf0z3Zhw7z7khYSxopDYQxKWIoL0k9cQMLcqSbuOcm+QD/GZ4V2NjX X-Gm-Gg: AZFdTZdlbZoj3GsbrlF2OLwAk1DTYp7Nz6gknAh4De5bidFOWhMNjzAwL8KY+yZ2Yrz rHqRSOhl6seWgHSPHmmKTTpVqoaVLaLlblele5eoFCZ4DZCpXEbaa24m9a7XKbg6UToyAQMP+is ZedSenm7d+OM0OxlL1D8p3fLM/osmjpXKcofqii++bfHw+Ozid3dr/HDz+h/psUraacmVjLcmBZ ucN12BnLntmsBOra/HnvhSq94977EhBwjOIiAaj6RttRRhaIVNEDevzLBuuhDPI9Z1TbMXgFx+f G+eMhC6uM4HIWW7NBa0glEiMzbwWagxf1+GdDF9FrAmONLy3oHrSwkx9XjGgnh5uV8sXvgym4TT cI2WfL9yxbG+SKrskuPvMB/p291VgvkznGwtaZN0joW2a0YXEjvJky1tfITPv0CEarSlpsdLq07 ZkO+NxmhqM5wq+adibAxIhEdYGhbtM4Y6JI8igWm6pq1++ufO91TUsD62fT6pV0Yqs+Os5wKb6t 14DmCMwMd6ERwhRbxEndmqa88h2/516Xo4f5g8BpL/NqqCTu4i/NsEK0av5vFNpb8bW7N/472Jh UDKjLfVoLDAlbxb8FzluhRTYipdFYPcjCxvsusF1hZBAUXVt/Ti16rPne8zA9LaR49BpPylkGEs BcSENBJ/oMwGrWTYNKx2RDYVa10ejuX1HvtOBzmqpER7wFJVKTcBFKx0= X-Received: by 2002:a05:6214:f05:b0:921:b8cb:b6b with SMTP id 6a1803df08f44-921b8cb0cf7mr228965306d6.51.1796332855756; Thu, 03 Dec 2026 13:20:55 -0800 (PST) Received: from FKXX2DL94F.bytedance.net ([71.18.96.12]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-921e05628bfsm4542286d6.13.2026.12.03.13.20.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Dec 2026 13:20:55 -0800 (PST) From: Yifan Feng To: Konstantin Komarov Cc: Christian Brauner , ntfs3@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Yifan Feng Subject: [PATCH] fs/ntfs3: keep the current mount options on remount Date: Thu, 3 Dec 2026 13:20:49 -0800 Message-Id: <20261203212049.31360-1-evanfengff@gmail.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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)