Skip to content

Commit 332a2e1

Browse files
committed
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: ольга крыжановская <[email protected]> Cc: Al Viro <[email protected]> Cc: [email protected] # O_PATH introduced in 3.0+ Signed-off-by: Linus Torvalds <[email protected]>
1 parent cd6407f commit 332a2e1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/open.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,10 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
397397
{
398398
struct file *file;
399399
struct inode *inode;
400-
int error;
400+
int error, fput_needed;
401401

402402
error = -EBADF;
403-
file = fget(fd);
403+
file = fget_raw_light(fd, &fput_needed);
404404
if (!file)
405405
goto out;
406406

@@ -414,7 +414,7 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
414414
if (!error)
415415
set_fs_pwd(current->fs, &file->f_path);
416416
out_putf:
417-
fput(file);
417+
fput_light(file, fput_needed);
418418
out:
419419
return error;
420420
}

0 commit comments

Comments
 (0)