diff options
author | Trond Myklebust <trond.myklebust@hammerspace.com> | 2021-07-10 18:07:14 -0400 |
---|---|---|
committer | Trond Myklebust <trond.myklebust@hammerspace.com> | 2021-10-03 20:49:05 -0400 |
commit | ca05cbae2a0468e5d78e9b4605936a8bf5da328b (patch) | |
tree | bd06e45fe70eb94249052670f024a9cec272ca8e /fs/nfs/inode.c | |
parent | 9019fb391de02cbff422090768b73afe9f6174df (diff) | |
download | linux-ca05cbae2a0468e5d78e9b4605936a8bf5da328b.tar.bz2 |
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.c | 4 |
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); } |