From: Al Viro Date: Sun, 28 Feb 2016 00:23:16 +0000 (-0500) Subject: namei: ->d_inode of a pinned dentry is stable only for positives X-Git-Tag: v4.1.12-92~150^2~149 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=e640f78a8d1bae768328da5d35ffefa30c428472;p=users%2Fjedix%2Flinux-maple.git namei: ->d_inode of a pinned dentry is stable only for positives Orabug: 23330981 [ Upstream commit d4565649b6d6923369112758212b851adc407f0c ] 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: Al Viro Signed-off-by: Sasha Levin (cherry picked from commit 9b77cd137fd841d7a14e1c9428cfc49f4df0306e) Signed-off-by: Dan Duval --- diff --git a/fs/namei.c b/fs/namei.c index 438572278a9e3..f3cc848da8bc4 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -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 @@ retry_lookup: 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)) {