Commit a7472bab authored by Al Viro's avatar Al Viro

make nameidata_dentry_drop_rcu_maybe() always leave RCU mode

Now we have do_follow_link() guaranteed to leave without dangling RCU
and the next step will get LOOKUP_RCU logics completely out of
link_path_walk().
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent ef7562d5
...@@ -498,8 +498,15 @@ static int nameidata_dentry_drop_rcu(struct nameidata *nd, struct dentry *dentry ...@@ -498,8 +498,15 @@ static int nameidata_dentry_drop_rcu(struct nameidata *nd, struct dentry *dentry
/* Try to drop out of rcu-walk mode if we were in it, otherwise do nothing. */ /* Try to drop out of rcu-walk mode if we were in it, otherwise do nothing. */
static inline int nameidata_dentry_drop_rcu_maybe(struct nameidata *nd, struct dentry *dentry) static inline int nameidata_dentry_drop_rcu_maybe(struct nameidata *nd, struct dentry *dentry)
{ {
if (nd->flags & LOOKUP_RCU) if (nd->flags & LOOKUP_RCU) {
return nameidata_dentry_drop_rcu(nd, dentry); if (unlikely(nameidata_dentry_drop_rcu(nd, dentry))) {
nd->flags &= ~LOOKUP_RCU;
nd->root.mnt = NULL;
rcu_read_unlock();
br_read_unlock(vfsmount_lock);
return -ECHILD;
}
}
return 0; return 0;
} }
...@@ -1424,7 +1431,7 @@ static int link_path_walk(const char *name, struct nameidata *nd) ...@@ -1424,7 +1431,7 @@ static int link_path_walk(const char *name, struct nameidata *nd)
if (inode && inode->i_op->follow_link) { if (inode && inode->i_op->follow_link) {
err = do_follow_link(inode, &next, nd); err = do_follow_link(inode, &next, nd);
if (err) if (err)
goto return_err; return err;
nd->inode = nd->path.dentry->d_inode; nd->inode = nd->path.dentry->d_inode;
} else { } else {
path_to_nameidata(&next, nd); path_to_nameidata(&next, nd);
...@@ -1455,7 +1462,7 @@ static int link_path_walk(const char *name, struct nameidata *nd) ...@@ -1455,7 +1462,7 @@ static int link_path_walk(const char *name, struct nameidata *nd)
(lookup_flags & LOOKUP_FOLLOW)) { (lookup_flags & LOOKUP_FOLLOW)) {
err = do_follow_link(inode, &next, nd); err = do_follow_link(inode, &next, nd);
if (err) if (err)
goto return_err; return err;
nd->inode = nd->path.dentry->d_inode; nd->inode = nd->path.dentry->d_inode;
} else { } else {
path_to_nameidata(&next, nd); path_to_nameidata(&next, nd);
...@@ -1477,7 +1484,6 @@ static int link_path_walk(const char *name, struct nameidata *nd) ...@@ -1477,7 +1484,6 @@ static int link_path_walk(const char *name, struct nameidata *nd)
} }
if (!(nd->flags & LOOKUP_RCU)) if (!(nd->flags & LOOKUP_RCU))
path_put(&nd->path); path_put(&nd->path);
return_err:
if (nd->flags & LOOKUP_RCU) { if (nd->flags & LOOKUP_RCU) {
nd->flags &= ~LOOKUP_RCU; nd->flags &= ~LOOKUP_RCU;
nd->root.mnt = NULL; nd->root.mnt = NULL;
......
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