Commit 9b77cd13 authored by Al Viro's avatar Al Viro Committed by Sasha Levin

namei: ->d_inode of a pinned dentry is stable only for positives

[ Upstream commit d4565649 ]

both do_last() and walk_component() risk picking a NULL inode out
of dentry about to become positive, *then* checking its flags and
seeing that it's not negative anymore and using (already stale by
then) value they'd fetched earlier.  Usually ends up oopsing soon
after that...

Cc: stable@vger.kernel.org # v3.13+
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarSasha Levin <sasha.levin@oracle.com>
parent 3960cde3
......@@ -1619,10 +1619,10 @@ static inline int walk_component(struct nameidata *nd, struct path *path,
if (err < 0)
goto out_err;
inode = path->dentry->d_inode;
err = -ENOENT;
if (d_is_negative(path->dentry))
goto out_path_put;
inode = path->dentry->d_inode;
}
if (should_follow_link(path->dentry, follow)) {
......@@ -3078,6 +3078,7 @@ static int do_last(struct nameidata *nd, struct path *path,
path_to_nameidata(path, nd);
goto out;
}
inode = path->dentry->d_inode;
finish_lookup:
/* we _can_ be in RCU mode here */
if (should_follow_link(path->dentry, !symlink_ok)) {
......
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