Commit 9c930054 authored by Xie Yongji's avatar Xie Yongji Committed by Michael S. Tsirkin

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: default avatarXie Yongji <xieyongji@bytedance.com>
Acked-by: default avatarJason Wang <jasowang@redhat.com>
Link: https://lore.kernel.org/r/20210831103634.33-4-xieyongji@bytedance.comSigned-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent 7a6b92d3
...@@ -1134,6 +1134,12 @@ int receive_fd_replace(int new_fd, struct file *file, unsigned int o_flags) ...@@ -1134,6 +1134,12 @@ int receive_fd_replace(int new_fd, struct file *file, unsigned int o_flags)
return new_fd; 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) static int ksys_dup3(unsigned int oldfd, unsigned int newfd, int flags)
{ {
int err = -EBADF; int err = -EBADF;
......
...@@ -94,6 +94,9 @@ extern void fd_install(unsigned int fd, struct file *file); ...@@ -94,6 +94,9 @@ extern void fd_install(unsigned int fd, struct file *file);
extern int __receive_fd(struct file *file, int __user *ufd, extern int __receive_fd(struct file *file, int __user *ufd,
unsigned int o_flags); unsigned int o_flags);
extern int receive_fd(struct file *file, unsigned int o_flags);
static inline int receive_fd_user(struct file *file, int __user *ufd, static inline int receive_fd_user(struct file *file, int __user *ufd,
unsigned int o_flags) unsigned int o_flags)
{ {
...@@ -101,10 +104,6 @@ static inline int receive_fd_user(struct file *file, int __user *ufd, ...@@ -101,10 +104,6 @@ static inline int receive_fd_user(struct file *file, int __user *ufd,
return -EFAULT; return -EFAULT;
return __receive_fd(file, ufd, o_flags); return __receive_fd(file, ufd, o_flags);
} }
static inline int receive_fd(struct file *file, unsigned int o_flags)
{
return __receive_fd(file, NULL, o_flags);
}
int receive_fd_replace(int new_fd, struct file *file, unsigned int o_flags); int receive_fd_replace(int new_fd, struct file *file, unsigned int o_flags);
extern void flush_delayed_fput(void); extern void flush_delayed_fput(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment