diff options
author | Ian Kent <ikent@redhat.com> | 2016-11-23 16:03:42 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2016-12-03 20:51:48 -0500 |
commit | cfaf86ab6ccdf0acf47ebe474a4a844114bc0e10 (patch) | |
tree | d78bb1593f84e1948f86c5323fcdb888e9991b16 | |
parent | dd36a882e7ade2c642f8711426ad8e4b7009aaae (diff) |
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.net
Signed-off-by: Ian 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/autofs4/root.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c index 0e9881552881..9355608cb495 100644 --- a/fs/autofs4/root.c +++ b/fs/autofs4/root.c | |||
@@ -123,7 +123,7 @@ static int autofs4_dir_open(struct inode *inode, struct file *file) | |||
123 | * it. | 123 | * it. |
124 | */ | 124 | */ |
125 | spin_lock(&sbi->lookup_lock); | 125 | spin_lock(&sbi->lookup_lock); |
126 | if (!d_mountpoint(dentry) && simple_empty(dentry)) { | 126 | if (!path_is_mountpoint(&file->f_path) && simple_empty(dentry)) { |
127 | spin_unlock(&sbi->lookup_lock); | 127 | spin_unlock(&sbi->lookup_lock); |
128 | return -ENOENT; | 128 | return -ENOENT; |
129 | } | 129 | } |
@@ -372,15 +372,15 @@ static struct vfsmount *autofs4_d_automount(struct path *path) | |||
372 | 372 | ||
373 | /* | 373 | /* |
374 | * If the dentry is a symlink it's equivalent to a directory | 374 | * If the dentry is a symlink it's equivalent to a directory |
375 | * having d_mountpoint() true, so there's no need to call back | 375 | * having path_is_mountpoint() true, so there's no need to call |
376 | * to the daemon. | 376 | * back to the daemon. |
377 | */ | 377 | */ |
378 | if (d_really_is_positive(dentry) && d_is_symlink(dentry)) { | 378 | if (d_really_is_positive(dentry) && d_is_symlink(dentry)) { |
379 | spin_unlock(&sbi->fs_lock); | 379 | spin_unlock(&sbi->fs_lock); |
380 | goto done; | 380 | goto done; |
381 | } | 381 | } |
382 | 382 | ||
383 | if (!d_mountpoint(dentry)) { | 383 | if (!path_is_mountpoint(path)) { |
384 | /* | 384 | /* |
385 | * It's possible that user space hasn't removed directories | 385 | * It's possible that user space hasn't removed directories |
386 | * after umounting a rootless multi-mount, although it | 386 | * 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 | 434 | ||
435 | /* The daemon never waits. */ | 435 | /* The daemon never waits. */ |
436 | if (autofs4_oz_mode(sbi)) { | 436 | if (autofs4_oz_mode(sbi)) { |
437 | if (!d_mountpoint(dentry)) | 437 | if (!path_is_mountpoint(path)) |
438 | return -EISDIR; | 438 | return -EISDIR; |
439 | return 0; | 439 | return 0; |
440 | } | 440 | } |
@@ -463,7 +463,7 @@ static int autofs4_d_manage(const struct path *path, bool rcu_walk) | |||
463 | 463 | ||
464 | if (ino->flags & AUTOFS_INF_WANT_EXPIRE) | 464 | if (ino->flags & AUTOFS_INF_WANT_EXPIRE) |
465 | return 0; | 465 | return 0; |
466 | if (d_mountpoint(dentry)) | 466 | if (path_is_mountpoint(path)) |
467 | return 0; | 467 | return 0; |
468 | inode = d_inode_rcu(dentry); | 468 | inode = d_inode_rcu(dentry); |
469 | if (inode && S_ISLNK(inode->i_mode)) | 469 | if (inode && S_ISLNK(inode->i_mode)) |
@@ -490,7 +490,7 @@ static int autofs4_d_manage(const struct path *path, bool rcu_walk) | |||
490 | * we can avoid needless calls ->d_automount() and avoid | 490 | * we can avoid needless calls ->d_automount() and avoid |
491 | * an incorrect ELOOP error return. | 491 | * an incorrect ELOOP error return. |
492 | */ | 492 | */ |
493 | if ((!d_mountpoint(dentry) && !simple_empty(dentry)) || | 493 | if ((!path_is_mountpoint(path) && !simple_empty(dentry)) || |
494 | (d_really_is_positive(dentry) && d_is_symlink(dentry))) | 494 | (d_really_is_positive(dentry) && d_is_symlink(dentry))) |
495 | status = -EISDIR; | 495 | status = -EISDIR; |
496 | } | 496 | } |