From patchwork Wed Dec 7 08:43:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Weinberger X-Patchwork-Id: 30699 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp59671wrr; Wed, 7 Dec 2022 00:45:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf4b2iGNy5YTWC+EePLrTF60oX6VChvVPw92/srbTMaWG4YQilq2L7dvTmSFKT6hIDHofBXo X-Received: by 2002:a17:902:c115:b0:189:c9ac:7428 with SMTP id 21-20020a170902c11500b00189c9ac7428mr18391022pli.159.1670402749153; Wed, 07 Dec 2022 00:45:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670402749; cv=none; d=google.com; s=arc-20160816; b=c/l/GSk/nDze4eSVqIgo0c95Cco9EAEgiUR/AFMvvdAvkE+gNHDqK7Z5jbm+L+uYyn w8gzVGH5T0g8kH2RLmeGQZww92H2syfyj3frrPxmY+rHE6pkrHhCEpAsLa9F9GuellK3 b4dHDgg/NrPS3STYbq7awk11qK1tn6LCuaPZXOuQBDQ0ahOn34J4p+VMSv/chRaFok2G JEiHNad8nWw/krLy+obnyxnbkryK63nvM33EWedaC0iPe8ZUxrrL6o2q7WvAeOjIyj+0 xZr2OMMLxBiXLPtGzFhKwiAsL+WInCKEoc0NNK6kPxdABMmgJqtWc+rldEeo6sHox5IE W3Hg== 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=U9wn3zADMgu2IIkfzXXbePNdCfJiTDl83ux/wXSTSE4=; b=XYFhIZlZCIN8sy2MZ5m8ng/IvGuoEIstqpLN1ZzzTXa3dsDiAkk3/kahCUvGXGMdIu HRUHi2/fUn0Wp7B/dfm0ogg2AXiJF1TvfgOPRZr1oqlqtZ/IuyIIGWed3Er8eeZYTyqs 3wC/sEO9K+3/F8BNpdC3hFYaLkssnzqjp2Uu7CdanDXZvPUqHEJdYBBzx+gTJVle0yMd K+XdSldHe2X2GHoU4CeMp0CXrYN8PHSXKBsvbAjO2kfiJKeQ/JDTsHaDHhHRjdgGXDpx BO7oiI/xwEsq/oiLxpCHiWepPgzPTeJxBi4tHaQZH9Sqx7YT/dTjzmUi7l5ZPzAGtugA 5nrQ== 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 bk13-20020a056a02028d00b00478972b84d7si12889825pgb.249.2022.12.07.00.45.36; Wed, 07 Dec 2022 00:45:49 -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 S229883AbiLGInl (ORCPT + 99 others); Wed, 7 Dec 2022 03:43:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229538AbiLGIna (ORCPT ); Wed, 7 Dec 2022 03:43:30 -0500 Received: from lithops.sigma-star.at (lithops.sigma-star.at [195.201.40.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 997D7B1CA; Wed, 7 Dec 2022 00:43:27 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 9EB3A64BA9D6; Wed, 7 Dec 2022 09:43:25 +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 LY6Z9iYN4mWg; Wed, 7 Dec 2022 09:43:25 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 0CE646226232; Wed, 7 Dec 2022 09:43:25 +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 zw7q6RHb6S87; Wed, 7 Dec 2022 09:43:24 +0100 (CET) Received: from blindfold.corp.sigma-star.at (unknown [82.150.214.1]) by lithops.sigma-star.at (Postfix) with ESMTPSA id 6544E64BA9AE; Wed, 7 Dec 2022 09:43:24 +0100 (CET) From: Richard Weinberger 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, benmaynard@google.com, Richard Weinberger Subject: [PATCH 2/3] fs: namei: Allow follow_down() to uncover auto mounts Date: Wed, 7 Dec 2022 09:43:08 +0100 Message-Id: <20221207084309.8499-3-richard@nod.at> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20221207084309.8499-1-richard@nod.at> References: <20221207084309.8499-1-richard@nod.at> MIME-Version: 1.0 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751544233123165412?= X-GMAIL-MSGID: =?utf-8?q?1751544233123165412?= 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 Acked-by: Al Viro --- fs/namei.c | 6 +++--- fs/nfsd/vfs.c | 6 +++++- include/linux/namei.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 578c2110df02..a6bb6863bf0c 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1458,11 +1458,11 @@ EXPORT_SYMBOL(follow_down_one); * point, the filesystem owning that dentry may be queried as to whether the * caller is permitted to proceed or not. */ -int follow_down(struct path *path) +int follow_down(struct path *path, unsigned int flags) { struct vfsmount *mnt = path->mnt; bool jumped; - int ret = traverse_mounts(path, &jumped, NULL, 0); + int ret = traverse_mounts(path, &jumped, NULL, flags); if (path->mnt != mnt) mntput(mnt); @@ -2864,7 +2864,7 @@ int path_pts(struct path *path) path->dentry = child; dput(parent); - follow_down(path); + follow_down(path, 0); return 0; } #endif diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 157f0df0e93a..ced04fc2b947 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -63,9 +63,13 @@ nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp, struct dentry *dentry = *dpp; struct path path = {.mnt = mntget(exp->ex_path.mnt), .dentry = dget(dentry)}; + unsigned int follow_flags = 0; int err = 0; - err = follow_down(&path); + if (exp->ex_flags & NFSEXP_CROSSMOUNT) + follow_flags = LOOKUP_AUTOMOUNT; + + err = follow_down(&path, follow_flags); if (err < 0) goto out; if (path.mnt == exp->ex_path.mnt && path.dentry == dentry && diff --git a/include/linux/namei.h b/include/linux/namei.h index 00fee52df842..6f96db73a70a 100644 --- a/include/linux/namei.h +++ b/include/linux/namei.h @@ -77,7 +77,7 @@ struct dentry *lookup_one_positive_unlocked(struct user_namespace *mnt_userns, struct dentry *base, int len); extern int follow_down_one(struct path *); -extern int follow_down(struct path *); +extern int follow_down(struct path *, unsigned int flags); extern int follow_up(struct path *); extern struct dentry *lock_rename(struct dentry *, struct dentry *);