Linux NFS development
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Jeff Layton <jlayton@poochiereds.net>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH] nfsd: do nfs4_check_fh in nfs4_check_file instead of nfs4_check_olstateid
Date: Thu, 30 Jul 2015 11:16:41 -0400	[thread overview]
Message-ID: <20150730151641.GE9349@fieldses.org> (raw)
In-Reply-To: <1438253866-7393-1-git-send-email-jeff.layton@primarydata.com>

On Thu, Jul 30, 2015 at 06:57:46AM -0400, Jeff Layton wrote:
> Currently, preprocess_stateid_op calls nfs4_check_olstateid which
> verifies that the open stateid corresponds to the current_fh in the
> call by calling nfs4_check_fh.
> 
> If the stateid is a NFS4_DELEG_STID however, then no such check is
> done. Move the call to nfs4_check_fh into nfs4_check_file instead
> so that it can be done for all stateid types.

Thanks, applying for 4.2 and -stable with a note that this can screw up
permissions checking later in nfs4_check_file.

--b.

> 
> Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
> ---
>  fs/nfsd/nfs4state.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index cd8c33186e26..75f617a052cf 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -4406,9 +4406,9 @@ laundromat_main(struct work_struct *laundry)
>  	queue_delayed_work(laundry_wq, &nn->laundromat_work, t*HZ);
>  }
>  
> -static inline __be32 nfs4_check_fh(struct svc_fh *fhp, struct nfs4_ol_stateid *stp)
> +static inline __be32 nfs4_check_fh(struct svc_fh *fhp, struct nfs4_stid *stp)
>  {
> -	if (!fh_match(&fhp->fh_handle, &stp->st_stid.sc_file->fi_fhandle))
> +	if (!fh_match(&fhp->fh_handle, &stp->sc_file->fi_fhandle))
>  		return nfserr_bad_stateid;
>  	return nfs_ok;
>  }
> @@ -4611,9 +4611,6 @@ nfs4_check_olstateid(struct svc_fh *fhp, struct nfs4_ol_stateid *ols, int flags)
>  {
>  	__be32 status;
>  
> -	status = nfs4_check_fh(fhp, ols);
> -	if (status)
> -		return status;
>  	status = nfsd4_check_openowner_confirmed(ols);
>  	if (status)
>  		return status;
> @@ -4628,6 +4625,10 @@ nfs4_check_file(struct svc_rqst *rqstp, struct svc_fh *fhp, struct nfs4_stid *s,
>  	struct file *file;
>  	__be32 status;
>  
> +	status = nfs4_check_fh(fhp, s);
> +	if (status)
> +		return status;
> +
>  	file = nfs4_find_file(s, flags);
>  	if (file) {
>  		status = nfsd_permission(rqstp, fhp->fh_export, fhp->fh_dentry,
> @@ -4808,7 +4809,7 @@ static __be32 nfs4_seqid_op_checks(struct nfsd4_compound_state *cstate, stateid_
>  	status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, nfsd4_has_session(cstate));
>  	if (status)
>  		return status;
> -	return nfs4_check_fh(current_fh, stp);
> +	return nfs4_check_fh(current_fh, &stp->st_stid);
>  }
>  
>  /* 
> -- 
> 2.4.3

  reply	other threads:[~2015-07-30 15:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-30 10:57 [PATCH] nfsd: do nfs4_check_fh in nfs4_check_file instead of nfs4_check_olstateid Jeff Layton
2015-07-30 15:16 ` J. Bruce Fields [this message]
2015-07-31 20:05   ` J. Bruce Fields
2015-07-31 20:28     ` Jeff Layton
  -- strict thread matches above, loose matches on Subject: below --
2015-07-30 13:52 [PATCH 0/9] nfsd: open file caching for v2/3 Jeff Layton
2015-07-30 13:52 ` [PATCH] nfsd: do nfs4_check_fh in nfs4_check_file instead of nfs4_check_olstateid Jeff Layton
2015-07-30 13:53   ` Jeff Layton
2015-07-30 15:51   ` Christoph Hellwig
2015-07-30 16:20     ` Jeff Layton
2015-07-30 16:34       ` Christoph Hellwig

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=20150730151641.GE9349@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=jlayton@poochiereds.net \
    --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