]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
file: remove __receive_fd()
authorChristian Brauner <brauner@kernel.org>
Thu, 30 Nov 2023 12:49:11 +0000 (13:49 +0100)
committerChristian Brauner <brauner@kernel.org>
Tue, 12 Dec 2023 13:24:14 +0000 (14:24 +0100)
Honestly, there's little value in having a helper with and without that
int __user *ufd argument. It's just messy and doesn't really give us
anything. Just expose receive_fd() with that argument and get rid of
that helper.

Link: https://lore.kernel.org/r/20231130-vfs-files-fixes-v1-5-e73ca6f4ea83@kernel.org
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Christian Brauner <brauner@kernel.org>
drivers/vdpa/vdpa_user/vduse_dev.c
fs/file.c
include/linux/file.h
include/net/scm.h
kernel/pid.c
kernel/seccomp.c

index 0ddd4b8abecb30ed4a30bc1aaf5345e9b175208f..fafd4610b1857a9edae74acc6fea28de9b36b8b5 100644 (file)
@@ -1157,7 +1157,7 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd,
                        fput(f);
                        break;
                }
-               ret = receive_fd(f, perm_to_file_flags(entry.perm));
+               ret = receive_fd(f, NULL, perm_to_file_flags(entry.perm));
                fput(f);
                break;
        }
index c8eaa0b29a08db3a4cadd51c28bbf5c2a763ec7e..3b683b9101d841b65f568e946915acc565e8b90a 100644 (file)
--- a/fs/file.c
+++ b/fs/file.c
@@ -1296,7 +1296,7 @@ out_unlock:
 }
 
 /**
- * __receive_fd() - Install received file into file descriptor table
+ * receive_fd() - Install received file into file descriptor table
  * @file: struct file that was received from another process
  * @ufd: __user pointer to write new fd number to
  * @o_flags: the O_* flags to apply to the new fd entry
@@ -1310,7 +1310,7 @@ out_unlock:
  *
  * Returns newly install fd or -ve on error.
  */
-int __receive_fd(struct file *file, int __user *ufd, unsigned int o_flags)
+int receive_fd(struct file *file, int __user *ufd, unsigned int o_flags)
 {
        int new_fd;
        int error;
@@ -1335,6 +1335,7 @@ int __receive_fd(struct file *file, int __user *ufd, unsigned int o_flags)
        __receive_sock(file);
        return new_fd;
 }
+EXPORT_SYMBOL_GPL(receive_fd);
 
 int receive_fd_replace(int new_fd, struct file *file, unsigned int o_flags)
 {
@@ -1350,12 +1351,6 @@ int receive_fd_replace(int new_fd, struct file *file, unsigned int o_flags)
        return new_fd;
 }
 
-int receive_fd(struct file *file, unsigned int o_flags)
-{
-       return __receive_fd(file, NULL, o_flags);
-}
-EXPORT_SYMBOL_GPL(receive_fd);
-
 static int ksys_dup3(unsigned int oldfd, unsigned int newfd, int flags)
 {
        int err = -EBADF;
index c0d5219c28528ab1fc82e7c87606c58e8e189551..6834a29338c43c3370640a3432c98b606313cfb3 100644 (file)
@@ -96,10 +96,7 @@ DEFINE_CLASS(get_unused_fd, int, if (_T >= 0) put_unused_fd(_T),
 
 extern void fd_install(unsigned int fd, struct file *file);
 
-extern int __receive_fd(struct file *file, int __user *ufd,
-                       unsigned int o_flags);
-
-extern int receive_fd(struct file *file, unsigned int o_flags);
+int receive_fd(struct file *file, int __user *ufd, unsigned int o_flags);
 
 int receive_fd_replace(int new_fd, struct file *file, unsigned int o_flags);
 
index 8aae2468bae0d3b68a4ea21d245786ea3ee852c9..cf68acec4d70a5f8c0a021a0635e6d3436e93a1e 100644 (file)
@@ -214,7 +214,7 @@ static inline int scm_recv_one_fd(struct file *f, int __user *ufd,
 {
        if (!ufd)
                return -EFAULT;
-       return __receive_fd(f, ufd, flags);
+       return receive_fd(f, ufd, flags);
 }
 
 #endif /* __LINUX_NET_SCM_H */
index 6500ef956f2f885793833e160891b4f441acd104..b52b108654541545797c19aa0bf68c735442bbac 100644 (file)
@@ -700,7 +700,7 @@ static int pidfd_getfd(struct pid *pid, int fd)
        if (IS_ERR(file))
                return PTR_ERR(file);
 
-       ret = receive_fd(file, O_CLOEXEC);
+       ret = receive_fd(file, NULL, O_CLOEXEC);
        fput(file);
 
        return ret;
index 255999ba9190a6f2dfac0fd8bbc3a37cfae2e60a..aca7b437882e98d81d66a5cd2d224b02be0d7fd3 100644 (file)
@@ -1072,7 +1072,7 @@ static void seccomp_handle_addfd(struct seccomp_kaddfd *addfd, struct seccomp_kn
         */
        list_del_init(&addfd->list);
        if (!addfd->setfd)
-               fd = receive_fd(addfd->file, addfd->flags);
+               fd = receive_fd(addfd->file, NULL, addfd->flags);
        else
                fd = receive_fd_replace(addfd->fd, addfd->file, addfd->flags);
        addfd->ret = fd;