Skip to content

Commit 4e94ddf

Browse files
committed
file: remove __receive_fd()
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>
1 parent eac9189 commit 4e94ddf

6 files changed

Lines changed: 8 additions & 16 deletions

File tree

drivers/vdpa/vdpa_user/vduse_dev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd,
11571157
fput(f);
11581158
break;
11591159
}
1160-
ret = receive_fd(f, perm_to_file_flags(entry.perm));
1160+
ret = receive_fd(f, NULL, perm_to_file_flags(entry.perm));
11611161
fput(f);
11621162
break;
11631163
}

fs/file.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
12961296
}
12971297

12981298
/**
1299-
* __receive_fd() - Install received file into file descriptor table
1299+
* receive_fd() - Install received file into file descriptor table
13001300
* @file: struct file that was received from another process
13011301
* @ufd: __user pointer to write new fd number to
13021302
* @o_flags: the O_* flags to apply to the new fd entry
@@ -1310,7 +1310,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
13101310
*
13111311
* Returns newly install fd or -ve on error.
13121312
*/
1313-
int __receive_fd(struct file *file, int __user *ufd, unsigned int o_flags)
1313+
int receive_fd(struct file *file, int __user *ufd, unsigned int o_flags)
13141314
{
13151315
int new_fd;
13161316
int error;
@@ -1335,6 +1335,7 @@ int __receive_fd(struct file *file, int __user *ufd, unsigned int o_flags)
13351335
__receive_sock(file);
13361336
return new_fd;
13371337
}
1338+
EXPORT_SYMBOL_GPL(receive_fd);
13381339

13391340
int receive_fd_replace(int new_fd, struct file *file, unsigned int o_flags)
13401341
{
@@ -1350,12 +1351,6 @@ int receive_fd_replace(int new_fd, struct file *file, unsigned int o_flags)
13501351
return new_fd;
13511352
}
13521353

1353-
int receive_fd(struct file *file, unsigned int o_flags)
1354-
{
1355-
return __receive_fd(file, NULL, o_flags);
1356-
}
1357-
EXPORT_SYMBOL_GPL(receive_fd);
1358-
13591354
static int ksys_dup3(unsigned int oldfd, unsigned int newfd, int flags)
13601355
{
13611356
int err = -EBADF;

include/linux/file.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,7 @@ DEFINE_CLASS(get_unused_fd, int, if (_T >= 0) put_unused_fd(_T),
9696

9797
extern void fd_install(unsigned int fd, struct file *file);
9898

99-
extern int __receive_fd(struct file *file, int __user *ufd,
100-
unsigned int o_flags);
101-
102-
extern int receive_fd(struct file *file, unsigned int o_flags);
99+
int receive_fd(struct file *file, int __user *ufd, unsigned int o_flags);
103100

104101
int receive_fd_replace(int new_fd, struct file *file, unsigned int o_flags);
105102

include/net/scm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static inline int scm_recv_one_fd(struct file *f, int __user *ufd,
214214
{
215215
if (!ufd)
216216
return -EFAULT;
217-
return __receive_fd(f, ufd, flags);
217+
return receive_fd(f, ufd, flags);
218218
}
219219

220220
#endif /* __LINUX_NET_SCM_H */

kernel/pid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ static int pidfd_getfd(struct pid *pid, int fd)
700700
if (IS_ERR(file))
701701
return PTR_ERR(file);
702702

703-
ret = receive_fd(file, O_CLOEXEC);
703+
ret = receive_fd(file, NULL, O_CLOEXEC);
704704
fput(file);
705705

706706
return ret;

kernel/seccomp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ static void seccomp_handle_addfd(struct seccomp_kaddfd *addfd, struct seccomp_kn
10721072
*/
10731073
list_del_init(&addfd->list);
10741074
if (!addfd->setfd)
1075-
fd = receive_fd(addfd->file, addfd->flags);
1075+
fd = receive_fd(addfd->file, NULL, addfd->flags);
10761076
else
10771077
fd = receive_fd_replace(addfd->fd, addfd->file, addfd->flags);
10781078
addfd->ret = fd;

0 commit comments

Comments
 (0)