diff options
author | Brian Gianforcaro <bgianf@serenityos.org> | 2021-12-29 00:16:27 -0800 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-12-29 18:08:15 +0100 |
commit | 0f7fe1eb08851e481ee760528362b71d5124eaf5 (patch) | |
tree | 0bf4fc86e2f218a56313f314d066c35c92ec2e9e | |
parent | bad6d50b86ae1e0a46219baf149fa0a3574af9ce (diff) | |
download | serenity-0f7fe1eb08851e481ee760528362b71d5124eaf5.zip |
Kernel: Use Process::require_no_promises instead of REQUIRE_NO_PROMISES
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.
-rw-r--r-- | Kernel/Syscalls/hostname.cpp | 3 | ||||
-rw-r--r-- | Kernel/Syscalls/mount.cpp | 4 | ||||
-rw-r--r-- | Kernel/Syscalls/profiling.cpp | 6 | ||||
-rw-r--r-- | Kernel/Syscalls/purge.cpp | 2 |
4 files changed, 8 insertions, 7 deletions
diff --git a/Kernel/Syscalls/hostname.cpp b/Kernel/Syscalls/hostname.cpp index d5698467b3..ee087923fa 100644 --- a/Kernel/Syscalls/hostname.cpp +++ b/Kernel/Syscalls/hostname.cpp @@ -25,7 +25,8 @@ ErrorOr<FlatPtr> Process::sys$gethostname(Userspace<char*> buffer, size_t size) ErrorOr<FlatPtr> Process::sys$sethostname(Userspace<const char*> buffer, size_t length) { VERIFY_NO_PROCESS_BIG_LOCK(this) - REQUIRE_NO_PROMISES; + require_no_promises(); + if (!is_superuser()) return EPERM; if (length > 64) diff --git a/Kernel/Syscalls/mount.cpp b/Kernel/Syscalls/mount.cpp index 4b12e8034b..0fd05ae7a3 100644 --- a/Kernel/Syscalls/mount.cpp +++ b/Kernel/Syscalls/mount.cpp @@ -21,10 +21,10 @@ namespace Kernel { ErrorOr<FlatPtr> Process::sys$mount(Userspace<const Syscall::SC_mount_params*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) + require_no_promises(); if (!is_superuser()) return EPERM; - REQUIRE_NO_PROMISES; auto params = TRY(copy_typed_from_user(user_params)); auto source_fd = params.source_fd; @@ -120,7 +120,7 @@ ErrorOr<FlatPtr> Process::sys$umount(Userspace<const char*> user_mountpoint, siz if (!is_superuser()) return EPERM; - REQUIRE_NO_PROMISES; + require_no_promises(); auto mountpoint = TRY(get_syscall_path_argument(user_mountpoint, mountpoint_length)); auto custody = TRY(VirtualFileSystem::the().resolve_path(mountpoint->view(), current_directory())); diff --git a/Kernel/Syscalls/profiling.cpp b/Kernel/Syscalls/profiling.cpp index 5376772bc6..ed54d9ea15 100644 --- a/Kernel/Syscalls/profiling.cpp +++ b/Kernel/Syscalls/profiling.cpp @@ -19,7 +19,7 @@ u64 g_profiling_event_mask; ErrorOr<FlatPtr> Process::sys$profiling_enable(pid_t pid, u64 event_mask) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) - REQUIRE_NO_PROMISES; + require_no_promises(); if (pid == -1) { if (!is_superuser()) @@ -69,7 +69,7 @@ ErrorOr<FlatPtr> Process::sys$profiling_enable(pid_t pid, u64 event_mask) ErrorOr<FlatPtr> Process::sys$profiling_disable(pid_t pid) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) - REQUIRE_NO_PROMISES; + require_no_promises(); if (pid == -1) { if (!is_superuser()) @@ -99,7 +99,7 @@ ErrorOr<FlatPtr> Process::sys$profiling_disable(pid_t pid) ErrorOr<FlatPtr> Process::sys$profiling_free_buffer(pid_t pid) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) - REQUIRE_NO_PROMISES; + require_no_promises(); if (pid == -1) { if (!is_superuser()) diff --git a/Kernel/Syscalls/purge.cpp b/Kernel/Syscalls/purge.cpp index 0c52501fc2..722c67166f 100644 --- a/Kernel/Syscalls/purge.cpp +++ b/Kernel/Syscalls/purge.cpp @@ -15,7 +15,7 @@ namespace Kernel { ErrorOr<FlatPtr> Process::sys$purge(int mode) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) - REQUIRE_NO_PROMISES; + require_no_promises(); if (!is_superuser()) return EPERM; size_t purged_page_count = 0; |