Skip to content

Commit 0418dae

Browse files
committed
NFSv4: Fail the truncate() if the lock/open stateid is invalid
If the open stateid could not be recovered, or the file locks were lost, then we should fail the truncate() operation altogether. Reported-by: Andy Adamson <andros@netapp.com> Link: http://lkml.kernel.org/r/1393954269-3974-1-git-send-email-andros@netapp.com Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
1 parent 869a9d3 commit 0418dae

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

fs/nfs/nfs4proc.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,13 +2398,16 @@ static int _nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred,
23982398

23992399
if (nfs4_copy_delegation_stateid(&arg.stateid, inode, fmode)) {
24002400
/* Use that stateid */
2401-
} else if (truncate && state != NULL && nfs4_valid_open_stateid(state)) {
2401+
} else if (truncate && state != NULL) {
24022402
struct nfs_lockowner lockowner = {
24032403
.l_owner = current->files,
24042404
.l_pid = current->tgid,
24052405
};
2406-
nfs4_select_rw_stateid(&arg.stateid, state, FMODE_WRITE,
2407-
&lockowner);
2406+
if (!nfs4_valid_open_stateid(state))
2407+
return -EBADF;
2408+
if (nfs4_select_rw_stateid(&arg.stateid, state, FMODE_WRITE,
2409+
&lockowner) == -EIO)
2410+
return -EBADF;
24082411
} else
24092412
nfs4_stateid_copy(&arg.stateid, &zero_stateid);
24102413

0 commit comments

Comments
 (0)