nfsd: Ensure we check stateid validity in the seqid operation checks

After taking the stateid st_mutex, we want to know that the stateid
still represents valid state before performing any non-idempotent
actions.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
This commit is contained in:
Trond Myklebust 2017-11-03 08:00:15 -04:00 committed by J. Bruce Fields
parent beeca19cf1
commit 9271d7e509
1 changed files with 3 additions and 9 deletions

View File

@ -5234,15 +5234,9 @@ static __be32 nfs4_seqid_op_checks(struct nfsd4_compound_state *cstate, stateid_
status = nfsd4_check_seqid(cstate, sop, seqid); status = nfsd4_check_seqid(cstate, sop, seqid);
if (status) if (status)
return status; return status;
if (stp->st_stid.sc_type == NFS4_CLOSED_STID status = nfsd4_lock_ol_stateid(stp);
|| stp->st_stid.sc_type == NFS4_REVOKED_DELEG_STID) if (status != nfs_ok)
/* return status;
* "Closed" stateid's exist *only* to return
* nfserr_replay_me from the previous step, and
* revoked delegations are kept only for free_stateid.
*/
return nfserr_bad_stateid;
mutex_lock(&stp->st_mutex);
status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, nfsd4_has_session(cstate)); status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, nfsd4_has_session(cstate));
if (status == nfs_ok) if (status == nfs_ok)
status = nfs4_check_fh(current_fh, &stp->st_stid); status = nfs4_check_fh(current_fh, &stp->st_stid);