summaryrefslogtreecommitdiffstats
path: root/fs/nfs/inode.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2018-12-02 19:30:31 -0500
committerAnna Schumaker <Anna.Schumaker@Netapp.com>2018-12-19 13:52:46 -0500
commita52458b48af142bcc2b72fe810c0db20cfae7fdd (patch)
treecb77d59d5fdf3d50e69500b8cc7cba1c7199272f /fs/nfs/inode.c
parent684f39b4cf5186bb0660e686f94296688b24fb32 (diff)
NFS/NFSD/SUNRPC: replace generic creds with 'struct cred'.
SUNRPC has two sorts of credentials, both of which appear as "struct rpc_cred". There are "generic credentials" which are supplied by clients such as NFS and passed in 'struct rpc_message' to indicate which user should be used to authorize the request, and there are low-level credentials such as AUTH_NULL, AUTH_UNIX, AUTH_GSS which describe the credential to be sent over the wires. This patch replaces all the generic credentials by 'struct cred' pointers - the credential structure used throughout Linux. For machine credentials, there is a special 'struct cred *' pointer which is statically allocated and recognized where needed as having a special meaning. A look-up of a low-level cred will map this to a machine credential. Signed-off-by: NeilBrown <neilb@suse.com> Acked-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Diffstat (limited to 'fs/nfs/inode.c')
-rw-r--r--fs/nfs/inode.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index aea015743172..094775ea0781 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -950,13 +950,11 @@ struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry,
950 struct file *filp) 950 struct file *filp)
951{ 951{
952 struct nfs_open_context *ctx; 952 struct nfs_open_context *ctx;
953 struct rpc_cred *cred = rpc_lookup_cred(); 953 const struct cred *cred = get_current_cred();
954 if (IS_ERR(cred))
955 return ERR_CAST(cred);
956 954
957 ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); 955 ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
958 if (!ctx) { 956 if (!ctx) {
959 put_rpccred(cred); 957 put_cred(cred);
960 return ERR_PTR(-ENOMEM); 958 return ERR_PTR(-ENOMEM);
961 } 959 }
962 nfs_sb_active(dentry->d_sb); 960 nfs_sb_active(dentry->d_sb);
@@ -998,8 +996,7 @@ static void __put_nfs_open_context(struct nfs_open_context *ctx, int is_sync)
998 } 996 }
999 if (inode != NULL) 997 if (inode != NULL)
1000 NFS_PROTO(inode)->close_context(ctx, is_sync); 998 NFS_PROTO(inode)->close_context(ctx, is_sync);
1001 if (ctx->cred != NULL) 999 put_cred(ctx->cred);
1002 put_rpccred(ctx->cred);
1003 dput(ctx->dentry); 1000 dput(ctx->dentry);
1004 nfs_sb_deactive(sb); 1001 nfs_sb_deactive(sb);
1005 put_rpccred(ctx->ll_cred); 1002 put_rpccred(ctx->ll_cred);
@@ -1044,7 +1041,7 @@ EXPORT_SYMBOL_GPL(nfs_file_set_open_context);
1044/* 1041/*
1045 * Given an inode, search for an open context with the desired characteristics 1042 * Given an inode, search for an open context with the desired characteristics
1046 */ 1043 */
1047struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, fmode_t mode) 1044struct nfs_open_context *nfs_find_open_context(struct inode *inode, const struct cred *cred, fmode_t mode)
1048{ 1045{
1049 struct nfs_inode *nfsi = NFS_I(inode); 1046 struct nfs_inode *nfsi = NFS_I(inode);
1050 struct nfs_open_context *pos, *ctx = NULL; 1047 struct nfs_open_context *pos, *ctx = NULL;