diff options
author | Brian Gianforcaro <bgianf@serenityos.org> | 2021-12-29 00:10:17 -0800 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-12-29 18:08:15 +0100 |
commit | bad6d50b86ae1e0a46219baf149fa0a3574af9ce (patch) | |
tree | 83d0da5a800509416d70555b751cd01244cbe98c /Kernel/Syscalls/process.cpp | |
parent | c4f60844c5d2bd51e70a621753208fe0c9392339 (diff) | |
download | serenity-bad6d50b86ae1e0a46219baf149fa0a3574af9ce.zip |
Kernel: Use Process::require_promise() instead of REQUIRE_PROMISE()
This change lays the foundation for making the require_promise return
an error hand handling the process abort outside of the syscall
implementations, to avoid cases where we would leak resources.
It also has the advantage that it makes removes a gs pointer read
to look up the current thread, then process for every syscall. We
can instead go through the Process this pointer in most cases.
Diffstat (limited to 'Kernel/Syscalls/process.cpp')
-rw-r--r-- | Kernel/Syscalls/process.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Kernel/Syscalls/process.cpp b/Kernel/Syscalls/process.cpp index f3565f7188..09bee8b794 100644 --- a/Kernel/Syscalls/process.cpp +++ b/Kernel/Syscalls/process.cpp @@ -12,21 +12,21 @@ namespace Kernel { ErrorOr<FlatPtr> Process::sys$getpid() { VERIFY_NO_PROCESS_BIG_LOCK(this) - REQUIRE_PROMISE(stdio); + require_promise(Pledge::stdio); return pid().value(); } ErrorOr<FlatPtr> Process::sys$getppid() { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) - REQUIRE_PROMISE(stdio); + require_promise(Pledge::stdio); return m_protected_values.ppid.value(); } ErrorOr<FlatPtr> Process::sys$get_process_name(Userspace<char*> buffer, size_t buffer_size) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) - REQUIRE_PROMISE(stdio); + require_promise(Pledge::stdio); if (m_name->length() + 1 > buffer_size) return ENAMETOOLONG; @@ -37,7 +37,7 @@ ErrorOr<FlatPtr> Process::sys$get_process_name(Userspace<char*> buffer, size_t b ErrorOr<FlatPtr> Process::sys$set_process_name(Userspace<const char*> user_name, size_t user_name_length) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) - REQUIRE_PROMISE(proc); + require_promise(Pledge::proc); if (user_name_length > 256) return ENAMETOOLONG; auto name = TRY(try_copy_kstring_from_user(user_name, user_name_length)); |