From patchwork Tue Oct 11 05:34:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 9370137 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 7FBCE607FD for ; Tue, 11 Oct 2016 05:35:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E4D529A6F for ; Tue, 11 Oct 2016 05:35:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6193229A8B; Tue, 11 Oct 2016 05:35:06 +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=unavailable 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 C8FB129A6F for ; Tue, 11 Oct 2016 05:35:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752483AbcJKFeY (ORCPT ); Tue, 11 Oct 2016 01:34:24 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:46054 "EHLO out5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752452AbcJKFeW (ORCPT ); Tue, 11 Oct 2016 01:34:22 -0400 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 0D1A9208DF; Tue, 11 Oct 2016 01:34:21 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute7.internal (MEProxy); Tue, 11 Oct 2016 01:34:21 -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=7gLbjZ8hQXXzNO1tU2SvzSbqCEU=; b=IfPJ5i LsE0oR8l+4ckW6F+/X8V0fxjNrHlZEoFCj00DiRwhGdM4NBJS5nJAyKv6kMVLd1Z AZzZxSxw8Bim+997cqhT2wFGs6+PwI/+ReZqo9hyKT7TCsXFYa0usiWM3jpi5nze Cnhg8xQa+DKet1oeA3FOCqijbGpNE6Hc/XcZc= 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=7gLbjZ8hQXXzNO1 tU2SvzSbqCEU=; b=rSRsf2WlO1Q+boBdsa7OU9hFfX8U2pdZPt1GhlCacE+K7Bh DR6L8vTpb7RjBpdCXec7x5dbDcq2YzZ/rk05NrDzqmku3zaAZvmYyf6+gbTtp/XP ASFebSXAfiTVlktyywJqXcWPDemE4bcF8B5zf2elAkgYkdbXwbObDTw5UunU= X-Sasl-enc: 6720oLecVdOl/DB+M+dEdLr5pqsNMgT/AYhxWL2c3KqF 1476164060 Received: from pluto.themaw.net (203-59-161-156.dyn.iinet.net.au [203.59.161.156]) by mail.messagingengine.com (Postfix) with ESMTPA id 6E9A9F29CE; Tue, 11 Oct 2016 01:34:20 -0400 (EDT) Received: from pluto.themaw.net (localhost [127.0.0.1]) by pluto.themaw.net (Postfix) with ESMTP id 75C12A008A; Tue, 11 Oct 2016 13:34:18 +0800 (AWST) Subject: [PATCH 6/8] autofs - use path_is_mountpoint() to fix unreliable d_mountpoint() checks From: Ian Kent To: Andrew Morton Cc: autofs mailing list , Kernel Mailing List , "Eric W. Biederman" , linux-fsdevel , Omar Sandoval , Al Viro Date: Tue, 11 Oct 2016 13:34:18 +0800 Message-ID: <20161011053418.27645.15241.stgit@pluto.themaw.net> In-Reply-To: <20161011053352.27645.83962.stgit@pluto.themaw.net> References: <20161011053352.27645.83962.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_is_mountpoint() instead of d_mountpoint() so we don't get false positives when checking if a dentry is a mount point in the current namespace. Signed-off-by: Ian Kent Cc: Al Viro Cc: Eric W. Biederman Cc: Omar Sandoval --- fs/autofs4/root.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 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/root.c b/fs/autofs4/root.c index d47930ad..d7e48fe 100644 --- a/fs/autofs4/root.c +++ b/fs/autofs4/root.c @@ -107,12 +107,15 @@ static int autofs4_dir_open(struct inode *inode, struct file *file) { struct dentry *dentry = file->f_path.dentry; struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); + struct path path; pr_debug("file=%p dentry=%p %pd\n", file, dentry, dentry); if (autofs4_oz_mode(sbi)) goto out; + path = file->f_path; + /* * An empty directory in an autofs file system is always a * mount point. The daemon must have failed to mount this @@ -123,7 +126,7 @@ static int autofs4_dir_open(struct inode *inode, struct file *file) * it. */ spin_lock(&sbi->lookup_lock); - if (!d_mountpoint(dentry) && simple_empty(dentry)) { + if (!path_is_mountpoint(&path) && simple_empty(dentry)) { spin_unlock(&sbi->lookup_lock); return -ENOENT; } @@ -372,15 +375,15 @@ static struct vfsmount *autofs4_d_automount(struct path *path) /* * If the dentry is a symlink it's equivalent to a directory - * having d_mountpoint() true, so there's no need to call back - * to the daemon. + * having path_is_mountpoint() true, so there's no need to call + * back to the daemon. */ if (d_really_is_positive(dentry) && d_is_symlink(dentry)) { spin_unlock(&sbi->fs_lock); goto done; } - if (!d_mountpoint(dentry)) { + if (!path_is_mountpoint(path)) { /* * It's possible that user space hasn't removed directories * after umounting a rootless multi-mount, although it @@ -434,8 +437,13 @@ static int autofs4_d_manage(struct path *path, bool rcu_walk) /* The daemon never waits. */ if (autofs4_oz_mode(sbi)) { - if (!d_mountpoint(dentry)) - return -EISDIR; + if (rcu_walk) { + if (!path_is_mountpoint_rcu(path)) + return -EISDIR; + } else { + if (!path_is_mountpoint(path)) + return -EISDIR; + } return 0; } @@ -463,7 +471,7 @@ static int autofs4_d_manage(struct path *path, bool rcu_walk) if (ino->flags & AUTOFS_INF_WANT_EXPIRE) return 0; - if (d_mountpoint(dentry)) + if (path_is_mountpoint_rcu(path)) return 0; inode = d_inode_rcu(dentry); if (inode && S_ISLNK(inode->i_mode)) @@ -490,7 +498,7 @@ static int autofs4_d_manage(struct path *path, bool rcu_walk) * we can avoid needless calls ->d_automount() and avoid * an incorrect ELOOP error return. */ - if ((!d_mountpoint(dentry) && !simple_empty(dentry)) || + if ((!path_is_mountpoint(path) && !simple_empty(dentry)) || (d_really_is_positive(dentry) && d_is_symlink(dentry))) status = -EISDIR; }