From: Trond Myklebust <trondmy@hammerspace.com>
To: "bfields@fieldses.org" <bfields@fieldses.org>
Cc: "linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>,
"SteveD@redhat.com" <SteveD@redhat.com>,
"bfields@redhat.com" <bfields@redhat.com>
Subject: Re: [PATCH 2/3] mountd: Ensure nfsd_path_strip_root() uses the canonicalised path
Date: Tue, 4 Jun 2019 17:58:59 +0000 [thread overview]
Message-ID: <1fb61a70b5eea0cd4735aa5ae3050382b317f886.camel@hammerspace.com> (raw)
In-Reply-To: <20190604154611.GC19422@fieldses.org>
On Tue, 2019-06-04 at 11:46 -0400, J. Bruce Fields wrote:
> On Mon, Jun 03, 2019 at 01:12:26PM -0400, Trond Myklebust wrote:
> > When attempting to strip the root path, we should first
> > canonicalise
> > the root pathname.
> >
> > Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
> > ---
> > support/misc/nfsd_path.c | 17 +++++++++++++----
> > 1 file changed, 13 insertions(+), 4 deletions(-)
> >
> > diff --git a/support/misc/nfsd_path.c b/support/misc/nfsd_path.c
> > index 2f41a793c534..9b38dd96007f 100644
> > --- a/support/misc/nfsd_path.c
> > +++ b/support/misc/nfsd_path.c
> > @@ -1,6 +1,7 @@
> > #include <errno.h>
> > #include <sys/types.h>
> > #include <sys/stat.h>
> > +#include <limits.h>
> > #include <stdlib.h>
> > #include <unistd.h>
> >
> > @@ -62,13 +63,21 @@ nfsd_path_nfsd_rootdir(void)
> > char *
> > nfsd_path_strip_root(char *pathname)
> > {
> > + char buffer[PATH_MAX];
> > const char *dir = nfsd_path_nfsd_rootdir();
> > char *ret;
> >
> > - ret = strstr(pathname, dir);
> > - if (!ret || ret != pathname)
> > - return pathname;
> > - return pathname + strlen(dir);
> > + if (!dir)
> > + goto out;
> > + if (realpath(dir, buffer)) {
> > + ret = strstr(pathname, buffer);
> > + if (ret == pathname)
> > + return pathname + strlen(dir);
> > + } else
> > + xlog(D_GENERAL, "%s: failed to resolve path %s: %m",
> > + __func__, dir);
> > +out:
> > + return pathname;
>
> I still don't get this.
>
> So in the case strstr doesn't find anything, it returns the path
> unchanged.
>
> That means that if the next_mnt() caller asks whether there are any
> mounts underneath /rootdir/a/b, and nextdir finds a mountpoint at
> /a/b/c, it can return that, right?
>
Ack. Sending out a v2 of these patches.
Thanks Bruce!
--
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@hammerspace.com
next prev parent reply other threads:[~2019-06-04 17:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-03 17:12 [PATCH 0/3] Incremental against [exports] rootdir patchset Trond Myklebust
2019-06-03 17:12 ` [PATCH 1/3] mountd: Fix up incorrect comparison in next_mnt() Trond Myklebust
2019-06-03 17:12 ` [PATCH 2/3] mountd: Ensure nfsd_path_strip_root() uses the canonicalised path Trond Myklebust
2019-06-03 17:12 ` [PATCH 3/3] mountd: Canonicalise the rootdir in exportent_mkrealpath() Trond Myklebust
2019-06-04 15:46 ` [PATCH 2/3] mountd: Ensure nfsd_path_strip_root() uses the canonicalised path J. Bruce Fields
2019-06-04 17:58 ` Trond Myklebust [this message]
2019-06-04 18:01 ` bfields
2019-06-10 13:53 ` [PATCH 0/3] Incremental against [exports] rootdir patchset Steve Dickson
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=1fb61a70b5eea0cd4735aa5ae3050382b317f886.camel@hammerspace.com \
--to=trondmy@hammerspace.com \
--cc=SteveD@redhat.com \
--cc=bfields@fieldses.org \
--cc=bfields@redhat.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;
as well as URLs for NNTP newsgroup(s).