Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5720471ybi; Tue, 4 Jun 2019 11:01:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqxx7/lLHUNKsVBqvaSsrNvU4TafpERUWzSsmsD5U59fxL3kb6evbD+W9pd/kKruOyWPqF3n X-Received: by 2002:a63:184d:: with SMTP id 13mr36830620pgy.346.1559671309205; Tue, 04 Jun 2019 11:01:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559671309; cv=none; d=google.com; s=arc-20160816; b=TBYggT0A1+82p2d7l8fvdZ/pJKwmofw1+8fy6Ps1FbvnalPF+QGiMNjYukFp5QumA2 J4kQxJyzeTrIcbmrf6ilPGypzdfxOUZqBETIv/1UxyZb46e/aLSq/ChdXx6Yo6qiRE8N O4pqq89B65U6tplbNlaqzL+B2psDxTYvo29PPMtGyIbK8WJm4DjgqfR6e9myYI/HK3c5 qh6uOAF+zKRW972xz4t/QJLsyAWS3rr0YmkaLVrJIRCztKbNgxtBDNXOneQuhg4cBy0+ c1NV0wNeA7AMq5KgakqqCgLZtWS844Tg49VL8PjPRuz4Lwfu4mRqrcM4Jy3qSlq8Ebeg vikA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=MLZQeXm7CKlbq/4cIKwhMkKzCaAKhVluSV8wUWi60Cc=; b=u9USsxGtuo4y23K8I+rdqfGGK/oG6tNrishJ/sjFQ97AgwUBVkbVYR1ijtTQpSYUKj pj9fICh+zb7MGpk6ST5GyvxUQ/dbPmAJNd80i7mzv6B8X3bHKbANJvazHvIHkhr0rSe1 486jqlHsXme5SeMCP/6cObzO7wy3QukbKdzmWqXSG1zNNK+jdIcsEDSfaHrcxgaZHDXK Gt1TgRV64pxOhLGsIbpOjR+DH6uKZD/VRBjdVRB8aQlxrBt/FAP/rkVgLDAHMd5Z8akh +aiBVfM+mvuHeh+ndvWjmeX38qalMnaIcHMrgMzihk4JSrlOvIsAZ0oWRwwMp2X66r0o HBlQ== 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 16si10322891pfo.12.2019.06.04.11.01.32; Tue, 04 Jun 2019 11:01:49 -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 S1726295AbfFDSB1 (ORCPT + 99 others); Tue, 4 Jun 2019 14:01:27 -0400 Received: from fieldses.org ([173.255.197.46]:33830 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726211AbfFDSB0 (ORCPT ); Tue, 4 Jun 2019 14:01:26 -0400 Received: by fieldses.org (Postfix, from userid 2815) id 7CAFD1C17; Tue, 4 Jun 2019 14:01:26 -0400 (EDT) Date: Tue, 4 Jun 2019 14:01:26 -0400 From: "bfields@fieldses.org" To: Trond Myklebust Cc: "linux-nfs@vger.kernel.org" , "SteveD@redhat.com" , "bfields@redhat.com" Subject: Re: [PATCH 2/3] mountd: Ensure nfsd_path_strip_root() uses the canonicalised path Message-ID: <20190604180126.GA2953@fieldses.org> References: <20190603171227.29148-1-trond.myklebust@hammerspace.com> <20190603171227.29148-2-trond.myklebust@hammerspace.com> <20190603171227.29148-3-trond.myklebust@hammerspace.com> <20190604154611.GC19422@fieldses.org> <1fb61a70b5eea0cd4735aa5ae3050382b317f886.camel@hammerspace.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1fb61a70b5eea0cd4735aa5ae3050382b317f886.camel@hammerspace.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Tue, Jun 04, 2019 at 05:58:59PM +0000, Trond Myklebust wrote: > 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 > > > --- > > > 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? > > > > Ack. Sending out a v2 of these patches. Oh, good, thanks, I thought I was going crazy. (Always a possibility, especially when I'm looking at code.) --b.