From: Xie Yongji <xieyongji@bytedance.com>
To: christian.brauner@ubuntu.com, hch@infradead.org,
gregkh@linuxfoundation.org, arve@android.com, tkjos@android.com,
maco@android.com, joel@joelfernandes.org, hridya@google.com,
surenb@google.com, viro@zeniv.linux.org.uk, sargun@sargun.me,
keescook@chromium.org, jasowang@redhat.com
Cc: devel@driverdev.osuosl.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH 1/2] file: Export receive_fd() to modules
Date: Thu, 1 Apr 2021 17:09:31 +0800 [thread overview]
Message-ID: <20210401090932.121-2-xieyongji@bytedance.com> (raw)
In-Reply-To: <20210401090932.121-1-xieyongji@bytedance.com>
Export receive_fd() so that some modules can use
it to pass file descriptor across processes without
missing any security stuffs.
Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
---
fs/file.c | 6 ++++++
include/linux/file.h | 7 +++----
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/fs/file.c b/fs/file.c
index 56986e55befa..2a80c6c3e147 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -1107,6 +1107,12 @@ 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(receive_fd);
+
static int ksys_dup3(unsigned int oldfd, unsigned int newfd, int flags)
{
int err = -EBADF;
diff --git a/include/linux/file.h b/include/linux/file.h
index 2de2e4613d7b..51e830b4fe3a 100644
--- a/include/linux/file.h
+++ b/include/linux/file.h
@@ -94,6 +94,9 @@ 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);
+
static inline int receive_fd_user(struct file *file, int __user *ufd,
unsigned int o_flags)
{
@@ -101,10 +104,6 @@ static inline int receive_fd_user(struct file *file, int __user *ufd,
return -EFAULT;
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);
extern void flush_delayed_fput(void);
--
2.11.0
next prev parent reply other threads:[~2021-04-01 9:10 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-01 9:09 [PATCH 0/2] Export receive_fd() to modules and do some cleanups Xie Yongji
2021-04-01 9:09 ` Xie Yongji [this message]
2021-04-01 9:52 ` [PATCH 1/2] file: Export receive_fd() to modules Greg KH
2021-04-01 10:24 ` Yongji Xie
2021-04-01 9:09 ` [PATCH 2/2] binder: Use receive_fd() to receive file from another process Xie Yongji
2021-04-01 9:54 ` Greg KH
2021-04-01 10:12 ` Yongji Xie
2021-04-01 10:42 ` Greg KH
2021-04-01 11:29 ` Yongji Xie
2021-04-01 11:33 ` Greg KH
2021-04-01 12:28 ` Yongji Xie
2021-04-01 14:09 ` Greg KH
2021-04-02 9:12 ` Kees Cook
2021-04-01 10:40 ` Christian Brauner
2021-04-01 11:11 ` Yongji Xie
2021-04-16 5:19 ` Al Viro
2021-04-16 5:55 ` Al Viro
2021-04-16 13:42 ` Christian Brauner
2021-04-16 14:09 ` Al Viro
2021-04-16 15:13 ` Christian Brauner
2021-04-16 15:35 ` Al Viro
2021-04-16 15:58 ` Christian Brauner
2021-04-16 16:00 ` Christian Brauner
2021-04-16 17:00 ` Al Viro
2021-04-16 17:30 ` Al Viro
2021-04-17 1:30 ` Al Viro
2021-04-01 9:53 ` [PATCH 0/2] Export receive_fd() to modules and do some cleanups Greg KH
2021-04-01 10:00 ` Yongji Xie
2021-04-01 10:20 ` Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210401090932.121-2-xieyongji@bytedance.com \
--to=xieyongji@bytedance.com \
--cc=arve@android.com \
--cc=christian.brauner@ubuntu.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=hch@infradead.org \
--cc=hridya@google.com \
--cc=jasowang@redhat.com \
--cc=joel@joelfernandes.org \
--cc=keescook@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=maco@android.com \
--cc=sargun@sargun.me \
--cc=surenb@google.com \
--cc=tkjos@android.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).