Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+8 -16
+1 -1
drivers/vdpa/vdpa_user/vduse_dev.c
··· 1157 1157 fput(f); 1158 1158 break; 1159 1159 } 1160 - ret = receive_fd(f, perm_to_file_flags(entry.perm)); 1160 + ret = receive_fd(f, NULL, perm_to_file_flags(entry.perm)); 1161 1161 fput(f); 1162 1162 break; 1163 1163 }
+3 -8
fs/file.c
··· 1296 1296 } 1297 1297 1298 1298 /** 1299 - * __receive_fd() - Install received file into file descriptor table 1299 + * receive_fd() - Install received file into file descriptor table 1300 1300 * @file: struct file that was received from another process 1301 1301 * @ufd: __user pointer to write new fd number to 1302 1302 * @o_flags: the O_* flags to apply to the new fd entry ··· 1310 1310 * 1311 1311 * Returns newly install fd or -ve on error. 1312 1312 */ 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) 1314 1314 { 1315 1315 int new_fd; 1316 1316 int error; ··· 1335 1335 __receive_sock(file); 1336 1336 return new_fd; 1337 1337 } 1338 + EXPORT_SYMBOL_GPL(receive_fd); 1338 1339 1339 1340 int receive_fd_replace(int new_fd, struct file *file, unsigned int o_flags) 1340 1341 { ··· 1350 1349 __receive_sock(file); 1351 1350 return new_fd; 1352 1351 } 1353 - 1354 - int receive_fd(struct file *file, unsigned int o_flags) 1355 - { 1356 - return __receive_fd(file, NULL, o_flags); 1357 - } 1358 - EXPORT_SYMBOL_GPL(receive_fd); 1359 1352 1360 1353 static int ksys_dup3(unsigned int oldfd, unsigned int newfd, int flags) 1361 1354 {
+1 -4
include/linux/file.h
··· 96 96 97 97 extern void fd_install(unsigned int fd, struct file *file); 98 98 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); 103 100 104 101 int receive_fd_replace(int new_fd, struct file *file, unsigned int o_flags); 105 102
+1 -1
include/net/scm.h
··· 214 214 { 215 215 if (!ufd) 216 216 return -EFAULT; 217 - return __receive_fd(f, ufd, flags); 217 + return receive_fd(f, ufd, flags); 218 218 } 219 219 220 220 #endif /* __LINUX_NET_SCM_H */
+1 -1
kernel/pid.c
··· 700 700 if (IS_ERR(file)) 701 701 return PTR_ERR(file); 702 702 703 - ret = receive_fd(file, O_CLOEXEC); 703 + ret = receive_fd(file, NULL, O_CLOEXEC); 704 704 fput(file); 705 705 706 706 return ret;
+1 -1
kernel/seccomp.c
··· 1072 1072 */ 1073 1073 list_del_init(&addfd->list); 1074 1074 if (!addfd->setfd) 1075 - fd = receive_fd(addfd->file, addfd->flags); 1075 + fd = receive_fd(addfd->file, NULL, addfd->flags); 1076 1076 else 1077 1077 fd = receive_fd_replace(addfd->fd, addfd->file, addfd->flags); 1078 1078 addfd->ret = fd;