diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-07 13:17:00 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-07 20:19:02 -0400 |
commit | 332a2e1244bd08b9e3ecd378028513396a004a24 (patch) | |
tree | 7524ffece22d3a7db3555d1df2e1d1d9370da9dd /fs/open.c | |
parent | cd6407fe220c5cf26c117457f5bcdfd6a81fbef8 (diff) |
vfs: make O_PATH file descriptors usable for 'fchdir()'
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>
Cc: stable@kernel.org # O_PATH introduced in 3.0+
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/open.c')
-rw-r--r-- | fs/open.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -397,10 +397,10 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd) | |||
397 | { | 397 | { |
398 | struct file *file; | 398 | struct file *file; |
399 | struct inode *inode; | 399 | struct inode *inode; |
400 | int error; | 400 | int error, fput_needed; |
401 | 401 | ||
402 | error = -EBADF; | 402 | error = -EBADF; |
403 | file = fget(fd); | 403 | file = fget_raw_light(fd, &fput_needed); |
404 | if (!file) | 404 | if (!file) |
405 | goto out; | 405 | goto out; |
406 | 406 | ||
@@ -414,7 +414,7 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd) | |||
414 | if (!error) | 414 | if (!error) |
415 | set_fs_pwd(current->fs, &file->f_path); | 415 | set_fs_pwd(current->fs, &file->f_path); |
416 | out_putf: | 416 | out_putf: |
417 | fput(file); | 417 | fput_light(file, fput_needed); |
418 | out: | 418 | out: |
419 | return error; | 419 | return error; |
420 | } | 420 | } |