aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-07-07 13:17:00 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-07-16 11:47:49 -0400
commita2f2aa2f0c648d1dc22cf9ef4990cfc0b721add8 (patch)
treece2dc37e8a5967d545550d6aff9fb0965ee894ef
parentc148a3eb63d97d2956a906ebed2def889d07eb21 (diff)
vfs: make O_PATH file descriptors usable for 'fchdir()'
commit 332a2e1244bd08b9e3ecd378028513396a004a24 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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/open.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/open.c b/fs/open.c
index b52cf013ffa..7e18c4d6e1f 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -396,10 +396,10 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
396{ 396{
397 struct file *file; 397 struct file *file;
398 struct inode *inode; 398 struct inode *inode;
399 int error; 399 int error, fput_needed;
400 400
401 error = -EBADF; 401 error = -EBADF;
402 file = fget(fd); 402 file = fget_raw_light(fd, &fput_needed);
403 if (!file) 403 if (!file)
404 goto out; 404 goto out;
405 405
@@ -413,7 +413,7 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
413 if (!error) 413 if (!error)
414 set_fs_pwd(current->fs, &file->f_path); 414 set_fs_pwd(current->fs, &file->f_path);
415out_putf: 415out_putf:
416 fput(file); 416 fput_light(file, fput_needed);
417out: 417out:
418 return error; 418 return error;
419} 419}