diff options
author | Brian Gianforcaro <b.gianfo@gmail.com> | 2020-08-09 15:23:13 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-10 12:52:15 +0200 |
commit | 8bd9dbc220963f0cde6ec055ba833d498c234dda (patch) | |
tree | b159f6ebc46c17c8c169d19b96b42de7c43c865b | |
parent | 02660b5d60ab677463ad786002ee91eeed8a197c (diff) | |
download | serenity-8bd9dbc220963f0cde6ec055ba833d498c234dda.zip |
Kernel: Use Userspace<T> for the accept syscall
-rw-r--r-- | Kernel/Process.h | 2 | ||||
-rw-r--r-- | Kernel/Syscalls/socket.cpp | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/Kernel/Process.h b/Kernel/Process.h index 13efccd7aa..1720b2b48b 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -293,7 +293,7 @@ public: int sys$socket(int domain, int type, int protocol); int sys$bind(int sockfd, Userspace<const sockaddr*> addr, socklen_t); int sys$listen(int sockfd, int backlog); - int sys$accept(int sockfd, sockaddr*, socklen_t*); + int sys$accept(int sockfd, Userspace<sockaddr*>, Userspace<socklen_t*>); int sys$connect(int sockfd, const sockaddr*, socklen_t); int sys$shutdown(int sockfd, int how); ssize_t sys$sendto(const Syscall::SC_sendto_params*); diff --git a/Kernel/Syscalls/socket.cpp b/Kernel/Syscalls/socket.cpp index f63b870f31..b7112a25b6 100644 --- a/Kernel/Syscalls/socket.cpp +++ b/Kernel/Syscalls/socket.cpp @@ -93,7 +93,7 @@ int Process::sys$listen(int sockfd, int backlog) return socket.listen(backlog); } -int Process::sys$accept(int accepting_socket_fd, sockaddr* user_address, socklen_t* user_address_size) +int Process::sys$accept(int accepting_socket_fd, Userspace<sockaddr*> user_address, Userspace<socklen_t*> user_address_size) { REQUIRE_PROMISE(accept); @@ -101,7 +101,8 @@ int Process::sys$accept(int accepting_socket_fd, sockaddr* user_address, socklen if (user_address) { if (!validate_write_typed(user_address_size)) return -EFAULT; - copy_from_user(&address_size, user_address_size); + if (!validate_read_and_copy_typed(&address_size, user_address_size)) + return -EFAULT; if (!validate_write(user_address, address_size)) return -EFAULT; } |