History

Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull vfs fixes from Al Viro: "Fixes for mountpoint_last() bugs (by converting to use of lookup_last()) and an autofs regression fix from this cycle (caused by follow_managed() breakage introduced in barrier fixes series)" * 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: fix autofs regression caused by follow_managed() changes reimplement path_mountpoint() with less magic

Linus Torvalds committed 6 years ago

Commit 84bf3942 parents 95e20af 508c8773 files · +13 −80Browse files

Unified · Split

3 files
  1. fs/namei.c +13 −77
  2. fs/nfs/nfstrace.h +0 −2
  3. include/linux/namei.h +0 −1
fs/namei.c+13−77
@@ -1232,6 +1232,7 @@ static int follow_managed(struct path *path, struct nameidata *nd) · 1231 unmodified lines
1232 BUG_ON(!path->dentry->d_op);1232 BUG_ON(!path->dentry->d_op);
1233 BUG_ON(!path->dentry->d_op->d_manage);1233 BUG_ON(!path->dentry->d_op->d_manage);
1234 ret = path->dentry->d_op->d_manage(path, false);1234 ret = path->dentry->d_op->d_manage(path, false);
1235 flags = smp_load_acquire(&path->dentry->d_flags);
1235 if (ret < 0)1236 if (ret < 0)
1236 break;1237 break;
1237 }1238 }
@@ -1649,17 +1650,15 @@ again: · 411 unmodified lines
1649 if (IS_ERR(dentry))1650 if (IS_ERR(dentry))
1650 return dentry;1651 return dentry;
1651 if (unlikely(!d_in_lookup(dentry))) {1652 if (unlikely(!d_in_lookup(dentry))) {
1652 if (!(flags & LOOKUP_NO_REVAL)) {1653 int error = d_revalidate(dentry, flags);
1653 int error = d_revalidate(dentry, flags);1654 if (unlikely(error <= 0)) {
1654 if (unlikely(error <= 0)) {1655 if (!error) {
1655 if (!error) {1656 d_invalidate(dentry);
1656 d_invalidate(dentry);
1657 dput(dentry);
1658 goto again;
1659 }
1660 dput(dentry);1657 dput(dentry);
1661 dentry = ERR_PTR(error);1658 goto again;
1662 }1659 }
1660 dput(dentry);
1661 dentry = ERR_PTR(error);
1663 }1662 }
1664 } else {1663 } else {
1665 old = inode->i_op->lookup(inode, dentry, flags);1664 old = inode->i_op->lookup(inode, dentry, flags);
@@ -2617,72 +2616,6 @@ int user_path_at_empty(int dfd, const char __user *name, unsigned flags, · 951 unmodified lines
2617}2616}
2618EXPORT_SYMBOL(user_path_at_empty);2617EXPORT_SYMBOL(user_path_at_empty);
2619 2618
2620/**
2621 * mountpoint_last - look up last component for umount
2622 * @nd: pathwalk nameidata - currently pointing at parent directory of "last"
2623 *
2624 * This is a special lookup_last function just for umount. In this case, we
2625 * need to resolve the path without doing any revalidation.
2626 *
2627 * The nameidata should be the result of doing a LOOKUP_PARENT pathwalk. Since
2628 * mountpoints are always pinned in the dcache, their ancestors are too. Thus,
2629 * in almost all cases, this lookup will be served out of the dcache. The only
2630 * cases where it won't are if nd->last refers to a symlink or the path is
2631 * bogus and it doesn't exist.
2632 *
2633 * Returns:
2634 * -error: if there was an error during lookup. This includes -ENOENT if the
2635 * lookup found a negative dentry.
2636 *
2637 * 0: if we successfully resolved nd->last and found it to not to be a
2638 * symlink that needs to be followed.
2639 *
2640 * 1: if we successfully resolved nd->last and found it to be a symlink
2641 * that needs to be followed.
2642 */
2643static int
2644mountpoint_last(struct nameidata *nd)
2645{
2646 int error = 0;
2647 struct dentry *dir = nd->path.dentry;
2648 struct path path;
2649
2650 /* If we're in rcuwalk, drop out of it to handle last component */
2651 if (nd->flags & LOOKUP_RCU) {
2652 if (unlazy_walk(nd))
2653 return -ECHILD;
2654 }
2655
2656 nd->flags &= ~LOOKUP_PARENT;
2657
2658 if (unlikely(nd->last_type != LAST_NORM)) {
2659 error = handle_dots(nd, nd->last_type);
2660 if (error)
2661 return error;
2662 path.dentry = dget(nd->path.dentry);
2663 } else {
2664 path.dentry = d_lookup(dir, &nd->last);
2665 if (!path.dentry) {
2666 /*
2667 * No cached dentry. Mounted dentries are pinned in the
2668 * cache, so that means that this dentry is probably
2669 * a symlink or the path doesn't actually point
2670 * to a mounted dentry.
2671 */
2672 path.dentry = lookup_slow(&nd->last, dir,
2673 nd->flags | LOOKUP_NO_REVAL);
2674 if (IS_ERR(path.dentry))
2675 return PTR_ERR(path.dentry);
2676 }
2677 }
2678 if (d_flags_negative(smp_load_acquire(&path.dentry->d_flags))) {
2679 dput(path.dentry);
2680 return -ENOENT;
2681 }
2682 path.mnt = nd->path.mnt;
2683 return step_into(nd, &path, 0, d_backing_inode(path.dentry), 0);
2684}
2685
2686/**2619/**
2687 * path_mountpoint - look up a path to be umounted2620 * path_mountpoint - look up a path to be umounted
2688 * @nd: lookup context2621 * @nd: lookup context
@@ -2699,14 +2632,17 @@ path_mountpoint(struct nameidata *nd, unsigned flags, struct path *path) · 10 unmodified lines
2699 int err;2632 int err;
2700 2633
2701 while (!(err = link_path_walk(s, nd)) &&2634 while (!(err = link_path_walk(s, nd)) &&
2702 (err = mountpoint_last(nd)) > 0) {2635 (err = lookup_last(nd)) > 0) {
2703 s = trailing_symlink(nd);2636 s = trailing_symlink(nd);
2704 }2637 }
2638 if (!err && (nd->flags & LOOKUP_RCU))
2639 err = unlazy_walk(nd);
2640 if (!err)
2641 err = handle_lookup_down(nd);
2705 if (!err) {2642 if (!err) {
2706 *path = nd->path;2643 *path = nd->path;
2707 nd->path.mnt = NULL;2644 nd->path.mnt = NULL;
2708 nd->path.dentry = NULL;2645 nd->path.dentry = NULL;
2709 follow_mount(path);
2710 }2646 }
2711 terminate_walk(nd);2647 terminate_walk(nd);
2712 return err;2648 return err;
fs/nfs/nfstrace.h+0−2
@@ -206,7 +206,6 @@ TRACE_DEFINE_ENUM(LOOKUP_AUTOMOUNT); · 205 unmodified lines
206TRACE_DEFINE_ENUM(LOOKUP_PARENT);206TRACE_DEFINE_ENUM(LOOKUP_PARENT);
207TRACE_DEFINE_ENUM(LOOKUP_REVAL);207TRACE_DEFINE_ENUM(LOOKUP_REVAL);
208TRACE_DEFINE_ENUM(LOOKUP_RCU);208TRACE_DEFINE_ENUM(LOOKUP_RCU);
209TRACE_DEFINE_ENUM(LOOKUP_NO_REVAL);
210TRACE_DEFINE_ENUM(LOOKUP_OPEN);209TRACE_DEFINE_ENUM(LOOKUP_OPEN);
211TRACE_DEFINE_ENUM(LOOKUP_CREATE);210TRACE_DEFINE_ENUM(LOOKUP_CREATE);
212TRACE_DEFINE_ENUM(LOOKUP_EXCL);211TRACE_DEFINE_ENUM(LOOKUP_EXCL);
@@ -224,7 +223,6 @@ TRACE_DEFINE_ENUM(LOOKUP_DOWN); · 11 unmodified lines
224 { LOOKUP_PARENT, "PARENT" }, \223 { LOOKUP_PARENT, "PARENT" }, \
225 { LOOKUP_REVAL, "REVAL" }, \224 { LOOKUP_REVAL, "REVAL" }, \
226 { LOOKUP_RCU, "RCU" }, \225 { LOOKUP_RCU, "RCU" }, \
227 { LOOKUP_NO_REVAL, "NO_REVAL" }, \
228 { LOOKUP_OPEN, "OPEN" }, \226 { LOOKUP_OPEN, "OPEN" }, \
229 { LOOKUP_CREATE, "CREATE" }, \227 { LOOKUP_CREATE, "CREATE" }, \
230 { LOOKUP_EXCL, "EXCL" }, \228 { LOOKUP_EXCL, "EXCL" }, \
include/linux/namei.h+0−1
@@ -34,7 +34,6 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND}; · 33 unmodified lines
34 34
35/* internal use only */35/* internal use only */
36#define LOOKUP_PARENT 0x001036#define LOOKUP_PARENT 0x0010
37#define LOOKUP_NO_REVAL 0x0080
38#define LOOKUP_JUMPED 0x100037#define LOOKUP_JUMPED 0x1000
39#define LOOKUP_ROOT 0x200038#define LOOKUP_ROOT 0x2000
40#define LOOKUP_ROOT_GRABBED 0x000839#define LOOKUP_ROOT_GRABBED 0x0008

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t