Linux NFS development
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Neil Brown <neilb@suse.de>
Cc: Trond Myklebust <trond.myklebust@fys.uio.no>,
	Christoph Hellwig <hch@infradead.org>,
	Frank van Maarseveen <frankvm@frankvm.com>,
	Christoph Hellwig <hch@lst.de>,
	Linux NFS mailing list <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH] exportfs: fix incorrect EACCES in reconnect_path()
Date: Fri, 9 May 2008 00:34:25 -0400	[thread overview]
Message-ID: <20080509043425.GD21408@fieldses.org> (raw)
In-Reply-To: <18466.28013.258338.485948-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>

On Thu, May 08, 2008 at 01:03:09PM +1000, Neil Brown wrote:
> On Tuesday May 6, bfields@fieldses.org wrote:
> > On Tue, May 06, 2008 at 10:35:46AM +1000, Neil Brown wrote:
> > > 
> > > To fix the current bug properly, reconnect_path still needs to bypass
> > > normal permission checks even when subtree_check is in effect, so it
> > > can be sure of getting read permission on the parent directory.
> > 
> > OK, but why not just forget the subtree_check case?  It would be just
> > another item on the "reasons not to use subtree_check" list.
> 
> I guess so.
> 
> > 
> > If a fix for the subtree checking case were easy (or if someone else had
> > the time to do a very careful job of it), then fine, but maybe we should
> > just fix the easy case and leave the subtree checking as is for now.
> 
> So is this the proposed fix?  A bit ugly, but I guess it's OK.

Something like that, yep.  (Frank, can you confirm that this does the
job for you?)

It'd be nice if we could find a way to incorporate a little cleanup at
the same time, but I'm not sure exactly what to suggest.

--b.

> 
> NeilBrown
> 
> Signed-off-by: Neil Brown <neilb@suse.de>
> 
> ### Diffstat output
>  ./fs/nfsd/nfsfh.c |   29 ++++++++++++++++++++++++++---
>  1 file changed, 26 insertions(+), 3 deletions(-)
> 
> diff .prev/fs/nfsd/nfsfh.c ./fs/nfsd/nfsfh.c
> --- .prev/fs/nfsd/nfsfh.c	2008-05-06 10:06:59.000000000 +1000
> +++ ./fs/nfsd/nfsfh.c	2008-05-08 13:01:06.000000000 +1000
> @@ -176,9 +176,24 @@ static __be32 nfsd_set_fh_dentry(struct 
>  	if (IS_ERR(exp))
>  		return nfserrno(PTR_ERR(exp));
>  
> -	error = nfsd_setuser_and_check_port(rqstp, exp);
> -	if (error)
> -		goto out;
> +	if (exp->ex_flags & NFSEXP_NOSUBTREECHECK) {
> +		/* Elevate privileges so that the lack of 'r' or 'x'
> +		 * permission on some parent directory will
> +		 * not stop exportfs_decode_fh from being able
> +		 * to reconnect a directory into the dentry cache.
> +		 * The same problem can affect "SUBTREECHECK" exports,
> +		 * but as nfsd_acceptable depends on correct
> +		 * access control settings being in effect, we cannot
> +		 * fix that case easily - so though.
> +		 */
> +		current->cap_effective =
> +			cap_raise_nfsd_set(current->cap_effective,
> +					   current->cap_permitted);
> +	} else {
> +		error = nfsd_setuser_and_check_port(rqstp, exp);
> +		if (error)
> +			goto out;
> +	}
>  
>  	/*
>  	 * Look up the dentry using the NFS file handle.
> @@ -215,6 +230,14 @@ static __be32 nfsd_set_fh_dentry(struct 
>  		goto out;
>  	}
>  
> +	if (exp->ex_flags & NFSEXP_NOSUBTREECHECK) {
> +		error = nfsd_setuser_and_check_port(rqstp, exp);
> +		if (error) {
> +			dput(dentry);
> +			goto out;
> +		}
> +	}
> +
>  	if (S_ISDIR(dentry->d_inode->i_mode) &&
>  			(dentry->d_flags & DCACHE_DISCONNECTED)) {
>  		printk("nfsd: find_fh_dentry returned a DISCONNECTED directory: %s/%s\n",

  parent reply	other threads:[~2008-05-09  4:34 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-04 10:24 reconnect_path() breaks NFS server causing occasional EACCES Frank van Maarseveen
2008-04-07 18:43 ` J. Bruce Fields
2008-04-07 19:55   ` Frank van Maarseveen
2008-04-09 13:36   ` Christoph Hellwig
2008-04-09 14:11     ` Frank van Maarseveen
2008-04-09 16:24     ` J. Bruce Fields
2008-04-29  5:20     ` Neil Brown
     [not found]       ` <18454.45086.254692.412079-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2008-04-29 16:35         ` J. Bruce Fields
2008-04-29 17:40           ` Frank van Maarseveen
2008-04-30 17:47             ` J. Bruce Fields
2008-05-02 15:16               ` [PATCH] exportfs: fix incorrect EACCES in reconnect_path() Frank van Maarseveen
2008-05-02 15:34                 ` Christoph Hellwig
2008-05-02 15:56                   ` J. Bruce Fields
2008-05-02 16:04                     ` Trond Myklebust
     [not found]                       ` <1209744293.8294.19.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2008-05-02 22:12                         ` J. Bruce Fields
2008-05-04 23:22                           ` Neil Brown
     [not found]                             ` <18462.17737.353976.999538-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2008-05-05 17:47                               ` J. Bruce Fields
2008-05-06  0:35                                 ` Neil Brown
     [not found]                                   ` <18463.42978.531115.344884-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2008-05-06 19:50                                     ` J. Bruce Fields
2008-05-08  3:03                                       ` Neil Brown
     [not found]                                         ` <18466.28013.258338.485948-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2008-05-09  4:34                                           ` J. Bruce Fields [this message]
2008-05-09 10:11                                             ` Frank van Maarseveen
2008-06-29 19:27                                               ` J. Bruce Fields
2008-05-03  8:52                         ` Frank van Maarseveen
2008-04-30 23:29           ` reconnect_path() breaks NFS server causing occasional EACCES Neil Brown

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=20080509043425.GD21408@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=frankvm@frankvm.com \
    --cc=hch@infradead.org \
    --cc=hch@lst.de \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=trond.myklebust@fys.uio.no \
    /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