NFS: Store the credential of the mount process in the nfs_server
authorTrond Myklebust <trondmy@gmail.com>
Wed, 24 Apr 2019 21:46:43 +0000 (17:46 -0400)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Fri, 26 Apr 2019 20:11:54 +0000 (16:11 -0400)
Store the credential of the mount process so that we can determine
information such as the user namespace.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
fs/nfs/client.c
fs/nfs/internal.h
fs/nfs/nfs3client.c
fs/nfs/nfs4client.c
include/linux/nfs_fs_sb.h

index a843cf3f63400db1a486740b9260d2f561734d95..e3baa9f1da76086a8c4a3d3f31145a8f91dbc55a 100644 (file)
@@ -500,7 +500,7 @@ int nfs_create_rpc_client(struct nfs_client *clp,
                .program        = &nfs_program,
                .version        = clp->rpc_ops->version,
                .authflavor     = flavor,
-               .cred           = current_cred(),
+               .cred           = cl_init->cred,
        };
 
        if (test_bit(NFS_CS_DISCRTRY, &clp->cl_flags))
@@ -655,6 +655,7 @@ static int nfs_init_server(struct nfs_server *server,
                .proto = data->nfs_server.protocol,
                .net = data->net,
                .timeparms = &timeparms,
+               .cred = server->cred,
        };
        struct nfs_client *clp;
        int error;
@@ -923,6 +924,7 @@ void nfs_free_server(struct nfs_server *server)
        ida_destroy(&server->lockowner_id);
        ida_destroy(&server->openowner_id);
        nfs_free_iostats(server->io_stats);
+       put_cred(server->cred);
        kfree(server);
        nfs_release_automount_timer();
 }
@@ -943,6 +945,8 @@ struct nfs_server *nfs_create_server(struct nfs_mount_info *mount_info,
        if (!server)
                return ERR_PTR(-ENOMEM);
 
+       server->cred = get_cred(current_cred());
+
        error = -ENOMEM;
        fattr = nfs_alloc_fattr();
        if (fattr == NULL)
@@ -1009,6 +1013,8 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source,
        if (!server)
                return ERR_PTR(-ENOMEM);
 
+       server->cred = get_cred(source->cred);
+
        error = -ENOMEM;
        fattr_fsinfo = nfs_alloc_fattr();
        if (fattr_fsinfo == NULL)
index 196534634c3a1d8686c75ad756db0f84f5895233..22232e76df4704ee8a0ce2cba4eef651ee179133 100644 (file)
@@ -84,6 +84,7 @@ struct nfs_client_initdata {
        u32 minorversion;
        struct net *net;
        const struct rpc_timeout *timeparms;
+       const struct cred *cred;
 };
 
 /*
index 7879f2a0fcfdc0248b203fab5a0d305c84588775..1afdb0f7473fa0d35740f4a7b1c7480169fd5a21 100644 (file)
@@ -91,6 +91,7 @@ struct nfs_client *nfs3_set_ds_client(struct nfs_server *mds_srv,
                .proto = ds_proto,
                .net = mds_clp->cl_net,
                .timeparms = &ds_timeout,
+               .cred = mds_srv->cred,
        };
        struct nfs_client *clp;
        char buf[INET6_ADDRSTRLEN + 1];
index 1339ede979afd5e3dfcb0d3a371dea41d01696b4..3ce246346f022a0a26da423fec916b237abd0c29 100644 (file)
@@ -870,6 +870,7 @@ static int nfs4_set_client(struct nfs_server *server,
                .minorversion = minorversion,
                .net = net,
                .timeparms = timeparms,
+               .cred = server->cred,
        };
        struct nfs_client *clp;
 
@@ -931,6 +932,7 @@ struct nfs_client *nfs4_set_ds_client(struct nfs_server *mds_srv,
                .minorversion = minor_version,
                .net = mds_clp->cl_net,
                .timeparms = &ds_timeout,
+               .cred = mds_srv->cred,
        };
        char buf[INET6_ADDRSTRLEN + 1];
 
@@ -1107,6 +1109,8 @@ struct nfs_server *nfs4_create_server(struct nfs_mount_info *mount_info,
        if (!server)
                return ERR_PTR(-ENOMEM);
 
+       server->cred = get_cred(current_cred());
+
        auth_probe = mount_info->parsed->auth_info.flavor_len < 1;
 
        /* set up the general RPC client */
@@ -1143,6 +1147,8 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data,
        parent_server = NFS_SB(data->sb);
        parent_client = parent_server->nfs_client;
 
+       server->cred = get_cred(parent_server->cred);
+
        /* Initialise the client representation from the parent server */
        nfs_server_copy_userdata(server, parent_server);
 
index 0fbc5d3c5e53658d01e2b160494fcbd72ea91ca2..1e78032a174bafc366ca4b9344cf298a69ddd70e 100644 (file)
@@ -241,6 +241,9 @@ struct nfs_server {
 
        /* XDR related information */
        unsigned int            read_hdrsize;
+
+       /* User namespace info */
+       const struct cred       *cred;
 };
 
 /* Server capabilities */