diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-05 17:51:37 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-05 17:51:37 +0200 |
commit | 789db813d397f476452d2ecce140385e1600a8c7 (patch) | |
tree | 745f79aa8d3f3045983666183b307777da0325e5 /Kernel/Syscalls/socket.cpp | |
parent | d7e5768763ff39201761e7c4dfb07cd18c724344 (diff) | |
download | serenity-789db813d397f476452d2ecce140385e1600a8c7.zip |
Kernel: Use copy_typed_from_user<T> for fetching syscall parameters
Diffstat (limited to 'Kernel/Syscalls/socket.cpp')
-rw-r--r-- | Kernel/Syscalls/socket.cpp | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/Kernel/Syscalls/socket.cpp b/Kernel/Syscalls/socket.cpp index 5d7174679d..179562784d 100644 --- a/Kernel/Syscalls/socket.cpp +++ b/Kernel/Syscalls/socket.cpp @@ -79,9 +79,7 @@ KResultOr<FlatPtr> Process::sys$accept4(Userspace<const Syscall::SC_accept4_para { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) REQUIRE_PROMISE(accept); - - Syscall::SC_accept4_params params = {}; - TRY(copy_from_user(¶ms, user_params)); + auto params = TRY(copy_typed_from_user(user_params)); int accepting_socket_fd = params.sockfd; Userspace<sockaddr*> user_address((FlatPtr)params.addr); @@ -307,24 +305,21 @@ KResult Process::get_sock_or_peer_name(const Params& params) KResultOr<FlatPtr> Process::sys$getsockname(Userspace<const Syscall::SC_getsockname_params*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) - Syscall::SC_getsockname_params params = {}; - TRY(copy_from_user(¶ms, user_params)); + auto params = TRY(copy_typed_from_user(user_params)); return get_sock_or_peer_name<true>(params); } KResultOr<FlatPtr> Process::sys$getpeername(Userspace<const Syscall::SC_getpeername_params*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) - Syscall::SC_getpeername_params params = {}; - TRY(copy_from_user(¶ms, user_params)); + auto params = TRY(copy_typed_from_user(user_params)); return get_sock_or_peer_name<false>(params); } KResultOr<FlatPtr> Process::sys$getsockopt(Userspace<const Syscall::SC_getsockopt_params*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) - Syscall::SC_getsockopt_params params = {}; - TRY(copy_from_user(¶ms, user_params)); + auto params = TRY(copy_typed_from_user(user_params)); int sockfd = params.sockfd; int level = params.level; @@ -349,8 +344,8 @@ KResultOr<FlatPtr> Process::sys$getsockopt(Userspace<const Syscall::SC_getsockop KResultOr<FlatPtr> Process::sys$setsockopt(Userspace<const Syscall::SC_setsockopt_params*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) - Syscall::SC_setsockopt_params params; - TRY(copy_from_user(¶ms, user_params)); + auto params = TRY(copy_typed_from_user(user_params)); + Userspace<const void*> user_value((FlatPtr)params.value); auto description = fds().file_description(params.sockfd); if (!description) @@ -365,8 +360,7 @@ KResultOr<FlatPtr> Process::sys$setsockopt(Userspace<const Syscall::SC_setsockop KResultOr<FlatPtr> Process::sys$socketpair(Userspace<const Syscall::SC_socketpair_params*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) - Syscall::SC_socketpair_params params; - TRY(copy_from_user(¶ms, user_params)); + auto params = TRY(copy_typed_from_user(user_params)); if (params.domain != AF_LOCAL) return EINVAL; |