aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/inode.c
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@hammerspace.com>2021-07-10 18:07:14 -0400
committerTrond Myklebust <trond.myklebust@hammerspace.com>2021-10-03 20:49:05 -0400
commitca05cbae2a0468e5d78e9b4605936a8bf5da328b (patch)
treebd06e45fe70eb94249052670f024a9cec272ca8e /fs/nfs/inode.c
parentNFS: Label the dentry with a verifier in nfs_rmdir() and nfs_unlink() (diff)
downloadlinux-dev-ca05cbae2a0468e5d78e9b4605936a8bf5da328b.tar.xz
linux-dev-ca05cbae2a0468e5d78e9b4605936a8bf5da328b.zip
NFS: Fix up nfs_ctx_key_to_expire()
If the cached credential exists but doesn't have any expiration callback then exit early. Fix up atomicity issues when replacing the credential with a new one since the existing code could lead to refcount leaks. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Diffstat (limited to 'fs/nfs/inode.c')
-rw-r--r--fs/nfs/inode.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 853213b3a209..4f45281c47cf 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1024,7 +1024,7 @@ struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry,
ctx->cred = get_cred(filp->f_cred);
else
ctx->cred = get_current_cred();
- ctx->ll_cred = NULL;
+ rcu_assign_pointer(ctx->ll_cred, NULL);
ctx->state = NULL;
ctx->mode = f_mode;
ctx->flags = 0;
@@ -1063,7 +1063,7 @@ static void __put_nfs_open_context(struct nfs_open_context *ctx, int is_sync)
put_cred(ctx->cred);
dput(ctx->dentry);
nfs_sb_deactive(sb);
- put_rpccred(ctx->ll_cred);
+ put_rpccred(rcu_dereference_protected(ctx->ll_cred, 1));
kfree(ctx->mdsthreshold);
kfree_rcu(ctx, rcu_head);
}