From: "J. Bruce Fields" <bfields@fieldses.org>
To: Kinglong Mee <kinglongmee@gmail.com>
Cc: "linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH 4/5] nfsd: Check stateid generation in nfsd4_lookup_stateid()
Date: Wed, 8 Jul 2015 17:42:37 -0400 [thread overview]
Message-ID: <20150708214237.GH19084@fieldses.org> (raw)
In-Reply-To: <5596743C.7080609@gmail.com>
I think you overlooked preprocesse_seqid_op? Does the reordering of the
stateid generation checking matter there? I'm not sure.
--b.
On Fri, Jul 03, 2015 at 07:38:36PM +0800, Kinglong Mee wrote:
> Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
> ---
> fs/nfsd/nfs4layouts.c | 2 --
> fs/nfsd/nfs4state.c | 30 ++++++++++++++----------------
> 2 files changed, 14 insertions(+), 18 deletions(-)
>
> diff --git a/fs/nfsd/nfs4layouts.c b/fs/nfsd/nfs4layouts.c
> index 367a65a..ef63244 100644
> --- a/fs/nfsd/nfs4layouts.c
> +++ b/fs/nfsd/nfs4layouts.c
> @@ -264,8 +264,6 @@ nfsd4_preprocess_layout_stateid(struct svc_rqst *rqstp,
> ls = container_of(stid, struct nfs4_layout_stateid, ls_stid);
>
> status = nfserr_bad_stateid;
> - if (stateid->si_generation > stid->sc_stateid.si_generation)
> - goto out_put_stid;
> if (layout_type != ls->ls_layout_type)
> goto out_put_stid;
> }
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 61dfb33..53248cd 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -4555,6 +4555,7 @@ nfsd4_lookup_stateid(struct nfsd4_compound_state *cstate,
> stateid_t *stateid, unsigned char typemask,
> struct nfs4_stid **s, struct nfsd_net *nn)
> {
> + struct nfs4_stid *stid;
> __be32 status;
>
> if (ZERO_STATEID(stateid) || ONE_STATEID(stateid))
> @@ -4567,10 +4568,18 @@ nfsd4_lookup_stateid(struct nfsd4_compound_state *cstate,
> }
> if (status)
> return status;
> - *s = find_stateid_by_type(cstate->clp, stateid, typemask);
> - if (!*s)
> + stid = find_stateid_by_type(cstate->clp, stateid, typemask);
> + if (!stid)
> return nfserr_bad_stateid;
> - return nfs_ok;
> +
> + status = check_stateid_generation(stateid, &stid->sc_stateid,
> + nfsd4_has_session(cstate));
> + if (status)
> + nfs4_put_stid(stid);
> + else
> + *s = stid;
> +
> + return status;
> }
>
> static struct file *
> @@ -4673,10 +4682,6 @@ nfs4_preprocess_stateid_op(struct svc_rqst *rqstp,
> &s, nn);
> if (status)
> return status;
> - status = check_stateid_generation(stateid, &s->sc_stateid,
> - nfsd4_has_session(cstate));
> - if (status)
> - goto out;
>
> switch (s->sc_type) {
> case NFS4_DELEG_STID:
> @@ -4694,7 +4699,6 @@ nfs4_preprocess_stateid_op(struct svc_rqst *rqstp,
> done:
> if (!status && filpp)
> status = nfs4_check_file(rqstp, fhp, s, filpp, tmp_file, flags);
> -out:
> if (s)
> nfs4_put_stid(s);
> return status;
> @@ -5021,7 +5025,6 @@ __be32
> nfsd4_delegreturn(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
> struct nfsd4_delegreturn *dr)
> {
> - struct nfs4_delegation *dp;
> stateid_t *stateid = &dr->dr_stateid;
> struct nfs4_stid *s;
> __be32 status;
> @@ -5033,14 +5036,9 @@ nfsd4_delegreturn(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
> status = nfsd4_lookup_stateid(cstate, stateid, NFS4_DELEG_STID, &s, nn);
> if (status)
> goto out;
> - dp = delegstateid(s);
> - status = check_stateid_generation(stateid, &dp->dl_stid.sc_stateid, nfsd4_has_session(cstate));
> - if (status)
> - goto put_stateid;
>
> - destroy_delegation(dp);
> -put_stateid:
> - nfs4_put_stid(&dp->dl_stid);
> + destroy_delegation(delegstateid(s));
> + nfs4_put_stid(s);
> out:
> return status;
> }
> --
> 2.4.3
next prev parent reply other threads:[~2015-07-08 21:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-03 11:32 [PATCH 1/5] nfsd: Fix a file leak of ls_file if nfsd4_layout_setlease fail Kinglong Mee
2015-07-03 11:34 ` [PATCH 2/5] nfsd: Drop including client's header file nfs_fs.h Kinglong Mee
2015-07-03 11:36 ` [PATCH 3/5] nfsd: Remove duplicate define of IDMAP_NAMESZ/IDMAP_TYPE_xx Kinglong Mee
2015-07-03 11:38 ` [PATCH 4/5] nfsd: Check stateid generation in nfsd4_lookup_stateid() Kinglong Mee
2015-07-08 21:42 ` J. Bruce Fields [this message]
2015-07-09 10:51 ` Kinglong Mee
2015-07-03 11:39 ` [PATCH 5/5] nfsd: Add macro NFS_ACL_MASK for ACL Kinglong Mee
2015-07-08 21:45 ` J. Bruce Fields
2015-07-08 21:30 ` [PATCH 1/5] nfsd: Fix a file leak of ls_file if nfsd4_layout_setlease fail J. Bruce Fields
2015-07-09 8:12 ` Christoph Hellwig
2015-07-09 9:31 ` Kinglong Mee
2015-07-09 9:38 ` [PATCH v2] " Kinglong Mee
2015-07-09 16:19 ` J. Bruce Fields
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150708214237.GH19084@fieldses.org \
--to=bfields@fieldses.org \
--cc=kinglongmee@gmail.com \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox