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

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.
This commit is contained in:
Brian Gianforcaro 2021-12-29 00:10:17 -08:00 committed by Andreas Kling
parent c4f60844c5
commit bad6d50b86
61 changed files with 133 additions and 132 deletions

View file

@ -11,7 +11,7 @@ namespace Kernel {
ErrorOr<FlatPtr> Process::sys$seteuid(UserID new_euid)
{
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
REQUIRE_PROMISE(id);
require_promise(Pledge::id);
if (new_euid == (uid_t)-1)
return EINVAL;
@ -31,7 +31,7 @@ ErrorOr<FlatPtr> Process::sys$seteuid(UserID new_euid)
ErrorOr<FlatPtr> Process::sys$setegid(GroupID new_egid)
{
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
REQUIRE_PROMISE(id);
require_promise(Pledge::id);
if (new_egid == (uid_t)-1)
return EINVAL;
@ -50,7 +50,7 @@ ErrorOr<FlatPtr> Process::sys$setegid(GroupID new_egid)
ErrorOr<FlatPtr> Process::sys$setuid(UserID new_uid)
{
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
REQUIRE_PROMISE(id);
require_promise(Pledge::id);
if (new_uid == (uid_t)-1)
return EINVAL;
@ -71,7 +71,7 @@ ErrorOr<FlatPtr> Process::sys$setuid(UserID new_uid)
ErrorOr<FlatPtr> Process::sys$setgid(GroupID new_gid)
{
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
REQUIRE_PROMISE(id);
require_promise(Pledge::id);
if (new_gid == (uid_t)-1)
return EINVAL;
@ -92,7 +92,7 @@ ErrorOr<FlatPtr> Process::sys$setgid(GroupID new_gid)
ErrorOr<FlatPtr> Process::sys$setreuid(UserID new_ruid, UserID new_euid)
{
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
REQUIRE_PROMISE(id);
require_promise(Pledge::id);
if (new_ruid == (uid_t)-1)
new_ruid = uid();
@ -118,7 +118,7 @@ ErrorOr<FlatPtr> Process::sys$setreuid(UserID new_ruid, UserID new_euid)
ErrorOr<FlatPtr> Process::sys$setresuid(UserID new_ruid, UserID new_euid, UserID new_suid)
{
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
REQUIRE_PROMISE(id);
require_promise(Pledge::id);
if (new_ruid == (uid_t)-1)
new_ruid = uid();
@ -144,7 +144,7 @@ ErrorOr<FlatPtr> Process::sys$setresuid(UserID new_ruid, UserID new_euid, UserID
ErrorOr<FlatPtr> Process::sys$setresgid(GroupID new_rgid, GroupID new_egid, GroupID new_sgid)
{
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
REQUIRE_PROMISE(id);
require_promise(Pledge::id);
if (new_rgid == (gid_t)-1)
new_rgid = gid();
@ -170,7 +170,7 @@ ErrorOr<FlatPtr> Process::sys$setresgid(GroupID new_rgid, GroupID new_egid, Grou
ErrorOr<FlatPtr> Process::sys$setgroups(size_t count, Userspace<const gid_t*> user_gids)
{
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
REQUIRE_PROMISE(id);
require_promise(Pledge::id);
if (!is_superuser())
return EPERM;