]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
fs: support O_PATH fds with FSCONFIG_SET_FD
authorChristian Brauner <brauner@kernel.org>
Mon, 10 Feb 2025 12:38:59 +0000 (13:38 +0100)
committerChristian Brauner <brauner@kernel.org>
Wed, 12 Feb 2025 09:02:10 +0000 (10:02 +0100)
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: a08557d19ef41 ("ovl: specify layers via file descriptors")
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/autofs/autofs_i.h
fs/fsopen.c

index 77c7991d89aace4ce5b0985d2a982804bbbb5eae..23cea74f9933b50ff0fee9733093338aa12b571b 100644 (file)
@@ -218,6 +218,8 @@ void autofs_clean_ino(struct autofs_info *);
 
 static inline int autofs_check_pipe(struct file *pipe)
 {
+       if (pipe->f_mode & FMODE_PATH)
+               return -EINVAL;
        if (!(pipe->f_mode & FMODE_CAN_WRITE))
                return -EINVAL;
        if (!S_ISFIFO(file_inode(pipe)->i_mode))
index 094a7f510edfecb49f532f4ada8a1ff2d0207a24..1aaf4cb2afb29e8fd73cfdf2d0676273626b0e46 100644 (file)
@@ -453,7 +453,7 @@ SYSCALL_DEFINE5(fsconfig,
        case FSCONFIG_SET_FD:
                param.type = fs_value_is_file;
                ret = -EBADF;
-               param.file = fget(aux);
+               param.file = fget_raw(aux);
                if (!param.file)
                        goto out_key;
                param.dirfd = aux;