NFSD: detect mismatch of file handle and delegation stateid in OPEN op
Subsystems (2)
Dai Ngo
reviewerPATCH v2 1/1 NFSD: detect mismatch of file handle and delegation stateid in OPEN op
When the client sends an OPEN with claim type CLAIM_DELEG_CUR_FH or CLAIM_DELEGATION_CUR, the delegation stateid and the file handle must belongs to the same file, otherwise return NFS4ERR_INVAL.
Note that RFC8881, section 8.2.4, mandates the server to return NFS4ERR_BAD_STATEID if the selected table entry does not match the current filehandle. However returning NFS4ERR_BAD_STATEID in the OPEN causes the client to retry the operation and therefor get the client into a loop. To avoid this situation we return NFS4ERR_INVAL instead.
---
V1 -> V2: replace NFS4ERR_BAD_STATEID with NFS4ERR_INVAL and add
comment to explain the deviation from the spec.
fs/nfsd/nfs4state.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
fs/nfsd/nfs4state.c +10 -1
@@ -6320,7 +6320,16 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf goto out;if (dp &&nfsd4_is_deleg_cur (open) && (dp->dl_stid.sc_file != fp)) { - status = nfserr_bad_stateid; +/* +* RFC8881, section 8.2.4, mandates the server to return +* NFS4ERR_BAD_STATEID if the selected table entry does +* not match the current filehandle. +* However returning NFS4ERR_BAD_STATEID in the OPEN causes +* the client to retry the operation and therefor get the +* client into a loop. To avoid this situation we return +* NFS4ERR_INVAL instead. +*/ + status = nfserr_inval; goto out; } stp =nfsd4_find_and_lock_existing_open (fp, open);
Signature · 1 line
2.43.5
Quoted 3 lines · Dai Ngo
When the client sends an OPEN with claim type
CLAIM_DELEG_CUR_FHorCLAIM_DELEGATION_CUR, the delegation stateid and the file handle must belongs to the same file, otherwise returnNFS4ERR_INVAL.
s/belongs/belong
Quoted 29 lines
Note that RFC8881, section 8.2.4, mandates the server to return
NFS4ERR_BAD_STATEIDif the selected table entry does not match the current filehandle. However returningNFS4ERR_BAD_STATEIDin the OPEN causes the client to retry the operation and therefor get the client into a loop. To avoid this situation we returnNFS4ERR_INVALinstead.Signed-off-by Dai Ngo <[email protected]>Reviewed-by Jeff Layton <[email protected]>---
V1 -> V2: replaceNFS4ERR_BAD_STATEIDwithNFS4ERR_INVALand add
comment to explain the deviation from the spec.fs/nfsd/nfs4state.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)fs/nfsd/nfs4state.c +3
-1@@ -6320,7 +6320,16 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf goto out;if (dp &&nfsd4_is_deleg_cur (open) && (dp->dl_stid.sc_file != fp)) { - status = nfserr_bad_stateid; +/* +* RFC8881, section 8.2.4, mandates the server to return +* NFS4ERR_BAD_STATEID if the selected table entry does
fs/nfsd/nfs4state.c nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf · line 6335
Quoted 10 lines
fs/nfsd/nfs4state.c +7
-0+* not match the current filehandle. +* However returning NFS4ERR_BAD_STATEID in the OPEN causes +* the client to retry the operation and therefor get the +* client into a loop. To avoid this situation we return +* NFS4ERR_INVAL instead. +*/ + status = nfserr_inval; goto out; } stp =nfsd4_find_and_lock_existing_open (fp, open);
Looks correct, but needs some clean up:
- squash V1 and V2 together
- Add Reported-by: Petro Pavlov <[email protected]>
- Add Fixes: c44c5eeb2c02 ("[PATCH] nfsd4: add open state code forCLAIM_DELEGATE_CUR")
Thanks!
Signature · 1 line
Chuck Lever