1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:18:12 +00:00

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.
This commit is contained in:
Brian Gianforcaro 2021-12-29 00:16:27 -08:00 committed by Andreas Kling
parent bad6d50b86
commit 0f7fe1eb08
4 changed files with 8 additions and 7 deletions

View file

@ -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()));