| From e3ed690259226de56ff2947b7d734747a16548dc Mon Sep 17 00:00:00 2001 |
| From: Sasha Levin <sashal@kernel.org> |
| Date: Fri, 28 Nov 2025 17:51:10 +0800 |
| Subject: exfat: fix remount failure in different process environments |
| |
| From: Yuezhang Mo <Yuezhang.Mo@sony.com> |
| |
| [ Upstream commit 51fc7b4ce10ccab8ea5e4876bcdc42cf5202a0ef ] |
| |
| The kernel test robot reported that the exFAT remount operation |
| failed. The reason for the failure was that the process's umask |
| is different between mount and remount, causing fs_fmask and |
| fs_dmask are changed. |
| |
| Potentially, both gid and uid may also be changed. Therefore, when |
| initializing fs_context for remount, inherit these mount options |
| from the options used during mount. |
| |
| Reported-by: kernel test robot <oliver.sang@intel.com> |
| Closes: https://lore.kernel.org/oe-lkp/202511251637.81670f5c-lkp@intel.com |
| Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com> |
| Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> |
| Signed-off-by: Sasha Levin <sashal@kernel.org> |
| --- |
| fs/exfat/super.c | 19 +++++++++++++++---- |
| 1 file changed, 15 insertions(+), 4 deletions(-) |
| |
| diff --git a/fs/exfat/super.c b/fs/exfat/super.c |
| index 816ba7e1607f..39e999c0de75 100644 |
| --- a/fs/exfat/super.c |
| +++ b/fs/exfat/super.c |
| @@ -758,10 +758,21 @@ static int exfat_init_fs_context(struct fs_context *fc) |
| ratelimit_state_init(&sbi->ratelimit, DEFAULT_RATELIMIT_INTERVAL, |
| DEFAULT_RATELIMIT_BURST); |
| |
| - sbi->options.fs_uid = current_uid(); |
| - sbi->options.fs_gid = current_gid(); |
| - sbi->options.fs_fmask = current->fs->umask; |
| - sbi->options.fs_dmask = current->fs->umask; |
| + if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE && fc->root) { |
| + struct super_block *sb = fc->root->d_sb; |
| + struct exfat_mount_options *cur_opts = &EXFAT_SB(sb)->options; |
| + |
| + sbi->options.fs_uid = cur_opts->fs_uid; |
| + sbi->options.fs_gid = cur_opts->fs_gid; |
| + sbi->options.fs_fmask = cur_opts->fs_fmask; |
| + sbi->options.fs_dmask = cur_opts->fs_dmask; |
| + } else { |
| + sbi->options.fs_uid = current_uid(); |
| + sbi->options.fs_gid = current_gid(); |
| + sbi->options.fs_fmask = current->fs->umask; |
| + sbi->options.fs_dmask = current->fs->umask; |
| + } |
| + |
| sbi->options.allow_utime = -1; |
| sbi->options.iocharset = exfat_default_iocharset; |
| sbi->options.errors = EXFAT_ERRORS_RO; |
| -- |
| 2.51.0 |
| |