Skip to content

Commit

Permalink
do_last(): ELOOP failure exit should be done after leaving RCU mode
Browse files Browse the repository at this point in the history
... or we risk seeing a bogus value of d_is_symlink() there.

Cc: [email protected] # v4.2+
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Feb 28, 2016
1 parent a7f7754 commit 5129fa4
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -3211,11 +3211,6 @@ static int do_last(struct nameidata *nd,
if (unlikely(error))
return error;

if (unlikely(d_is_symlink(path.dentry)) && !(open_flag & O_PATH)) {
path_to_nameidata(&path, nd);
return -ELOOP;
}

if ((nd->flags & LOOKUP_RCU) || nd->path.mnt != path.mnt) {
path_to_nameidata(&path, nd);
} else {
Expand All @@ -3234,6 +3229,10 @@ static int do_last(struct nameidata *nd,
return error;
}
audit_inode(nd->name, nd->path.dentry, 0);
if (unlikely(d_is_symlink(nd->path.dentry)) && !(open_flag & O_PATH)) {
error = -ELOOP;
goto out;
}
error = -EISDIR;
if ((open_flag & O_CREAT) && d_is_dir(nd->path.dentry))
goto out;
Expand Down

0 comments on commit 5129fa4

Please sign in to comment.