From patchwork Mon Oct 3 00:46:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 9359865 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DDAF660459 for ; Mon, 3 Oct 2016 00:48:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EEB0E28A45 for ; Mon, 3 Oct 2016 00:48:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E37AC28A63; Mon, 3 Oct 2016 00:48:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F0CF28A45 for ; Mon, 3 Oct 2016 00:48:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752410AbcJCAsX (ORCPT ); Sun, 2 Oct 2016 20:48:23 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:54418 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752138AbcJCArE (ORCPT ); Sun, 2 Oct 2016 20:47:04 -0400 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id AC4D82068D; Sun, 2 Oct 2016 20:47:03 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute7.internal (MEProxy); Sun, 02 Oct 2016 20:47:03 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=themaw.net; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=8ibuMTAkiKDRtxAi6DPfVAI4smA=; b=XfDibA c0Z9YrOQlzvF0knko+WcW/IFlmz/xe3rZwD7IkFJStWI5AZVHchs7A2U0Ckdy9S2 FX1f0pWsFlozbVo7QBuQlsSmYsW9AHSx7kq6ivmKecwYr/8nVORmzIa3rwZyy+cH vkUWjCjF0G9O3Cuf+NXc2OlIq6yE+RGhpntxg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=8ibuMTAkiKDRtxA i6DPfVAI4smA=; b=U1FJ/qtHV8rE52PLldcR4rkg1ejBgoCFTFjx5yNb3+xKPd4 1Yz5uIVyyjiLYsfvPjnHGewenS6uXuZJT596yHvYygg0zirU9Z5meqEm0DplJlOj MBDHJO46FCDaq/+ErzZs/6sB3ZYo8Xn9VJdtQvGPDfjeYRb0JDF8So5Fxf6M= X-Sasl-enc: S6EXRJeD0K76q/l3jhCvv5iUiktNMTdR3tfi/tTbre6P 1475455623 Received: from pluto.themaw.net (58-6-77-201.dyn.iinet.net.au [58.6.77.201]) by mail.messagingengine.com (Postfix) with ESMTPA id 272B6F2988; Sun, 2 Oct 2016 20:47:03 -0400 (EDT) Received: from pluto.themaw.net (localhost [127.0.0.1]) by pluto.themaw.net (Postfix) with ESMTP id 02E0DA008E; Mon, 3 Oct 2016 08:46:59 +0800 (AWST) Subject: [RFC PATCH 7/8] autofs - use path_has_submounts() to fix unreliable have_submount() checks From: Ian Kent To: Kernel Mailing List Cc: autofs mailing list , Al Viro , linux-fsdevel , Omar Sandoval , Andrew Morton , "Eric W. Biederman" Date: Mon, 03 Oct 2016 08:46:59 +0800 Message-ID: <20161003004659.4865.60429.stgit@pluto.themaw.net> In-Reply-To: <20161003003646.4865.42500.stgit@pluto.themaw.net> References: <20161003003646.4865.42500.stgit@pluto.themaw.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ian Kent If an automount mount is clone(2)ed into a file system that is propagation private, when it later expires in the originating namespace, subsequent calls to autofs ->d_automount() for that dentry in the original namespace will return ELOOP until the mount is umounted in the cloned namespace. Now that a struct path is available where needed use path_has_submounts() instead of have_submounts() so we don't get false positives when checking if a dentry is a mount point or contains mounts in the current namespace. Signed-off-by: Ian Kent Cc: Al Viro Cc: Eric W. Biederman Cc: Omar Sandoval --- fs/autofs4/dev-ioctl.c | 2 +- fs/autofs4/root.c | 14 +++++++------- fs/autofs4/waitq.c | 10 +++++++--- 3 files changed, 15 insertions(+), 11 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c index 3cd96e6..953e790 100644 --- a/fs/autofs4/dev-ioctl.c +++ b/fs/autofs4/dev-ioctl.c @@ -564,7 +564,7 @@ static int autofs_dev_ioctl_ismountpoint(struct file *fp, devid = new_encode_dev(dev); - err = have_submounts(path.dentry); + err = path_has_submounts(&path); if (follow_down_one(&path)) magic = path.dentry->d_sb->s_magic; diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c index 0f5d264..cf90d37 100644 --- a/fs/autofs4/root.c +++ b/fs/autofs4/root.c @@ -387,16 +387,16 @@ static struct vfsmount *autofs4_d_automount(struct path *path) /* * It's possible that user space hasn't removed directories * after umounting a rootless multi-mount, although it - * should. For v5 have_submounts() is sufficient to handle - * this because the leaves of the directory tree under the - * mount never trigger mounts themselves (they have an autofs - * trigger mount mounted on them). But v4 pseudo direct mounts - * do need the leaves to trigger mounts. In this case we - * have no choice but to use the list_empty() check and + * should. For v5 path_has_submounts() is sufficient to + * handle this because the leaves of the directory tree under + * the mount never trigger mounts themselves (they have an + * autofs trigger mount mounted on them). But v4 pseudo direct + * mounts do need the leaves to trigger mounts. In this case + * we have no choice but to use the list_empty() check and * require user space behave. */ if (sbi->version > 4) { - if (have_submounts(dentry)) { + if (path_has_submounts(path)) { spin_unlock(&sbi->fs_lock); goto done; } diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c index f757f87..ed05cae 100644 --- a/fs/autofs4/waitq.c +++ b/fs/autofs4/waitq.c @@ -250,8 +250,9 @@ autofs4_find_wait(struct autofs_sb_info *sbi, const struct qstr *qstr) static int validate_request(struct autofs_wait_queue **wait, struct autofs_sb_info *sbi, const struct qstr *qstr, - struct dentry *dentry, enum autofs_notify notify) + struct path *path, enum autofs_notify notify) { + struct dentry *dentry = path->dentry; struct autofs_wait_queue *wq; struct autofs_info *ino; @@ -314,6 +315,7 @@ static int validate_request(struct autofs_wait_queue **wait, */ if (notify == NFY_MOUNT) { struct dentry *new = NULL; + struct path this; int valid = 1; /* @@ -333,7 +335,9 @@ static int validate_request(struct autofs_wait_queue **wait, dentry = new; } } - if (have_submounts(dentry)) + this.mnt = path->mnt; + this.dentry = dentry; + if (path_has_submounts(&this)) valid = 0; if (new) @@ -406,7 +410,7 @@ int autofs4_wait(struct autofs_sb_info *sbi, return -EINTR; } - ret = validate_request(&wq, sbi, &qstr, dentry, notify); + ret = validate_request(&wq, sbi, &qstr, path, notify); if (ret <= 0) { if (ret != -EINTR) mutex_unlock(&sbi->wq_mutex);