Skip to content

Commit 1cef218

Browse files
scottmayhewamschuma-ntap
authored andcommitted
NFS: Ensure the fs_context has the correct fs_type before mounting
This is necessary because unless userspace explicitly requests fstype "nfs4" (either via "mount -t nfs4" or by calling the "mount.nfs4" helper directly), the fstype will default to "nfs". This was fine on older kernels because the super_block->s_type was set via mount_info->nfs_mod->nfs_fs, which was set when parsing the mount options and subsequently passed in the "type" argument of sget(). After commit f2aedb7 ("NFS: Add fs_context support."), sget_fc(), which has no "type" argument, is called instead. In sget_fc(), the super_block->s_type is set via fs_context->fs_type, which was set when the filesystem context was initially created. Reported-by: Patrick Steinhardt <ps@pks.im> Fixes: f2aedb7 ("NFS: Add fs_context support.") Signed-off-by: Scott Mayhew <smayhew@redhat.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent 5d63944 commit 1cef218

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

fs/nfs/fs_context.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,13 @@ static int nfs_fs_context_validate(struct fs_context *fc)
12401240
}
12411241
ctx->nfs_mod = nfs_mod;
12421242
}
1243+
1244+
/* Ensure the filesystem context has the correct fs_type */
1245+
if (fc->fs_type != ctx->nfs_mod->nfs_fs) {
1246+
module_put(fc->fs_type->owner);
1247+
__module_get(ctx->nfs_mod->nfs_fs->owner);
1248+
fc->fs_type = ctx->nfs_mod->nfs_fs;
1249+
}
12431250
return 0;
12441251

12451252
out_no_device_name:

0 commit comments

Comments
 (0)