Commit d4565649 authored by Al Viro's avatar Al Viro

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

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>
parent c80567c8
...@@ -1743,11 +1743,11 @@ static int walk_component(struct nameidata *nd, int flags) ...@@ -1743,11 +1743,11 @@ static int walk_component(struct nameidata *nd, int flags)
if (err < 0) if (err < 0)
return err; return err;
inode = d_backing_inode(path.dentry);
seq = 0; /* we are already out of RCU mode */ seq = 0; /* we are already out of RCU mode */
err = -ENOENT; err = -ENOENT;
if (d_is_negative(path.dentry)) if (d_is_negative(path.dentry))
goto out_path_put; goto out_path_put;
inode = d_backing_inode(path.dentry);
} }
if (flags & WALK_PUT) if (flags & WALK_PUT)
...@@ -3192,12 +3192,12 @@ static int do_last(struct nameidata *nd, ...@@ -3192,12 +3192,12 @@ static int do_last(struct nameidata *nd,
return error; return error;
BUG_ON(nd->flags & LOOKUP_RCU); BUG_ON(nd->flags & LOOKUP_RCU);
inode = d_backing_inode(path.dentry);
seq = 0; /* out of RCU mode, so the value doesn't matter */ seq = 0; /* out of RCU mode, so the value doesn't matter */
if (unlikely(d_is_negative(path.dentry))) { if (unlikely(d_is_negative(path.dentry))) {
path_to_nameidata(&path, nd); path_to_nameidata(&path, nd);
return -ENOENT; return -ENOENT;
} }
inode = d_backing_inode(path.dentry);
finish_lookup: finish_lookup:
if (nd->depth) if (nd->depth)
put_link(nd); put_link(nd);
......
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