提交 ba7a4c1a 编写于 作者: A Al Viro 提交者: Linus Torvalds

[PATCH] namei fixes (13/19)

In open_namei() exit_dput: we have mntput() done in the wrong order -
if nd->mnt != path.mnt we end up doing
	mntput(nd->mnt);
	nd->mnt = path.mnt;
	dput(nd->dentry);
	mntput(nd->mnt);
which drops nd->dentry too late.  Fixed by having path.mnt go first.
That allows to switch O_NOFOLLOW under if (__follow_mount(...)) back
to exit_dput, while we are at it.

Fix for early-mntput() race + equivalent transformation.
Signed-off-by: NAl Viro <viro@parcelfarce.linux.theplanet.co.uk>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 a15a3f6f
...@@ -1501,11 +1501,8 @@ int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd) ...@@ -1501,11 +1501,8 @@ int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
if (__follow_mount(&path)) { if (__follow_mount(&path)) {
error = -ELOOP; error = -ELOOP;
if (flag & O_NOFOLLOW) { if (flag & O_NOFOLLOW)
dput(path.dentry); goto exit_dput;
mntput(path.mnt);
goto exit;
}
} }
error = -ENOENT; error = -ENOENT;
if (!path.dentry->d_inode) if (!path.dentry->d_inode)
...@@ -1530,8 +1527,7 @@ int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd) ...@@ -1530,8 +1527,7 @@ int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
exit_dput: exit_dput:
dput(path.dentry); dput(path.dentry);
if (nd->mnt != path.mnt) if (nd->mnt != path.mnt)
mntput(nd->mnt); mntput(path.mnt);
nd->mnt = path.mnt;
exit: exit:
path_release(nd); path_release(nd);
return error; return error;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册