diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2016-02-27 19:37:37 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2016-02-27 19:37:37 -0500 |
commit | 5129fa482b16615fd4464d2f5d23acb1b7056c66 (patch) | |
tree | 1dc9ec48abbcaa87be322a795ca661444ec52acd | |
parent | a7f775428b8f5808815c0e3004020cedb94cbe3b (diff) |
do_last(): ELOOP failure exit should be done after leaving RCU mode
... or we risk seeing a bogus value of d_is_symlink() there.
Cc: stable@vger.kernel.org # v4.2+
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/namei.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/fs/namei.c b/fs/namei.c index 65a0e9d1ea48..9c590e0f66e9 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -3211,11 +3211,6 @@ finish_lookup: | |||
3211 | if (unlikely(error)) | 3211 | if (unlikely(error)) |
3212 | return error; | 3212 | return error; |
3213 | 3213 | ||
3214 | if (unlikely(d_is_symlink(path.dentry)) && !(open_flag & O_PATH)) { | ||
3215 | path_to_nameidata(&path, nd); | ||
3216 | return -ELOOP; | ||
3217 | } | ||
3218 | |||
3219 | if ((nd->flags & LOOKUP_RCU) || nd->path.mnt != path.mnt) { | 3214 | if ((nd->flags & LOOKUP_RCU) || nd->path.mnt != path.mnt) { |
3220 | path_to_nameidata(&path, nd); | 3215 | path_to_nameidata(&path, nd); |
3221 | } else { | 3216 | } else { |
@@ -3234,6 +3229,10 @@ finish_open: | |||
3234 | return error; | 3229 | return error; |
3235 | } | 3230 | } |
3236 | audit_inode(nd->name, nd->path.dentry, 0); | 3231 | audit_inode(nd->name, nd->path.dentry, 0); |
3232 | if (unlikely(d_is_symlink(nd->path.dentry)) && !(open_flag & O_PATH)) { | ||
3233 | error = -ELOOP; | ||
3234 | goto out; | ||
3235 | } | ||
3237 | error = -EISDIR; | 3236 | error = -EISDIR; |
3238 | if ((open_flag & O_CREAT) && d_is_dir(nd->path.dentry)) | 3237 | if ((open_flag & O_CREAT) && d_is_dir(nd->path.dentry)) |
3239 | goto out; | 3238 | goto out; |