From: David Howells <dhowells@redhat.com>
To: viro@ftp.linux.org.uk, jmoyer@redhat.com
Cc: linux-fs@vger.kernel.org, autofs@linux.kernel.org,
linux-kernel@vger.kernel.org, linux-afs@lists.infradead.org,
linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org,
David Howells <dhowells@redhat.com>, Ian Kent <raven@themaw.net>
Subject: [PATCH 06/17] Add an AT_NO_AUTOMOUNT flag to suppress terminal automount
Date: Thu, 30 Sep 2010 19:15:26 +0100 [thread overview]
Message-ID: <20100930181526.30939.22704.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <20100930181455.30939.53914.stgit@warthog.procyon.org.uk>
Add an AT_NO_AUTOMOUNT flag to suppress terminal automounting of directories
with follow_link semantics. This can be used by fstatat() users to permit the
gathering of attributes on an automount point and also prevent
mass-automounting of a directory of automount points by ls.
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Ian Kent <raven@themaw.net>
---
fs/namei.c | 6 ++++++
fs/stat.c | 4 +++-
include/linux/fcntl.h | 1 +
include/linux/namei.h | 2 ++
4 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/fs/namei.c b/fs/namei.c
index 86421f9..74bce3a 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -625,6 +625,12 @@ static int follow_automount(struct path *path, unsigned flags,
if (!path->dentry->d_op || !path->dentry->d_op->d_automount)
return -EREMOTE;
+ /* We don't want to mount if someone supplied AT_NO_AUTOMOUNT
+ * and this is the terminal part of the path.
+ */
+ if ((flags & LOOKUP_NO_AUTOMOUNT) && !(flags & LOOKUP_CONTINUE))
+ return -EXDEV; /* we actually want to stop here */
+
/* We want to mount if someone is trying to open/create a file of any
* type under the mountpoint, wants to traverse through the mountpoint
* or wants to open the mounted directory.
diff --git a/fs/stat.c b/fs/stat.c
index 12e90e2..d5c61cf 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -75,11 +75,13 @@ int vfs_fstatat(int dfd, const char __user *filename, struct kstat *stat,
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
*/
next prev parent reply other threads:[~2010-09-30 18:15 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-30 18:14 [PATCH 00/17] Introduce automounter dentry ops David Howells
2010-09-30 18:15 ` [PATCH 01/17] Add a dentry op to handle automounting rather than abusing follow_link() David Howells
2010-09-30 18:15 ` [PATCH 02/17] AFS: Use d_automount() " David Howells
2010-09-30 18:15 ` [PATCH 03/17] NFS: " David Howells
2010-09-30 18:15 ` [PATCH 04/17] CIFS: " David Howells
2010-09-30 18:15 ` [PATCH 05/17] Remove the automount through follow_link() kludge code from pathwalk David Howells
2010-10-08 23:41 ` Valerie Aurora
2010-10-10 1:16 ` Ian Kent
2010-09-30 18:15 ` David Howells [this message]
2010-10-01 8:55 ` [PATCH 06/17] Add an AT_NO_AUTOMOUNT flag to suppress terminal automount Ian Kent
2010-09-30 18:15 ` [PATCH 07/17] Make dentry::d_mounted into a more general field for special function dirs David Howells
2010-10-08 23:57 ` Valerie Aurora
2010-09-30 18:15 ` [PATCH 08/17] Make follow_down() handle d_manage() David Howells
[not found] ` <20100930181536.30939.6776.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
2010-10-09 0:28 ` Valerie Aurora
2010-09-30 18:15 ` [PATCH 09/17] autofs4: add d_automount() dentry operation David Howells
2010-09-30 18:15 ` [PATCH 10/17] autofs4: add d_manage() " David Howells
2010-09-30 18:15 ` [PATCH 11/17] autofs4: removed unused code David Howells
2010-09-30 18:15 ` [PATCH 12/17] autofs4: cleanup inode operations David Howells
2010-09-30 18:16 ` [PATCH 13/17] autofs4: cleanup dentry operations David Howells
2010-09-30 18:16 ` [PATCH 14/17] autofs4: cleanup autofs4_free_ino() David Howells
2010-09-30 18:16 ` [PATCH 15/17] autofs4 - fix wait validation David Howells
2010-09-30 18:16 ` [PATCH 16/17] autofs4 - add v4 pseudo direct mount support David Howells
2010-09-30 18:16 ` [PATCH 17/17] autofs4 - bump version David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100930181526.30939.22704.stgit@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=autofs@linux.kernel.org \
--cc=jmoyer@redhat.com \
--cc=linux-afs@lists.infradead.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-fs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=raven@themaw.net \
--cc=viro@ftp.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).