diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2017-04-15 15:58:56 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2017-04-21 14:05:35 -0400 |
commit | 159b095628851966b5fbf2637b0c40709911ca88 (patch) | |
tree | bdf6e9eb19f8636413da28411d1099a507b2c02c /fs | |
parent | 85128b2be6738fe36c224995c5ee80fe80fbb1b5 (diff) | |
download | linux-159b095628851966b5fbf2637b0c40709911ca88.tar.gz linux-159b095628851966b5fbf2637b0c40709911ca88.tar.bz2 linux-159b095628851966b5fbf2637b0c40709911ca88.zip |
make sure that fchdir() won't accept referral points, etc.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/open.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/fs/open.c b/fs/open.c index 949cef29c3bb..9f4bbd7cc51a 100644 --- a/fs/open.c +++ b/fs/open.c @@ -459,20 +459,17 @@ out: SYSCALL_DEFINE1(fchdir, unsigned int, fd) { struct fd f = fdget_raw(fd); - struct inode *inode; - int error = -EBADF; + int error; error = -EBADF; if (!f.file) goto out; - inode = file_inode(f.file); - error = -ENOTDIR; - if (!S_ISDIR(inode->i_mode)) + if (!d_can_lookup(f.file->f_path.dentry)) goto out_putf; - error = inode_permission(inode, MAY_EXEC | MAY_CHDIR); + error = inode_permission(file_inode(f.file), MAY_EXEC | MAY_CHDIR); if (!error) set_fs_pwd(current->fs, &f.file->f_path); out_putf: |