Skip to content

Commit 4d8948c

Browse files
author
Trond Myklebust
committed
NFS/pnfs: Fix a credential use-after-free issue in pnfs_roc()
If the credential returned by pnfs_prepare_layoutreturn() does not match the credential of the RPC call, then we do end up calling pnfs_send_layoutreturn() with that credential, so don't free it! Fixes: 44ea8df ("NFS/pnfs: Reference the layout cred in pnfs_prepare_layoutreturn()") Signed-off-by: Trond Myklebust <[email protected]>
1 parent 7bcc105 commit 4d8948c

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

fs/nfs/pnfs.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,18 +1458,15 @@ bool pnfs_roc(struct inode *ino,
14581458
/* lo ref dropped in pnfs_roc_release() */
14591459
layoutreturn = pnfs_prepare_layoutreturn(lo, &stateid, &lc_cred, &iomode);
14601460
/* If the creds don't match, we can't compound the layoutreturn */
1461-
if (!layoutreturn)
1461+
if (!layoutreturn || cred_fscmp(cred, lc_cred) != 0)
14621462
goto out_noroc;
1463-
if (cred_fscmp(cred, lc_cred) != 0)
1464-
goto out_noroc_put_cred;
14651463

14661464
roc = layoutreturn;
14671465
pnfs_init_layoutreturn_args(args, lo, &stateid, iomode);
14681466
res->lrs_present = 0;
14691467
layoutreturn = false;
1470-
1471-
out_noroc_put_cred:
14721468
put_cred(lc_cred);
1469+
14731470
out_noroc:
14741471
spin_unlock(&ino->i_lock);
14751472
rcu_read_unlock();

0 commit comments

Comments
 (0)