Commit 051d3812 authored by Ian Kent's avatar Ian Kent Committed by Linus Torvalds

[PATCH] autofs4: nameidata needs to be up to date for follow_link

In order to be able to trigger a mount using the follow_link inode method the
nameidata struct that is passed in needs to have the vfsmount of the autofs
trigger not its parent.

During a path walk if an autofs trigger is mounted on a dentry, when the
follow_link method is called, the nameidata struct contains the vfsmount and
mountpoint dentry of the parent mount while the dentry that is passed in is
the root of the autofs trigger mount.  I believe it is impossible to get the
vfsmount of the trigger mount, within the follow_link method, when only the
parent vfsmount and the root dentry of the trigger mount are known.

This patch updates the nameidata struct on entry to __do_follow_link if it
detects that it is out of date.  It moves the path_to_nameidata to above
__do_follow_link to facilitate calling it from there.  The dput_path is moved
as well as that seemed sensible.  No changes are made to these two functions.
Signed-off-by: default avatarIan Kent <raven@themaw.net>
Cc: Al Viro <viro@ftp.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f75ba3ad
...@@ -546,6 +546,22 @@ struct path { ...@@ -546,6 +546,22 @@ struct path {
struct dentry *dentry; struct dentry *dentry;
}; };
static inline void dput_path(struct path *path, struct nameidata *nd)
{
dput(path->dentry);
if (path->mnt != nd->mnt)
mntput(path->mnt);
}
static inline void path_to_nameidata(struct path *path, struct nameidata *nd)
{
dput(nd->dentry);
if (nd->mnt != path->mnt)
mntput(nd->mnt);
nd->mnt = path->mnt;
nd->dentry = path->dentry;
}
static __always_inline int __do_follow_link(struct path *path, struct nameidata *nd) static __always_inline int __do_follow_link(struct path *path, struct nameidata *nd)
{ {
int error; int error;
...@@ -555,8 +571,11 @@ static __always_inline int __do_follow_link(struct path *path, struct nameidata ...@@ -555,8 +571,11 @@ static __always_inline int __do_follow_link(struct path *path, struct nameidata
touch_atime(path->mnt, dentry); touch_atime(path->mnt, dentry);
nd_set_link(nd, NULL); nd_set_link(nd, NULL);
if (path->mnt == nd->mnt) if (path->mnt != nd->mnt) {
mntget(path->mnt); path_to_nameidata(path, nd);
dget(dentry);
}
mntget(path->mnt);
cookie = dentry->d_inode->i_op->follow_link(dentry, nd); cookie = dentry->d_inode->i_op->follow_link(dentry, nd);
error = PTR_ERR(cookie); error = PTR_ERR(cookie);
if (!IS_ERR(cookie)) { if (!IS_ERR(cookie)) {
...@@ -573,22 +592,6 @@ static __always_inline int __do_follow_link(struct path *path, struct nameidata ...@@ -573,22 +592,6 @@ static __always_inline int __do_follow_link(struct path *path, struct nameidata
return error; return error;
} }
static inline void dput_path(struct path *path, struct nameidata *nd)
{
dput(path->dentry);
if (path->mnt != nd->mnt)
mntput(path->mnt);
}
static inline void path_to_nameidata(struct path *path, struct nameidata *nd)
{
dput(nd->dentry);
if (nd->mnt != path->mnt)
mntput(nd->mnt);
nd->mnt = path->mnt;
nd->dentry = path->dentry;
}
/* /*
* This limits recursive symlink follows to 8, while * This limits recursive symlink follows to 8, while
* limiting consecutive symlinks to 40. * limiting consecutive symlinks to 40.
......
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