summaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorIan Kent <raven@themaw.net>2017-09-08 19:16:24 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-09-08 21:26:50 -0400
commit42f46148217865a545e129612075f3d828a2c4e4 (patch)
treef3529641b339babcc6af9eabe91782e8f9245c96 /fs/namei.c
parent33d72f3822d7ff8a9e45bd7413c811085cb87aa5 (diff)
autofs: fix AT_NO_AUTOMOUNT not being honored
The fstatat(2) and statx() calls can pass the flag AT_NO_AUTOMOUNT which is meant to clear the LOOKUP_AUTOMOUNT flag and prevent triggering of an automount by the call. But this flag is unconditionally cleared for all stat family system calls except statx(). stat family system calls have always triggered mount requests for the negative dentry case in follow_automount() which is intended but prevents the fstatat(2) and statx() AT_NO_AUTOMOUNT case from being handled. In order to handle the AT_NO_AUTOMOUNT for both system calls the negative dentry case in follow_automount() needs to be changed to return ENOENT when the LOOKUP_AUTOMOUNT flag is clear (and the other required flags are clear). AFAICT this change doesn't have any noticable side effects and may, in some use cases (although I didn't see it in testing) prevent unnecessary callbacks to the automount daemon. It's also possible that a stat family call has been made with a path that is in the process of being mounted by some other process. But stat family calls should return the automount state of the path as it is "now" so it shouldn't wait for mount completion. This is the same semantic as the positive dentry case already handled. Link: http://lkml.kernel.org/r/150216641255.11652.4204561328197919771.stgit@pluto.themaw.net Fixes: deccf497d804a4c5fca ("Make stat/lstat/fstatat pass AT_NO_AUTOMOUNT to vfs_statx()") Signed-off-by: Ian Kent <raven@themaw.net> Cc: David Howells <dhowells@redhat.com> Cc: Colin Walters <walters@redhat.com> Cc: Ondrej Holy <oholy@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/fs/namei.c b/fs/namei.c
index ddb6a7c2b3d4..1180f9c58093 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1129,9 +1129,18 @@ static int follow_automount(struct path *path, struct nameidata *nd,
1129 * of the daemon to instantiate them before they can be used. 1129 * of the daemon to instantiate them before they can be used.
1130 */ 1130 */
1131 if (!(nd->flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY | 1131 if (!(nd->flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY |
1132 LOOKUP_OPEN | LOOKUP_CREATE | LOOKUP_AUTOMOUNT)) && 1132 LOOKUP_OPEN | LOOKUP_CREATE |
1133 path->dentry->d_inode) 1133 LOOKUP_AUTOMOUNT))) {
1134 return -EISDIR; 1134 /* Positive dentry that isn't meant to trigger an
1135 * automount, EISDIR will allow it to be used,
1136 * otherwise there's no mount here "now" so return
1137 * ENOENT.
1138 */
1139 if (path->dentry->d_inode)
1140 return -EISDIR;
1141 else
1142 return -ENOENT;
1143 }
1135 1144
1136 if (path->dentry->d_sb->s_user_ns != &init_user_ns) 1145 if (path->dentry->d_sb->s_user_ns != &init_user_ns)
1137 return -EACCES; 1146 return -EACCES;