]> git.dujemihanovic.xyz Git - linux.git/commitdiff
nfsd: don't assume copy notify when preprocessing the stateid
authorSagi Grimberg <sagi@grimberg.me>
Wed, 24 Jul 2024 17:01:37 +0000 (10:01 -0700)
committerChuck Lever <chuck.lever@oracle.com>
Fri, 20 Sep 2024 23:31:03 +0000 (19:31 -0400)
Move the stateid handling to nfsd4_copy_notify.
If nfs4_preprocess_stateid_op did not produce an output stateid, error out.

Copy notify specifically does not permit the use of special stateids,
so enforce that outside generic stateid pre-processing.

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Olga Kornievskaia <aglo@umich.edu>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs4proc.c
fs/nfsd/nfs4state.c

index 2e39cf2e502a336fb77c42b4aee5420c723b5429..911134ed5a0e84f430016a5470038eb2d1f98c24 100644 (file)
@@ -1942,7 +1942,7 @@ nfsd4_copy_notify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
        struct nfsd4_copy_notify *cn = &u->copy_notify;
        __be32 status;
        struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
-       struct nfs4_stid *stid;
+       struct nfs4_stid *stid = NULL;
        struct nfs4_cpntf_state *cps;
        struct nfs4_client *clp = cstate->clp;
 
@@ -1951,6 +1951,8 @@ nfsd4_copy_notify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
                                        &stid);
        if (status)
                return status;
+       if (!stid)
+               return nfserr_bad_stateid;
 
        cn->cpn_lease_time.tv_sec = nn->nfsd4_lease;
        cn->cpn_lease_time.tv_nsec = 0;
index 5c48915ff61cd82ad3681391d05f20a8ae443813..8fddc2d1c80eadd2261bfce8e80c410f1a14d8e2 100644 (file)
@@ -7022,11 +7022,7 @@ nfs4_preprocess_stateid_op(struct svc_rqst *rqstp,
                *nfp = NULL;
 
        if (ZERO_STATEID(stateid) || ONE_STATEID(stateid)) {
-               if (cstid)
-                       status = nfserr_bad_stateid;
-               else
-                       status = check_special_stateids(net, fhp, stateid,
-                                                                       flags);
+               status = check_special_stateids(net, fhp, stateid, flags);
                goto done;
        }