Skip to content

Commit 5d63944

Browse files
trondmyamschuma-ntap
authored andcommitted
NFSv4: Ensure the delegation cred is pinned when we call delegreturn
Ensure we don't release the delegation cred during the call to nfs4_proc_delegreturn(). Fixes: ee05f45 ("NFSv4: Fix races between open and delegreturn") Signed-off-by: Trond Myklebust <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 8c75593 commit 5d63944

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

fs/nfs/delegation.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,18 @@ void nfs_inode_reclaim_delegation(struct inode *inode, const struct cred *cred,
255255

256256
static int nfs_do_return_delegation(struct inode *inode, struct nfs_delegation *delegation, int issync)
257257
{
258+
const struct cred *cred;
258259
int res = 0;
259260

260-
if (!test_bit(NFS_DELEGATION_REVOKED, &delegation->flags))
261-
res = nfs4_proc_delegreturn(inode,
262-
delegation->cred,
261+
if (!test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) {
262+
spin_lock(&delegation->lock);
263+
cred = get_cred(delegation->cred);
264+
spin_unlock(&delegation->lock);
265+
res = nfs4_proc_delegreturn(inode, cred,
263266
&delegation->stateid,
264267
issync);
268+
put_cred(cred);
269+
}
265270
return res;
266271
}
267272

0 commit comments

Comments
 (0)