Commit cfaf86ab authored by Ian Kent's avatar Ian Kent Committed by Al Viro

autofs: use path_is_mountpoint() to fix unreliable d_mountpoint() checks

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.

Link: http://lkml.kernel.org/r/20161011053418.27645.15241.stgit@pluto.themaw.netSigned-off-by: default avatarIan Kent <raven@themaw.net>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Omar Sandoval <osandov@osandov.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent dd36a882
...@@ -123,7 +123,7 @@ static int autofs4_dir_open(struct inode *inode, struct file *file) ...@@ -123,7 +123,7 @@ static int autofs4_dir_open(struct inode *inode, struct file *file)
* it. * it.
*/ */
spin_lock(&sbi->lookup_lock); spin_lock(&sbi->lookup_lock);
if (!d_mountpoint(dentry) && simple_empty(dentry)) { if (!path_is_mountpoint(&file->f_path) && simple_empty(dentry)) {
spin_unlock(&sbi->lookup_lock); spin_unlock(&sbi->lookup_lock);
return -ENOENT; return -ENOENT;
} }
...@@ -372,15 +372,15 @@ static struct vfsmount *autofs4_d_automount(struct path *path) ...@@ -372,15 +372,15 @@ static struct vfsmount *autofs4_d_automount(struct path *path)
/* /*
* If the dentry is a symlink it's equivalent to a directory * If the dentry is a symlink it's equivalent to a directory
* having d_mountpoint() true, so there's no need to call back * having path_is_mountpoint() true, so there's no need to call
* to the daemon. * back to the daemon.
*/ */
if (d_really_is_positive(dentry) && d_is_symlink(dentry)) { if (d_really_is_positive(dentry) && d_is_symlink(dentry)) {
spin_unlock(&sbi->fs_lock); spin_unlock(&sbi->fs_lock);
goto done; goto done;
} }
if (!d_mountpoint(dentry)) { if (!path_is_mountpoint(path)) {
/* /*
* It's possible that user space hasn't removed directories * It's possible that user space hasn't removed directories
* after umounting a rootless multi-mount, although it * after umounting a rootless multi-mount, although it
...@@ -434,7 +434,7 @@ static int autofs4_d_manage(const struct path *path, bool rcu_walk) ...@@ -434,7 +434,7 @@ static int autofs4_d_manage(const struct path *path, bool rcu_walk)
/* The daemon never waits. */ /* The daemon never waits. */
if (autofs4_oz_mode(sbi)) { if (autofs4_oz_mode(sbi)) {
if (!d_mountpoint(dentry)) if (!path_is_mountpoint(path))
return -EISDIR; return -EISDIR;
return 0; return 0;
} }
...@@ -463,7 +463,7 @@ static int autofs4_d_manage(const struct path *path, bool rcu_walk) ...@@ -463,7 +463,7 @@ static int autofs4_d_manage(const struct path *path, bool rcu_walk)
if (ino->flags & AUTOFS_INF_WANT_EXPIRE) if (ino->flags & AUTOFS_INF_WANT_EXPIRE)
return 0; return 0;
if (d_mountpoint(dentry)) if (path_is_mountpoint(path))
return 0; return 0;
inode = d_inode_rcu(dentry); inode = d_inode_rcu(dentry);
if (inode && S_ISLNK(inode->i_mode)) if (inode && S_ISLNK(inode->i_mode))
...@@ -490,7 +490,7 @@ static int autofs4_d_manage(const struct path *path, bool rcu_walk) ...@@ -490,7 +490,7 @@ static int autofs4_d_manage(const struct path *path, bool rcu_walk)
* we can avoid needless calls ->d_automount() and avoid * we can avoid needless calls ->d_automount() and avoid
* an incorrect ELOOP error return. * 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))) (d_really_is_positive(dentry) && d_is_symlink(dentry)))
status = -EISDIR; status = -EISDIR;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment