From: David Howells <dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: viro-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org
Cc: dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
raven-PKsaG3nR2I+sTnJN9+BGXg@public.gmane.org,
linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-afs-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 6/6] Add an AT_NO_AUTOMOUNT flag to suppress terminal automount [ver #2]
Date: Fri, 23 Jul 2010 16:11:05 +0100 [thread overview]
Message-ID: <17789.1279897865@redhat.com> (raw)
In-Reply-To: <20100722175913.5552.3905.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
This is an update required because the first patch in the series was also
altered in the same area.
David
---
From: David Howells <dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: [PATCH] Add an AT_NO_AUTOMOUNT flag to suppress terminal automount
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-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
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 f2910b7..c154112 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -629,6 +629,12 @@ static int follow_automount(struct path *path, unsigned flags, int res)
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 c4ecd52..bae6fa2 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
*/
prev parent reply other threads:[~2010-07-23 15:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-22 17:58 [PATCH 1/6] Add a dentry op to handle automounting rather than abusing follow_link() David Howells
2010-07-22 17:58 ` [PATCH 2/6] AFS: Use d_automount() " David Howells
[not found] ` <20100722175847.5552.11520.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
2010-07-22 17:58 ` [PATCH 3/6] NFS: " David Howells
2010-07-22 17:59 ` [PATCH 4/6] CIFS: " David Howells
2010-07-23 15:09 ` [PATCH 1/6] Add a dentry op to handle automounting rather than abusing follow_link() [ver #2] David Howells
[not found] ` <17723.1279897759-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-07-24 4:11 ` Ian Kent
2010-07-26 14:19 ` David Howells
[not found] ` <9168.1280153997-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-07-26 15:22 ` Ian Kent
2010-07-26 15:54 ` David Howells
[not found] ` <30118.1280159695-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-07-27 3:43 ` Ian Kent
2010-07-27 8:48 ` David Howells
[not found] ` <12883.1280220521-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-07-27 12:51 ` Ian Kent
2010-07-22 17:59 ` [PATCH 5/6] Remove the automount through follow_link() kludge code from pathwalk David Howells
2010-07-22 17:59 ` [PATCH 6/6] Add an AT_NO_AUTOMOUNT flag to suppress terminal automount David Howells
[not found] ` <20100722175913.5552.3905.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
2010-07-22 18:01 ` David Howells
2010-07-23 15:11 ` David Howells [this message]
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=17789.1279897865@redhat.com \
--to=dhowells-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=linux-afs-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=raven-PKsaG3nR2I+sTnJN9+BGXg@public.gmane.org \
--cc=viro-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org \
/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).