From patchwork Thu Jul 22 17:59:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 113662 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o6MI0TPJ016677 for ; Thu, 22 Jul 2010 18:01:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756383Ab0GVR7a (ORCPT ); Thu, 22 Jul 2010 13:59:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32510 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756055Ab0GVR7T (ORCPT ); Thu, 22 Jul 2010 13:59:19 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6MHxGuc016872 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 22 Jul 2010 13:59:16 -0400 Received: from warthog.cambridge.redhat.com (kibblesnbits.boston.devel.redhat.com [10.16.60.12]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6MHxDHX019025 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 22 Jul 2010 13:59:15 -0400 Received: from [127.0.0.1] (helo=warthog.procyon.org.uk) by warthog.cambridge.redhat.com with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1Oc037-0001TU-4n; Thu, 22 Jul 2010 18:59:13 +0100 Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells Subject: [PATCH 6/6] Add an AT_NO_AUTOMOUNT flag to suppress terminal automount To: viro@ZenIV.linux.org.uk Cc: linux-fsdevel@vger.kernel.org, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org, David Howells Date: Thu, 22 Jul 2010 18:59:13 +0100 Message-ID: <20100722175913.5552.3905.stgit@warthog.procyon.org.uk> In-Reply-To: <20100722175847.5552.11520.stgit@warthog.procyon.org.uk> References: <20100722175847.5552.11520.stgit@warthog.procyon.org.uk> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 22 Jul 2010 18:01:16 +0000 (UTC) diff --git a/fs/namei.c b/fs/namei.c index 86068a2..056427e 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -654,7 +654,8 @@ static int follow_automount(struct path *path, int res) /* no need for dcache_lock, as serialization is taken care in * namespace.c */ -static int __follow_mount(struct path *path, unsigned nofollow) +static int __follow_mount(struct path *path, unsigned nofollow, + struct nameidata *nd) { struct vfsmount *mounted; int ret, res = 0; @@ -674,8 +675,12 @@ static int __follow_mount(struct path *path, unsigned nofollow) } if (!d_automount_point(path->dentry)) break; - if (nofollow) - return -ELOOP; + if (!(nd->flags & LOOKUP_CONTINUE)) { + if (nofollow) + return -ELOOP; + if (nd->flags & LOOKUP_NO_AUTOMOUNT) + break; + } ret = follow_automount(path, res); if (ret < 0) return ret; @@ -769,7 +774,7 @@ static int do_lookup(struct nameidata *nd, struct qstr *name, done: path->mnt = mnt; path->dentry = dentry; - ret = __follow_mount(path, 0); + ret = __follow_mount(path, 0, nd); if (unlikely(ret < 0)) path_put(path); return ret; @@ -1762,7 +1767,7 @@ static struct file *do_last(struct nameidata *nd, struct path *path, if (open_flag & O_EXCL) goto exit_dput; - error = __follow_mount(path, open_flag & O_NOFOLLOW); + error = __follow_mount(path, open_flag & O_NOFOLLOW, nd); if (error < 0) goto exit_dput; diff --git a/fs/stat.c b/fs/stat.c index c4ecd52..e4662de 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -74,11 +74,13 @@ int vfs_fstatat(int dfd, char __user *filename, struct kstat *stat, int flag) int error = -EINVAL; int lookup_flags = 0; - if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0) + if ((flag & ~AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT) != 0) goto out; if (!(flag & AT_SYMLINK_NOFOLLOW)) lookup_flags |= LOOKUP_FOLLOW; + if (flag & AT_NO_AUTOMOUNT) + lookup_flags |= LOOKUP_NO_AUTOMOUNT; error = user_path_at(dfd, filename, lookup_flags, &path); if (error) diff --git a/include/linux/fcntl.h b/include/linux/fcntl.h index afc00af..a562fa5 100644 --- a/include/linux/fcntl.h +++ b/include/linux/fcntl.h @@ -45,6 +45,7 @@ #define AT_REMOVEDIR 0x200 /* Remove directory instead of unlinking file. */ #define AT_SYMLINK_FOLLOW 0x400 /* Follow symbolic links. */ +#define AT_NO_AUTOMOUNT 0x800 /* Suppress terminal automount traversal */ #ifdef __KERNEL__ diff --git a/include/linux/namei.h b/include/linux/namei.h index 05b441d..1e1febf 100644 --- a/include/linux/namei.h +++ b/include/linux/namei.h @@ -43,12 +43,14 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND}; * - internal "there are more path components" flag * - locked when lookup done with dcache_lock held * - dentry cache is untrusted; force a real lookup + * - suppress terminal automount */ #define LOOKUP_FOLLOW 1 #define LOOKUP_DIRECTORY 2 #define LOOKUP_CONTINUE 4 #define LOOKUP_PARENT 16 #define LOOKUP_REVAL 64 +#define LOOKUP_NO_AUTOMOUNT 128 /* * Intent data */