Skip to content

Commit 0ff053b

Browse files
committed
fs: support O_PATH fds with FSCONFIG_SET_FD
Let FSCONFIG_SET_FD handle O_PATH file descriptors. This is particularly useful in the context of overlayfs where layers can be specified via file descriptors instead of paths. But userspace must currently use non-O_PATH file desriptors which is often pointless especially if the file descriptors have been created via open_tree(OPEN_TREE_CLONE). Link: https://lore.kernel.org/r/20250210-work-overlayfs-v2-1-ed2a949b674b@kernel.org Fixes: a08557d ("ovl: specify layers via file descriptors") Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 2cc0b7f commit 0ff053b

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

fs/autofs/autofs_i.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ void autofs_clean_ino(struct autofs_info *);
218218

219219
static inline int autofs_check_pipe(struct file *pipe)
220220
{
221+
if (pipe->f_mode & FMODE_PATH)
222+
return -EINVAL;
221223
if (!(pipe->f_mode & FMODE_CAN_WRITE))
222224
return -EINVAL;
223225
if (!S_ISFIFO(file_inode(pipe)->i_mode))

fs/fsopen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ SYSCALL_DEFINE5(fsconfig,
453453
case FSCONFIG_SET_FD:
454454
param.type = fs_value_is_file;
455455
ret = -EBADF;
456-
param.file = fget(aux);
456+
param.file = fget_raw(aux);
457457
if (!param.file)
458458
goto out_key;
459459
param.dirfd = aux;

0 commit comments

Comments
 (0)