Message ID | 20221117191151.14262-3-richard@nod.at |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp577576wrr; Thu, 17 Nov 2022 11:14:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf7U09O0VbXxkLncyMZzUY0Jh7FFSO3zpEsHD6e3MN4borzEn2hE5EeKfoW+4uGRma9f2NjF X-Received: by 2002:a17:906:e21a:b0:7a1:e4c2:fb0b with SMTP id gf26-20020a170906e21a00b007a1e4c2fb0bmr3319486ejb.464.1668712497124; Thu, 17 Nov 2022 11:14:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668712497; cv=none; d=google.com; s=arc-20160816; b=cOQVG6PXwV10Im7wbk0a0SWdawOqRkhvNWV7TgLePSHPOdAlMWktf9OWpfgvIXwDxx a5iCnmhyS1yxgc+2Nx+xCZqu1a3nDHfu0hwqz+hffvmwlqC02cuew7KRlfLyZX+jqbfF 1tvXir6II1jMpHle24bNsCecReyzzkyA9XQOSH7N5Hj8pkiwdmvl0Ad/QcZJcbxLarco 3xUaZLrgJ0fmJ9AVYieG5/KmqKOSR7maT+DXttoqJd+zatV1QTnfKdGD0UTRPnuY1I87 jsVE8Lt4OXCAUE+I7OMYNaHuwsLbpt8TTduohZ7wqZCaJiLTBmZ6CvVnni2KRk9bc14O um0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=QR0/lKEZnaThVPieVeCchFgTpddjH7qsjQ88VzoxFKY=; b=x6m4C3QcQfhiS5Og4bvimsxokLkp5jhlWRa5OaWRyFImSo6na66z5uuN9E5Wx2teSF ffvHBfcv4WmvEEOcZ0X+xKO2hkfYnfpCE5a+Y0AaVbEMIzPHlEmAig45oWH+hgv2YzSr Rc7MmOf3rfldNDTIkgg6rEPKClp+uT6BzeCeXS60PDZlGR0w/Vf+4/WlYDwFYDlmkeVo W0/qtkY/FkNkFz+zT/2k0MkrCYRiTQNalOrSaTOPaR9EMW+dulAj5KA1STvRhZI2+rOX +6FFEK7krgbMWxrg2gX7V77XIZfCNRPgTDs5R/aMwVeq1rqwhmx/W+tPn7hzzZL+Osr8 kUcQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v16-20020a056402175000b00462352ef503si1398676edx.518.2022.11.17.11.14.32; Thu, 17 Nov 2022 11:14:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240450AbiKQTMR (ORCPT <rfc822;a1648639935@gmail.com> + 99 others); Thu, 17 Nov 2022 14:12:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240555AbiKQTMM (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 17 Nov 2022 14:12:12 -0500 Received: from lithops.sigma-star.at (lithops.sigma-star.at [195.201.40.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61D0287567; Thu, 17 Nov 2022 11:12:10 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 953E963E516C; Thu, 17 Nov 2022 20:12:08 +0100 (CET) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 2d-a3it2RGeZ; Thu, 17 Nov 2022 20:12:08 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 4A76063E516F; Thu, 17 Nov 2022 20:12:08 +0100 (CET) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id uDGT4ROq8FZk; Thu, 17 Nov 2022 20:12:08 +0100 (CET) Received: from blindfold.corp.sigma-star.at (213-47-184-186.cable.dynamic.surfer.at [213.47.184.186]) by lithops.sigma-star.at (Postfix) with ESMTPSA id C32F463E516B; Thu, 17 Nov 2022 20:12:07 +0100 (CET) From: Richard Weinberger <richard@nod.at> To: linux-nfs@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, jlayton@kernel.org, chuck.lever@oracle.com, anna@kernel.org, trond.myklebust@hammerspace.com, viro@zeniv.linux.org.uk, raven@themaw.net, chris.chilvers@appsbroker.com, david.young@appsbroker.com, luis.turcitu@appsbroker.com, david@sigma-star.at, Richard Weinberger <richard@nod.at> Subject: [PATCH 2/3] fs: namei: Allow follow_down() to uncover auto mounts Date: Thu, 17 Nov 2022 20:11:50 +0100 Message-Id: <20221117191151.14262-3-richard@nod.at> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20221117191151.14262-1-richard@nod.at> References: <20221117191151.14262-1-richard@nod.at> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, T_SPF_PERMERROR autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749771875102198394?= X-GMAIL-MSGID: =?utf-8?q?1749771875102198394?= |
Series |
NFS: NFSD: Allow crossing mounts when re-exporting
|
|
Commit Message
Richard Weinberger
Nov. 17, 2022, 7:11 p.m. UTC
This function is only used by NFSD to cross mount points.
If a mount point is of type auto mount, follow_down() will
not uncover it. Add LOOKUP_AUTOMOUNT to the lookup flags
to have ->d_automount() called when NFSD walks down the
mount tree.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
fs/namei.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Thu, 2022-11-17 at 20:11 +0100, Richard Weinberger wrote: > This function is only used by NFSD to cross mount points. > If a mount point is of type auto mount, follow_down() will > not uncover it. Add LOOKUP_AUTOMOUNT to the lookup flags > to have ->d_automount() called when NFSD walks down the > mount tree. > > Signed-off-by: Richard Weinberger <richard@nod.at> > --- > fs/namei.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/namei.c b/fs/namei.c > index 578c2110df02..000c4b84e6be 100644 > --- a/fs/namei.c > +++ b/fs/namei.c > @@ -1462,7 +1462,7 @@ int follow_down(struct path *path) > { > struct vfsmount *mnt = path->mnt; > bool jumped; > - int ret = traverse_mounts(path, &jumped, NULL, 0); > + int ret = traverse_mounts(path, &jumped, NULL, LOOKUP_AUTOMOUNT); > > if (path->mnt != mnt) > mntput(mnt); What happens when CROSSMOUNT isn't enabled and someone tries to stroll into an automount point? I'm guessing the automount happens but the export is denied? It seems like LOOKUP_AUTOMOUNT ought to be conditional on the parent export having CROSSMOUNT set. There's also another caller of follow_down too, the UNIX98 pty code. This may be harmless for it, but it'd be best not to perturb that if we can help it. Maybe follow_down can grow a lookupflags argument?
----- Ursprüngliche Mail ----- > Von: "Jeff Layton" <jlayton@kernel.org> > What happens when CROSSMOUNT isn't enabled and someone tries to stroll > into an automount point? I'm guessing the automount happens but the > export is denied? Exactly. On the other hand, why should knfsd not trigger automounts? Almost any userspace interaction would also do so. > It seems like LOOKUP_AUTOMOUNT ought to be conditional > on the parent export having CROSSMOUNT set. > > There's also another caller of follow_down too, the UNIX98 pty code. > This may be harmless for it, but it'd be best not to perturb that if we > can help it. > > Maybe follow_down can grow a lookupflags argument? So, in nfsd_cross_mnt() the follow_down() helper should use LOOKUP_AUTOMOUNT only if exp->ex_flags & NFSEXP_CROSSMOUNT is true? Sounds sane, thanks for the pointer. Thanks, //richard
On Thu, 2022-11-17 at 22:12 +0100, Richard Weinberger wrote: > ----- Ursprüngliche Mail ----- > > Von: "Jeff Layton" <jlayton@kernel.org> > > What happens when CROSSMOUNT isn't enabled and someone tries to stroll > > into an automount point? I'm guessing the automount happens but the > > export is denied? > > Exactly. > > On the other hand, why should knfsd not trigger automounts? > Almost any userspace interaction would also do so. > I have no issue with knfsd activity triggering an automount, but I think it'd be best if we don't do that when knfsd can't do anything with the resulting filesystem. Automounts can be expensive. > > It seems like LOOKUP_AUTOMOUNT ought to be conditional > > on the parent export having CROSSMOUNT set. > > > > There's also another caller of follow_down too, the UNIX98 pty code. > > This may be harmless for it, but it'd be best not to perturb that if we > > can help it. > > > > Maybe follow_down can grow a lookupflags argument? > > So, in nfsd_cross_mnt() the follow_down() helper should use LOOKUP_AUTOMOUNT only > if exp->ex_flags & NFSEXP_CROSSMOUNT is true? > Sounds sane, thanks for the pointer. > Yeah, I think so. I do wonder if we ought to make any provision for "nohide" exports, but since you have to enumerate those explicitly, it shouldn't be a huge problem for someone to just ensure that they're mounted beforehand.
On 18/11/22 05:01, Jeff Layton wrote: > On Thu, 2022-11-17 at 20:11 +0100, Richard Weinberger wrote: >> This function is only used by NFSD to cross mount points. >> If a mount point is of type auto mount, follow_down() will >> not uncover it. Add LOOKUP_AUTOMOUNT to the lookup flags >> to have ->d_automount() called when NFSD walks down the >> mount tree. >> >> Signed-off-by: Richard Weinberger <richard@nod.at> >> --- >> fs/namei.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/fs/namei.c b/fs/namei.c >> index 578c2110df02..000c4b84e6be 100644 >> --- a/fs/namei.c >> +++ b/fs/namei.c >> @@ -1462,7 +1462,7 @@ int follow_down(struct path *path) >> { >> struct vfsmount *mnt = path->mnt; >> bool jumped; >> - int ret = traverse_mounts(path, &jumped, NULL, 0); >> + int ret = traverse_mounts(path, &jumped, NULL, LOOKUP_AUTOMOUNT); >> >> if (path->mnt != mnt) >> mntput(mnt); > > What happens when CROSSMOUNT isn't enabled and someone tries to stroll > into an automount point? I'm guessing the automount happens but the > export is denied? It seems like LOOKUP_AUTOMOUNT ought to be conditional > on the parent export having CROSSMOUNT set. > > There's also another caller of follow_down too, the UNIX98 pty code. > This may be harmless for it, but it'd be best not to perturb that if we > can help it. > > Maybe follow_down can grow a lookupflags argument?es, I think that's needed too. Changing the core VFS unconditionally ricks breaking things. For example this: if (!(lookup_flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY | LOOKUP_OPEN | LOOKUP_CREATE | LOOKUP_AUTOMOUNT)) && dentry->d_inode) will never be true now so that, at the least, the handling of this case will change for automount(8). I don't remember now the reasons behind doing this but I do remember there was a special case that needed to be handled by it. Ian
----- Ursprüngliche Mail ----- > Von: "Jeff Layton" <jlayton@kernel.org> >> So, in nfsd_cross_mnt() the follow_down() helper should use LOOKUP_AUTOMOUNT >> only >> if exp->ex_flags & NFSEXP_CROSSMOUNT is true? >> Sounds sane, thanks for the pointer. >> > > Yeah, I think so. I do wonder if we ought to make any provision for > "nohide" exports, but since you have to enumerate those explicitly, it > shouldn't be a huge problem for someone to just ensure that they're > mounted beforehand. TBH, I didn't invest much into the nohide feature wrt. NFS re-exporting. What problem do you have in mind? I wonder also what NFS client folks think about my changes before I send the next revision (with Jeff's comments addressed). Thanks, //richard
On Sun, 2022-11-27 at 22:29 +0100, Richard Weinberger wrote: > ----- Ursprüngliche Mail ----- > > Von: "Jeff Layton" <jlayton@kernel.org> > > > So, in nfsd_cross_mnt() the follow_down() helper should use LOOKUP_AUTOMOUNT > > > only > > > if exp->ex_flags & NFSEXP_CROSSMOUNT is true? > > > Sounds sane, thanks for the pointer. > > > > > > > Yeah, I think so. I do wonder if we ought to make any provision for > > "nohide" exports, but since you have to enumerate those explicitly, it > > shouldn't be a huge problem for someone to just ensure that they're > > mounted beforehand. > > TBH, I didn't invest much into the nohide feature wrt. NFS re-exporting. > What problem do you have in mind? > nohide is sort of complimentary to crossmnt. You can achieve the same effect as crossmnt by adding explicit exports for all the children and marking them "nohide". The point here is that you have to explicitly create exports for the child mounts in that case, and if you're doing that then it's not a burden for the admin to make sure they're mounted before exporting. So, I don't think we need to worry about nohide here after all. > I wonder also what NFS client folks think about my changes before I send > the next revision (with Jeff's comments addressed).
diff --git a/fs/namei.c b/fs/namei.c index 578c2110df02..000c4b84e6be 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1462,7 +1462,7 @@ int follow_down(struct path *path) { struct vfsmount *mnt = path->mnt; bool jumped; - int ret = traverse_mounts(path, &jumped, NULL, 0); + int ret = traverse_mounts(path, &jumped, NULL, LOOKUP_AUTOMOUNT); if (path->mnt != mnt) mntput(mnt);