Skip to content

Commit 9c93005

Browse files
YongjiXiemstsirkin
authored andcommitted
file: Export receive_fd() to modules
Export receive_fd() so that some modules can use it to pass file descriptor between processes without missing any security stuffs. Signed-off-by: Xie Yongji <[email protected]> Acked-by: Jason Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 7a6b92d commit 9c93005

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

fs/file.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,12 @@ int receive_fd_replace(int new_fd, struct file *file, unsigned int o_flags)
11341134
return new_fd;
11351135
}
11361136

1137+
int receive_fd(struct file *file, unsigned int o_flags)
1138+
{
1139+
return __receive_fd(file, NULL, o_flags);
1140+
}
1141+
EXPORT_SYMBOL_GPL(receive_fd);
1142+
11371143
static int ksys_dup3(unsigned int oldfd, unsigned int newfd, int flags)
11381144
{
11391145
int err = -EBADF;

include/linux/file.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,16 @@ extern void fd_install(unsigned int fd, struct file *file);
9494

9595
extern int __receive_fd(struct file *file, int __user *ufd,
9696
unsigned int o_flags);
97+
98+
extern int receive_fd(struct file *file, unsigned int o_flags);
99+
97100
static inline int receive_fd_user(struct file *file, int __user *ufd,
98101
unsigned int o_flags)
99102
{
100103
if (ufd == NULL)
101104
return -EFAULT;
102105
return __receive_fd(file, ufd, o_flags);
103106
}
104-
static inline int receive_fd(struct file *file, unsigned int o_flags)
105-
{
106-
return __receive_fd(file, NULL, o_flags);
107-
}
108107
int receive_fd_replace(int new_fd, struct file *file, unsigned int o_flags);
109108

110109
extern void flush_delayed_fput(void);

0 commit comments

Comments
 (0)