summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Kernel/API/Syscall.h4
-rw-r--r--Kernel/Process.h9
-rw-r--r--Kernel/Syscalls/socket.cpp2
3 files changed, 11 insertions, 4 deletions
diff --git a/Kernel/API/Syscall.h b/Kernel/API/Syscall.h
index 0c5511166d..1a24be437c 100644
--- a/Kernel/API/Syscall.h
+++ b/Kernel/API/Syscall.h
@@ -326,8 +326,8 @@ struct SC_getsockname_params {
struct SC_getpeername_params {
int sockfd;
- sockaddr* addr;
- socklen_t* addrlen;
+ Userspace<sockaddr*> addr;
+ Userspace<socklen_t*> addrlen;
};
struct SC_futex_params {
diff --git a/Kernel/Process.h b/Kernel/Process.h
index d62d6cb21c..572b6169dc 100644
--- a/Kernel/Process.h
+++ b/Kernel/Process.h
@@ -298,7 +298,7 @@ public:
int sys$getsockopt(const Syscall::SC_getsockopt_params*);
int sys$setsockopt(const Syscall::SC_setsockopt_params*);
int sys$getsockname(const Syscall::SC_getsockname_params*);
- int sys$getpeername(const Syscall::SC_getpeername_params*);
+ int sys$getpeername(Userspace<const Syscall::SC_getpeername_params*>);
int sys$sched_setparam(pid_t pid, Userspace<const struct sched_param*>);
int sys$sched_getparam(pid_t pid, Userspace<struct sched_param*>);
int sys$create_thread(void* (*)(void*), Userspace<const Syscall::SC_create_thread_params*>);
@@ -423,6 +423,13 @@ public:
}
template<typename T>
+ [[nodiscard]] bool validate_read_and_copy_typed(T* dest, Userspace<T*> src)
+ {
+ Userspace<const T*> const_src { src.ptr() };
+ return validate_read_and_copy_typed(dest, const_src);
+ }
+
+ template<typename T>
[[nodiscard]] bool validate_write_typed(T* value, size_t count = 1)
{
Checked size = sizeof(T);
diff --git a/Kernel/Syscalls/socket.cpp b/Kernel/Syscalls/socket.cpp
index 1aaae4e9f8..1ed6730d5b 100644
--- a/Kernel/Syscalls/socket.cpp
+++ b/Kernel/Syscalls/socket.cpp
@@ -308,7 +308,7 @@ int Process::sys$getsockname(const Syscall::SC_getsockname_params* user_params)
return get_sock_or_peer_name<true>(params);
}
-int Process::sys$getpeername(const Syscall::SC_getpeername_params* user_params)
+int Process::sys$getpeername(Userspace<const Syscall::SC_getpeername_params*> user_params)
{
Syscall::SC_getpeername_params params;
if (!validate_read_and_copy_typed(&params, user_params))