]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
lockd: Store the lockd client credential in struct nlm_host
authorTrond Myklebust <trondmy@gmail.com>
Wed, 24 Apr 2019 21:46:50 +0000 (17:46 -0400)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Fri, 26 Apr 2019 21:51:23 +0000 (17:51 -0400)
When we create a new lockd client, we want to be able to pass the
correct credential of the process that created the struct nlm_host.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
fs/lockd/clntlock.c
fs/lockd/host.c
include/linux/lockd/bind.h
include/linux/lockd/lockd.h

index c2a128678e6e596ffebdc43db0989bbbd83ee1f4..70f520b41a195da5c0720ab8976be49e4ea532cd 100644 (file)
@@ -63,7 +63,7 @@ struct nlm_host *nlmclnt_init(const struct nlmclnt_initdata *nlm_init)
        host = nlmclnt_lookup_host(nlm_init->address, nlm_init->addrlen,
                                   nlm_init->protocol, nlm_version,
                                   nlm_init->hostname, nlm_init->noresvport,
-                                  nlm_init->net);
+                                  nlm_init->net, nlm_init->cred);
        if (host == NULL)
                goto out_nohost;
        if (host->h_rpcclnt == NULL && nlm_bind_host(host) == NULL)
index d46081123f7cc64f8c8cda0e0f1b17c79ce37457..7d46fafdbbe5a6fb219941e16f9335910fe82225 100644 (file)
@@ -60,6 +60,7 @@ struct nlm_lookup_host_info {
        const size_t            hostname_len;   /* it's length */
        const int               noresvport;     /* use non-priv port */
        struct net              *net;           /* network namespace to bind */
+       const struct cred       *cred;
 };
 
 /*
@@ -162,6 +163,7 @@ static struct nlm_host *nlm_alloc_host(struct nlm_lookup_host_info *ni,
        host->h_nsmhandle  = nsm;
        host->h_addrbuf    = nsm->sm_addrbuf;
        host->net          = ni->net;
+       host->h_cred       = get_cred(ni->cred),
        strlcpy(host->nodename, utsname()->nodename, sizeof(host->nodename));
 
 out:
@@ -188,6 +190,7 @@ static void nlm_destroy_host_locked(struct nlm_host *host)
        clnt = host->h_rpcclnt;
        if (clnt != NULL)
                rpc_shutdown_client(clnt);
+       put_cred(host->h_cred);
        kfree(host);
 
        ln->nrhosts--;
@@ -202,6 +205,8 @@ static void nlm_destroy_host_locked(struct nlm_host *host)
  * @version: NLM protocol version
  * @hostname: '\0'-terminated hostname of server
  * @noresvport: 1 if non-privileged port should be used
+ * @net: pointer to net namespace
+ * @cred: pointer to cred
  *
  * Returns an nlm_host structure that matches the passed-in
  * [server address, transport protocol, NLM version, server hostname].
@@ -214,7 +219,8 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
                                     const u32 version,
                                     const char *hostname,
                                     int noresvport,
-                                    struct net *net)
+                                    struct net *net,
+                                    const struct cred *cred)
 {
        struct nlm_lookup_host_info ni = {
                .server         = 0,
@@ -226,6 +232,7 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
                .hostname_len   = strlen(hostname),
                .noresvport     = noresvport,
                .net            = net,
+               .cred           = cred,
        };
        struct hlist_head *chain;
        struct nlm_host *host;
@@ -458,7 +465,7 @@ nlm_bind_host(struct nlm_host *host)
                        .authflavor     = RPC_AUTH_UNIX,
                        .flags          = (RPC_CLNT_CREATE_NOPING |
                                           RPC_CLNT_CREATE_AUTOBIND),
-                       .cred           = current_cred(),
+                       .cred           = host->h_cred,
                };
 
                /*
index 053a4ef3d43175df329ab8b5e2758ce67c50cf7d..8c0cf1059443afe0f48690b41895f2ae746b0fe1 100644 (file)
@@ -46,6 +46,7 @@ struct nlmclnt_initdata {
        int                     noresvport;
        struct net              *net;
        const struct nlmclnt_operations *nlmclnt_ops;
+       const struct cred       *cred;
 };
 
 /*
index b065ef4067701b6892c9f09b03094677d941b506..c9b422dde542204bfb902593622de0cfafae6ede 100644 (file)
@@ -70,6 +70,7 @@ struct nlm_host {
        struct nsm_handle       *h_nsmhandle;   /* NSM status handle */
        char                    *h_addrbuf;     /* address eyecatcher */
        struct net              *net;           /* host net */
+       const struct cred       *h_cred;
        char                    nodename[UNX_MAXNODENAME + 1];
        const struct nlmclnt_operations *h_nlmclnt_ops; /* Callback ops for NLM users */
 };
@@ -229,7 +230,8 @@ struct nlm_host  *nlmclnt_lookup_host(const struct sockaddr *sap,
                                        const u32 version,
                                        const char *hostname,
                                        int noresvport,
-                                       struct net *net);
+                                       struct net *net,
+                                       const struct cred *cred);
 void             nlmclnt_release_host(struct nlm_host *);
 struct nlm_host  *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
                                        const char *hostname,