public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Steve Dickson <SteveD@redhat.com>
To: "J. Bruce Fields" <bfields@citi.umich.edu>
Cc: linux-nfs@vger.kernel.org, nfsv4@linux-nfs.org
Subject: Re: [PATCH 6/7] nfsd: restrict filehandles accepted in V4ROOT case
Date: Fri, 04 Dec 2009 10:05:09 -0500	[thread overview]
Message-ID: <4B192525.4050301@RedHat.com> (raw)
In-Reply-To: <1259714383-32577-7-git-send-email-bfields@citi.umich.edu>



On 12/01/2009 07:39 PM, J. Bruce Fields wrote:
> From: Steve Dickson <SteveD@redhat.com>
> 
> On V4ROOT exports, only accept filehandles that are the *root* of some
> export.  This allows mountd to allow or deny access to individual paths
> and symlinks on the pseudofilesystem.
> 
> Note that the checks in readdir and lookup are not enough, since a
> malicious host with access to the network could guess filehandles that
> they weren't able to obtain through lookup or readdir.
> 
> Signed-Off-By: Steve Dickson <steved@redhat.com>
> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
> ---
>  fs/nfsd/nfsd.h  |    4 ++++
>  fs/nfsd/nfsfh.c |   35 +++++++++++++++++++++++++++++++++++
>  fs/nfsd/vfs.c   |    7 +------
>  3 files changed, 40 insertions(+), 6 deletions(-)
>  create mode 100644 fs/nfsd/nfsd.h
> 
> diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
> new file mode 100644
> index 0000000..7a1ad80
> --- /dev/null
> +++ b/fs/nfsd/nfsd.h
> @@ -0,0 +1,4 @@
> +static inline int nfsd_v4client(struct svc_rqst *rq)
> +{
> +	return rq->rq_prog == NFS_PROGRAM && rq->rq_vers == 4;
> +}
> diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
> index a77efb8..9b902c0 100644
> --- a/fs/nfsd/nfsfh.c
> +++ b/fs/nfsd/nfsfh.c
> @@ -22,6 +22,7 @@
>  #include <linux/sunrpc/svc.h>
>  #include <linux/sunrpc/svcauth_gss.h>
>  #include <linux/nfsd/nfsd.h>
> +#include "nfsd.h"
>  #include "vfs.h"
>  #include "auth.h"
>  
> @@ -110,6 +111,36 @@ static __be32 nfsd_setuser_and_check_port(struct svc_rqst *rqstp,
>  	return nfserrno(nfsd_setuser(rqstp, exp));
>  }
>  
> +static inline __be32 check_pseudo_root(struct svc_rqst *rqstp,
> +	struct dentry *dentry, struct svc_export *exp)
> +{
> +	if (!(exp->ex_flags & NFSEXP_V4ROOT))
> +		return nfs_ok;
> +	/*
> +	 * v2/v3 clients have no need for the V4ROOT export--they use
> +	 * the mount protocl instead; also, further V4ROOT checks may be
> +	 * in v4-specific code, in which case v2/v3 clients could bypass
> +	 * them.
> +	 */
> +	if (!nfsd_v4client(rqstp))
> +		return nfserr_stale;
> +	/*
> +	 * We're exposing only the directories and symlinks that have to be
> +	 * traversed on the way to real exports:
> +	 */
> +	if (unlikely(!S_ISDIR(dentry->d_inode->i_mode) &&
> +		     !S_ISLNK(dentry->d_inode->i_mode)))
> +		return nfserr_stale;
> +	/*
> +	 * A pseudoroot export gives permission to access only one
> +	 * single directory; the kernel has to make another upcall
> +	 * before granting access to anything else under it:
> +	 */
> +	if (unlikely(dentry->d_parent != exp->ex_path.dentry))
Remember this is wrong... it needs to be 
-	if (unlikely(dentry->d_parent != exp->ex_path.dentry))
+	if (unlikely(dentry != exp->ex_path.dentry))

steved.

  parent reply	other threads:[~2009-12-04 15:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-02  0:39 pseudoroot kernel patches J. Bruce Fields
2009-12-02  0:39 ` [PATCH 1/7] nfsd: introduce export flag for v4 pseudoroot J. Bruce Fields
2009-12-02  0:39   ` [PATCH 2/7] nfsd4: don't continue "under" mounts in V4ROOT case J. Bruce Fields
2009-12-02  0:39     ` [PATCH 3/7] nfsd: filter lookup results " J. Bruce Fields
2009-12-02  0:39       ` [PATCH 4/7] nfsd: special readdir exception for V4ROOT J. Bruce Fields
2009-12-02  0:39         ` [PATCH 5/7] nfsd: allow exports of symlinks J. Bruce Fields
2009-12-02  0:39           ` [PATCH 6/7] nfsd: restrict filehandles accepted in V4ROOT case J. Bruce Fields
2009-12-02  0:39             ` [PATCH 7/7] nfsd: increase export interface version J. Bruce Fields
2009-12-04 15:05             ` Steve Dickson [this message]
     [not found]               ` <4B192525.4050301-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
2009-12-04 18:49                 ` [PATCH 6/7] nfsd: restrict filehandles accepted in V4ROOT case 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=4B192525.4050301@RedHat.com \
    --to=steved@redhat.com \
    --cc=bfields@citi.umich.edu \
    --cc=linux-nfs@vger.kernel.org \
    --cc=nfsv4@linux-nfs.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