Commit 80fc8f6a authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Zefan Li

nfsd: fix the check for confirmed openowner in nfs4_preprocess_stateid_op

commit ebe9cb3b upstream.

If we find a non-confirmed openowner we jump to exit the function, but do
not set an error value.  Fix this by factoring out a helper to do the
check and properly set the error from nfsd4_validate_stateid.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
[lizf: adjust the changes for nfsd4_validate_stateid()]
Signed-off-by: default avatarZefan Li <lizefan@huawei.com>
parent 9f0a120b
...@@ -3364,10 +3364,17 @@ static int check_stateid_generation(stateid_t *in, stateid_t *ref, bool has_sess ...@@ -3364,10 +3364,17 @@ static int check_stateid_generation(stateid_t *in, stateid_t *ref, bool has_sess
return nfserr_old_stateid; return nfserr_old_stateid;
} }
static __be32 nfsd4_check_openowner_confirmed(struct nfs4_ol_stateid *ols)
{
if (ols->st_stateowner->so_is_open_owner &&
!(openowner(ols->st_stateowner)->oo_flags & NFS4_OO_CONFIRMED))
return nfserr_bad_stateid;
return nfs_ok;
}
__be32 nfs4_validate_stateid(struct nfs4_client *cl, stateid_t *stateid) __be32 nfs4_validate_stateid(struct nfs4_client *cl, stateid_t *stateid)
{ {
struct nfs4_stid *s; struct nfs4_stid *s;
struct nfs4_ol_stateid *ols;
__be32 status; __be32 status;
if (STALE_STATEID(stateid)) if (STALE_STATEID(stateid))
...@@ -3381,11 +3388,7 @@ __be32 nfs4_validate_stateid(struct nfs4_client *cl, stateid_t *stateid) ...@@ -3381,11 +3388,7 @@ __be32 nfs4_validate_stateid(struct nfs4_client *cl, stateid_t *stateid)
return status; return status;
if (!(s->sc_type & (NFS4_OPEN_STID | NFS4_LOCK_STID))) if (!(s->sc_type & (NFS4_OPEN_STID | NFS4_LOCK_STID)))
return nfs_ok; return nfs_ok;
ols = openlockstateid(s); return nfsd4_check_openowner_confirmed(openlockstateid(s));
if (ols->st_stateowner->so_is_open_owner
&& !(openowner(ols->st_stateowner)->oo_flags & NFS4_OO_CONFIRMED))
return nfserr_bad_stateid;
return nfs_ok;
} }
static __be32 nfsd4_lookup_stateid(stateid_t *stateid, unsigned char typemask, struct nfs4_stid **s) static __be32 nfsd4_lookup_stateid(stateid_t *stateid, unsigned char typemask, struct nfs4_stid **s)
...@@ -3452,8 +3455,8 @@ nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate, ...@@ -3452,8 +3455,8 @@ nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate,
status = nfs4_check_fh(current_fh, stp); status = nfs4_check_fh(current_fh, stp);
if (status) if (status)
goto out; goto out;
if (stp->st_stateowner->so_is_open_owner status = nfsd4_check_openowner_confirmed(stp);
&& !(openowner(stp->st_stateowner)->oo_flags & NFS4_OO_CONFIRMED)) if (status)
goto out; goto out;
status = nfs4_check_openmode(stp, flags); status = nfs4_check_openmode(stp, flags);
if (status) if (status)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment