aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/scm.c
diff options
context:
space:
mode:
authorKees Cook <[email protected]>2020-06-10 15:20:05 +0000
committerKees Cook <[email protected]>2020-07-13 18:03:44 +0000
commit6659061045cc93f609e100b128f30581e5f012e9 (patch)
tree2624a04d064594b211d8a800521eaa93558c1138 /net/core/scm.c
parentnet/scm: Regularize compat handling of scm_detach_fds() (diff)
downloadkernel-6659061045cc93f609e100b128f30581e5f012e9.tar.gz
kernel-6659061045cc93f609e100b128f30581e5f012e9.zip
fs: Move __scm_install_fd() to __receive_fd()
In preparation for users of the "install a received file" logic outside of net/ (pidfd and seccomp), relocate and rename __scm_install_fd() from net/core/scm.c to __receive_fd() in fs/file.c, and provide a wrapper named receive_fd_user(), as future patches will change the interface to __receive_fd(). Additionally add a comment to fd_install() as a counterpoint to how __receive_fd() interacts with fput(). Cc: Alexander Viro <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Jakub Kicinski <[email protected]> Cc: Dmitry Kadashev <[email protected]> Cc: Jens Axboe <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Sargun Dhillon <[email protected]> Cc: Ido Schimmel <[email protected]> Cc: Ioana Ciornei <[email protected]> Cc: [email protected] Cc: [email protected] Reviewed-by: Sargun Dhillon <[email protected]> Acked-by: Christian Brauner <[email protected]> Signed-off-by: Kees Cook <[email protected]>
Diffstat (limited to 'net/core/scm.c')
-rw-r--r--net/core/scm.c27
1 files changed, 1 insertions, 26 deletions
diff --git a/net/core/scm.c b/net/core/scm.c
index 44f03213dcab..67c166a7820d 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -280,31 +280,6 @@ void put_cmsg_scm_timestamping(struct msghdr *msg, struct scm_timestamping_inter
}
EXPORT_SYMBOL(put_cmsg_scm_timestamping);
-int __scm_install_fd(struct file *file, int __user *ufd, unsigned int o_flags)
-{
- int new_fd;
- int error;
-
- error = security_file_receive(file);
- if (error)
- return error;
-
- new_fd = get_unused_fd_flags(o_flags);
- if (new_fd < 0)
- return new_fd;
-
- error = put_user(new_fd, ufd);
- if (error) {
- put_unused_fd(new_fd);
- return error;
- }
-
- /* Bump the sock usage counts, if any. */
- __receive_sock(file);
- fd_install(new_fd, get_file(file));
- return 0;
-}
-
static int scm_max_fds(struct msghdr *msg)
{
if (msg->msg_controllen <= sizeof(struct cmsghdr))
@@ -331,7 +306,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
}
for (i = 0; i < fdmax; i++) {
- err = __scm_install_fd(scm->fp->fp[i], cmsg_data + i, o_flags);
+ err = receive_fd_user(scm->fp->fp[i], cmsg_data + i, o_flags);
if (err)
break;
}