Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5582012ybi; Tue, 4 Jun 2019 08:46:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqxmz+rrZGDRKhy9iFRhoG4ilif9duRQYnWE1TvUCtlMI9nzvz2XJXpfQaRV8yL5Tc6iTTqW X-Received: by 2002:a17:90a:9f90:: with SMTP id o16mr38743751pjp.72.1559663200321; Tue, 04 Jun 2019 08:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559663200; cv=none; d=google.com; s=arc-20160816; b=hjN6SLzymAY1Lra7POD4koItgHARmY3Exo0einxxvSyZh53WctGuBPu8L5CTULOgPy r3dy04QkDccaOw7uHnr8fQLabUeGA9vY2JvcG799nG1MdXwuyfUcPHPiiiurEMt3Kye2 lUkjVxBM8eb3iX2RLevRMOZ+3Kq3UXD703KWzDsnKyK5lkOm6f91HiqUJvgCn31DfUfs ZIyrz4+boX0FrnqBaP9ww4NUuW2oEHhs8w/L2T4lNuG4Pthp3Wb4TfXvT4qeP2vemQyL s0H9OTmqZabn28aV+h5G77X9CHKWX8rmQL2fQkHfrIMbOjxoMAiiogzd8PPo9xvOC09v Q0Og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:from:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:date; bh=lhtV9fVQ5j1fSt55bZPQL1N+qxucvrCIc2vW00u2J0c=; b=mEyyKqZBgWWItdXXc4XHgadIYfWMrkqIRuFGnbFyoJA492h0KeHnM5GIpEUy0xFrHj +kmX+l9lK7Bq5LktaeFAfA8HQUL0OEDJ+NbeMMzDCmxjwsSglYMIB9XeZ1wTpacdtZ5x ABBQeEWuwoF133RxDW+3aN7trE8ydH7jCAuBg90aWVEr0OP1vN0CB+ok7CChy3W6qxPv xc3oqR0H8L4SFPSK+3F+0UkU20IIwBEdRyHPA4sq0v1E3udTsVzmoOAdffwSOLqfP52X hJWvrqe9hT7zTkXU0HK1KMXPvi2pSoBiVBCWxi7gnRS6lJVb+9iymFJv2q65Jb8hkiMB /X1A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v22si9004171pfe.275.2019.06.04.08.46.13; Tue, 04 Jun 2019 08:46:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727996AbfFDPqL (ORCPT + 99 others); Tue, 4 Jun 2019 11:46:11 -0400 Received: from fieldses.org ([173.255.197.46]:47492 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727951AbfFDPqL (ORCPT ); Tue, 4 Jun 2019 11:46:11 -0400 Received: by fieldses.org (Postfix, from userid 2815) id 16A7F1C83; Tue, 4 Jun 2019 11:46:11 -0400 (EDT) Date: Tue, 4 Jun 2019 11:46:11 -0400 To: Trond Myklebust Cc: Steve Dickson , "J. Bruce Fields" , linux-nfs@vger.kernel.org Subject: Re: [PATCH 2/3] mountd: Ensure nfsd_path_strip_root() uses the canonicalised path Message-ID: <20190604154611.GC19422@fieldses.org> References: <20190603171227.29148-1-trond.myklebust@hammerspace.com> <20190603171227.29148-2-trond.myklebust@hammerspace.com> <20190603171227.29148-3-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190603171227.29148-3-trond.myklebust@hammerspace.com> User-Agent: Mutt/1.5.21 (2010-09-15) From: bfields@fieldses.org (J. Bruce Fields) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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 > --- > 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 > #include > #include > +#include > #include > #include > > @@ -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? --b. > } > > char * > -- > 2.21.0