Browse files

vfs: make O_PATH file descriptors usable for 'fchdir()'

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: ольга крыжановская <>
Cc: Al Viro <>
Signed-off-by: Linus Torvalds <>
Signed-off-by: Ben Hutchings <>
  • Loading branch information...
1 parent 90f81e2 commit f6d2d473ca73cb30cf25a6940b1dff3cc78b513f @torvalds torvalds committed with bwhacks Jul 7, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 fs/open.c
@@ -396,10 +396,10 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
struct file *file;
struct inode *inode;
- int error;
+ int error, fput_needed;
error = -EBADF;
- file = fget(fd);
+ file = fget_raw_light(fd, &fput_needed);
if (!file)
goto out;
@@ -413,7 +413,7 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
if (!error)
set_fs_pwd(current->fs, &file->f_path);
- fput(file);
+ fput_light(file, fput_needed);
return error;

0 comments on commit f6d2d47

Please sign in to comment.