Skip to content

Commit

Permalink
vfs: make O_PATH file descriptors usable for 'fchdir()'
Browse files Browse the repository at this point in the history
commit 332a2e1 upstream.

We already use them for openat() and friends, but fchdir() also wants to
be able to use O_PATH file descriptors.  This should make it comparable
to the O_SEARCH of Solaris.  In particular, O_PATH allows you to access
(not-quite-open) a directory you don't have read persmission to, only
execute permission.

Noticed during development of multithread support for ksh93.

Reported-by: ольга крыжановская <olga.kryzhanovska@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
  • Loading branch information
torvalds authored and bwhacks committed Jul 12, 2012
1 parent 90f81e2 commit f6d2d47
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fs/open.c
Expand Up @@ -396,10 +396,10 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
{ {
struct file *file; struct file *file;
struct inode *inode; struct inode *inode;
int error; int error, fput_needed;


error = -EBADF; error = -EBADF;
file = fget(fd); file = fget_raw_light(fd, &fput_needed);
if (!file) if (!file)
goto out; goto out;


Expand All @@ -413,7 +413,7 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
if (!error) if (!error)
set_fs_pwd(current->fs, &file->f_path); set_fs_pwd(current->fs, &file->f_path);
out_putf: out_putf:
fput(file); fput_light(file, fput_needed);
out: out:
return error; return error;
} }
Expand Down

0 comments on commit f6d2d47

Please sign in to comment.