diff --git a/Kernel/Process.h b/Kernel/Process.h index 25a88a9fd64..d24ae9188a7 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -185,11 +185,11 @@ public: int sys$yield(); int sys$sync(); int sys$beep(); - int sys$get_process_name(char* buffer, int buffer_size); - int sys$set_process_name(const char* user_name, size_t user_name_length); - int sys$watch_file(const char* path, size_t path_length); + int sys$get_process_name(Userspace buffer, size_t buffer_size); + int sys$set_process_name(Userspace user_name, size_t user_name_length); + int sys$watch_file(Userspace path, size_t path_length); int sys$dbgputch(u8); - int sys$dbgputstr(const u8*, int length); + int sys$dbgputstr(Userspace, int length); int sys$dump_backtrace(); int sys$gettid(); int sys$donate(int tid); @@ -445,8 +445,7 @@ public: [[nodiscard]] String validate_and_copy_string_from_user(Userspace user_characters, size_t size) const { - return validate_and_copy_string_from_user(user_characters.unsafe_userspace_ptr(), size); - } + return validate_and_copy_string_from_user(user_characters.unsafe_userspace_ptr(), size); } [[nodiscard]] String validate_and_copy_string_from_user(const Syscall::StringArgument&) const; diff --git a/Kernel/Syscalls/debug.cpp b/Kernel/Syscalls/debug.cpp index d17a68206b6..bd22e8b4c27 100644 --- a/Kernel/Syscalls/debug.cpp +++ b/Kernel/Syscalls/debug.cpp @@ -42,7 +42,7 @@ int Process::sys$dbgputch(u8 ch) return 0; } -int Process::sys$dbgputstr(const u8* characters, int length) +int Process::sys$dbgputstr(Userspace characters, int length) { if (!length) return 0; @@ -50,7 +50,7 @@ int Process::sys$dbgputstr(const u8* characters, int length) return -EFAULT; SmapDisabler disabler; for (int i = 0; i < length; ++i) - IO::out8(0xe9, characters[i]); + IO::out8(0xe9, characters.unsafe_userspace_ptr()[i]); return 0; } diff --git a/Kernel/Syscalls/process.cpp b/Kernel/Syscalls/process.cpp index e622a42837a..c081756785e 100644 --- a/Kernel/Syscalls/process.cpp +++ b/Kernel/Syscalls/process.cpp @@ -55,23 +55,20 @@ int Process::sys$set_process_icon(int icon_id) return 0; } -int Process::sys$get_process_name(char* buffer, int buffer_size) +int Process::sys$get_process_name(Userspace buffer, size_t buffer_size) { REQUIRE_PROMISE(stdio); - if (buffer_size <= 0) - return -EINVAL; - if (!validate_write(buffer, buffer_size)) return -EFAULT; - if (m_name.length() + 1 > (size_t)buffer_size) + if (m_name.length() + 1 > buffer_size) return -ENAMETOOLONG; copy_to_user(buffer, m_name.characters(), m_name.length() + 1); return 0; } -int Process::sys$set_process_name(const char* user_name, size_t user_name_length) +int Process::sys$set_process_name(Userspace user_name, size_t user_name_length) { REQUIRE_PROMISE(proc); if (user_name_length > 256) diff --git a/Kernel/Syscalls/watch_file.cpp b/Kernel/Syscalls/watch_file.cpp index ee87e32d087..caf8299528a 100644 --- a/Kernel/Syscalls/watch_file.cpp +++ b/Kernel/Syscalls/watch_file.cpp @@ -31,7 +31,7 @@ namespace Kernel { -int Process::sys$watch_file(const char* user_path, size_t path_length) +int Process::sys$watch_file(Userspace user_path, size_t path_length) { REQUIRE_PROMISE(rpath); auto path = get_syscall_path_argument(user_path, path_length);