Skip to content

Commit b0ea262

Browse files
committed
Merge tag 'nfs-for-5.6-3' of git://git.linux-nfs.org/projects/anna/linux-nfs
Pull NFS client bugfixes from Anna Schumaker: "These are mostly fscontext fixes, but there is also one that fixes collisions seen in fscache: - Ensure the fs_context has the correct fs_type when mounting and submounting - Fix leaking of ctx->nfs_server.hostname - Add minor version to fscache key to prevent collisions" * tag 'nfs-for-5.6-3' of git://git.linux-nfs.org/projects/anna/linux-nfs: nfs: add minor version to nfs_server_key for fscache NFS: Fix leak of ctx->nfs_server.hostname NFS: Don't hard-code the fs_type when submounting NFS: Ensure the fs_context has the correct fs_type before mounting
2 parents 7e6d869 + 55dee1b commit b0ea262

File tree

5 files changed

+13
-2
lines changed

5 files changed

+13
-2
lines changed

fs/nfs/client.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_init)
153153
if ((clp = kzalloc(sizeof(*clp), GFP_KERNEL)) == NULL)
154154
goto error_0;
155155

156+
clp->cl_minorversion = cl_init->minorversion;
156157
clp->cl_nfs_mod = cl_init->nfs_mod;
157158
if (!try_module_get(clp->cl_nfs_mod->owner))
158159
goto error_dealloc;

fs/nfs/fs_context.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,8 @@ static int nfs_parse_source(struct fs_context *fc,
832832
if (len > maxnamlen)
833833
goto out_hostname;
834834

835+
kfree(ctx->nfs_server.hostname);
836+
835837
/* N.B. caller will free nfs_server.hostname in all cases */
836838
ctx->nfs_server.hostname = kmemdup_nul(dev_name, len, GFP_KERNEL);
837839
if (!ctx->nfs_server.hostname)
@@ -1240,6 +1242,13 @@ static int nfs_fs_context_validate(struct fs_context *fc)
12401242
}
12411243
ctx->nfs_mod = nfs_mod;
12421244
}
1245+
1246+
/* Ensure the filesystem context has the correct fs_type */
1247+
if (fc->fs_type != ctx->nfs_mod->nfs_fs) {
1248+
module_put(fc->fs_type->owner);
1249+
__module_get(ctx->nfs_mod->nfs_fs->owner);
1250+
fc->fs_type = ctx->nfs_mod->nfs_fs;
1251+
}
12431252
return 0;
12441253

12451254
out_no_device_name:

fs/nfs/fscache.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ static DEFINE_SPINLOCK(nfs_fscache_keys_lock);
3131
struct nfs_server_key {
3232
struct {
3333
uint16_t nfsversion; /* NFS protocol version */
34+
uint32_t minorversion; /* NFSv4 minor version */
3435
uint16_t family; /* address family */
3536
__be16 port; /* IP port */
3637
} hdr;
@@ -55,6 +56,7 @@ void nfs_fscache_get_client_cookie(struct nfs_client *clp)
5556

5657
memset(&key, 0, sizeof(key));
5758
key.hdr.nfsversion = clp->rpc_ops->version;
59+
key.hdr.minorversion = clp->cl_minorversion;
5860
key.hdr.family = clp->cl_addr.ss_family;
5961

6062
switch (clp->cl_addr.ss_family) {

fs/nfs/namespace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ struct vfsmount *nfs_d_automount(struct path *path)
153153
/* Open a new filesystem context, transferring parameters from the
154154
* parent superblock, including the network namespace.
155155
*/
156-
fc = fs_context_for_submount(&nfs_fs_type, path->dentry);
156+
fc = fs_context_for_submount(path->mnt->mnt_sb->s_type, path->dentry);
157157
if (IS_ERR(fc))
158158
return ERR_CAST(fc);
159159

fs/nfs/nfs4client.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init)
216216
INIT_LIST_HEAD(&clp->cl_ds_clients);
217217
rpc_init_wait_queue(&clp->cl_rpcwaitq, "NFS client");
218218
clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED;
219-
clp->cl_minorversion = cl_init->minorversion;
220219
clp->cl_mvops = nfs_v4_minor_ops[cl_init->minorversion];
221220
clp->cl_mig_gen = 1;
222221
#if IS_ENABLED(CONFIG_NFS_V4_1)

0 commit comments

Comments
 (0)