Skip to content

Commit 074b07d

Browse files
J. Bruce Fieldschucklever
authored andcommitted
nfsd: fix crash on COPY_NOTIFY with special stateid
RTM says "If the special ONE stateid is passed to nfs4_preprocess_stateid_op(), it returns status=0 but does not set *cstid. nfsd4_copy_notify() depends on stid being set if status=0, and thus can crash if the client sends the right COPY_NOTIFY RPC." RFC 7862 says "The cna_src_stateid MUST refer to either open or locking states provided earlier by the server. If it is invalid, then the operation MUST fail." The RFC doesn't specify an error, and the choice doesn't matter much as this is clearly illegal client behavior, but bad_stateid seems reasonable. Simplest is just to guarantee that nfs4_preprocess_stateid_op, called with non-NULL cstid, errors out if it can't return a stateid. Reported-by: rtm@csail.mit.edu Fixes: 624322f ("NFSD add COPY_NOTIFY operation") Signed-off-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Reviewed-by: Olga Kornievskaia <kolga@netapp.com> Tested-by: Olga Kornievskaia <kolga@netapp.com>
1 parent 7f4f5d7 commit 074b07d

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

fs/nfsd/nfs4state.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6058,7 +6058,11 @@ nfs4_preprocess_stateid_op(struct svc_rqst *rqstp,
60586058
*nfp = NULL;
60596059

60606060
if (ZERO_STATEID(stateid) || ONE_STATEID(stateid)) {
6061-
status = check_special_stateids(net, fhp, stateid, flags);
6061+
if (cstid)
6062+
status = nfserr_bad_stateid;
6063+
else
6064+
status = check_special_stateids(net, fhp, stateid,
6065+
flags);
60626066
goto done;
60636067
}
60646068

0 commit comments

Comments
 (0)