Commit 159b0956 authored by Al Viro's avatar Al Viro

make sure that fchdir() won't accept referral points, etc.

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 85128b2b
...@@ -459,20 +459,17 @@ SYSCALL_DEFINE1(chdir, const char __user *, filename) ...@@ -459,20 +459,17 @@ SYSCALL_DEFINE1(chdir, const char __user *, filename)
SYSCALL_DEFINE1(fchdir, unsigned int, fd) SYSCALL_DEFINE1(fchdir, unsigned int, fd)
{ {
struct fd f = fdget_raw(fd); struct fd f = fdget_raw(fd);
struct inode *inode; int error;
int error = -EBADF;
error = -EBADF; error = -EBADF;
if (!f.file) if (!f.file)
goto out; goto out;
inode = file_inode(f.file);
error = -ENOTDIR; error = -ENOTDIR;
if (!S_ISDIR(inode->i_mode)) if (!d_can_lookup(f.file->f_path.dentry))
goto out_putf; goto out_putf;
error = inode_permission(inode, MAY_EXEC | MAY_CHDIR); error = inode_permission(file_inode(f.file), MAY_EXEC | MAY_CHDIR);
if (!error) if (!error)
set_fs_pwd(current->fs, &f.file->f_path); set_fs_pwd(current->fs, &f.file->f_path);
out_putf: out_putf:
......
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