summaryrefslogtreecommitdiffstats
path: root/net/sunrpc/auth.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2018-12-02 19:30:30 -0500
committerAnna Schumaker <Anna.Schumaker@Netapp.com>2018-12-19 13:52:44 -0500
commit97f68c6b02e0225b38d327103c59cfe2ab5ecda7 (patch)
tree87d434407fef925b2d3fefad5dd759d33b9eb31a /net/sunrpc/auth.c
parentf06bc03339ad4c1baa964a5f0606247ac1c3c50b (diff)
SUNRPC: add 'struct cred *' to auth_cred and rpc_cred
The SUNRPC credential framework was put together before Linux has 'struct cred'. Now that we have it, it makes sense to use it. This first step just includes a suitable 'struct cred *' pointer in every 'struct auth_cred' and almost every 'struct rpc_cred'. The rpc_cred used for auth_null has a NULL 'struct cred *' as nothing else really makes sense. For rpc_cred, the pointer is reference counted. For auth_cred it isn't. struct auth_cred are either allocated on the stack, in which case the thread owns a reference to the auth, or are part of 'struct generic_cred' in which case gc_base owns the reference, and "acred" shares it. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Diffstat (limited to 'net/sunrpc/auth.c')
-rw-r--r--net/sunrpc/auth.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index ad8ead738981..a7e08e44f92b 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -659,6 +659,7 @@ rpcauth_lookupcred(struct rpc_auth *auth, int flags)
659 acred.uid = cred->fsuid; 659 acred.uid = cred->fsuid;
660 acred.gid = cred->fsgid; 660 acred.gid = cred->fsgid;
661 acred.group_info = cred->group_info; 661 acred.group_info = cred->group_info;
662 acred.cred = cred;
662 ret = auth->au_ops->lookup_cred(auth, &acred, flags); 663 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
663 return ret; 664 return ret;
664} 665}
@@ -674,6 +675,7 @@ rpcauth_init_cred(struct rpc_cred *cred, const struct auth_cred *acred,
674 cred->cr_auth = auth; 675 cred->cr_auth = auth;
675 cred->cr_ops = ops; 676 cred->cr_ops = ops;
676 cred->cr_expire = jiffies; 677 cred->cr_expire = jiffies;
678 cred->cr_cred = get_cred(acred->cred);
677 cred->cr_uid = acred->uid; 679 cred->cr_uid = acred->uid;
678} 680}
679EXPORT_SYMBOL_GPL(rpcauth_init_cred); 681EXPORT_SYMBOL_GPL(rpcauth_init_cred);
@@ -694,11 +696,15 @@ rpcauth_bind_root_cred(struct rpc_task *task, int lookupflags)
694 struct auth_cred acred = { 696 struct auth_cred acred = {
695 .uid = GLOBAL_ROOT_UID, 697 .uid = GLOBAL_ROOT_UID,
696 .gid = GLOBAL_ROOT_GID, 698 .gid = GLOBAL_ROOT_GID,
699 .cred = get_task_cred(&init_task),
697 }; 700 };
701 struct rpc_cred *ret;
698 702
699 dprintk("RPC: %5u looking up %s cred\n", 703 dprintk("RPC: %5u looking up %s cred\n",
700 task->tk_pid, task->tk_client->cl_auth->au_ops->au_name); 704 task->tk_pid, task->tk_client->cl_auth->au_ops->au_name);
701 return auth->au_ops->lookup_cred(auth, &acred, lookupflags); 705 ret = auth->au_ops->lookup_cred(auth, &acred, lookupflags);
706 put_cred(acred.cred);
707 return ret;
702} 708}
703 709
704static struct rpc_cred * 710static struct rpc_cred *