From 998c1152efa116da5fabf89363d178c8fb729d77 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 20 Aug 2022 18:36:47 +0200 Subject: [PATCH] Kernel: Mark syscalls that get/set user/group ID as not needing big lock Now that these operate on the neatly atomic and immutable Credentials object, they should no longer require the process big lock for synchronization. :^) --- Kernel/API/Syscall.h | 30 +++++++++++++++--------------- Kernel/Syscalls/getuid.cpp | 14 +++++++------- Kernel/Syscalls/setuid.cpp | 16 ++++++++-------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Kernel/API/Syscall.h b/Kernel/API/Syscall.h index 389f91d3e4a..cf53d789f9b 100644 --- a/Kernel/API/Syscall.h +++ b/Kernel/API/Syscall.h @@ -82,10 +82,10 @@ enum class NeedsBigProcessLock { S(get_stack_bounds, NeedsBigProcessLock::No) \ S(get_thread_name, NeedsBigProcessLock::Yes) \ S(getcwd, NeedsBigProcessLock::No) \ - S(getegid, NeedsBigProcessLock::Yes) \ - S(geteuid, NeedsBigProcessLock::Yes) \ - S(getgid, NeedsBigProcessLock::Yes) \ - S(getgroups, NeedsBigProcessLock::Yes) \ + S(getegid, NeedsBigProcessLock::No) \ + S(geteuid, NeedsBigProcessLock::No) \ + S(getgid, NeedsBigProcessLock::No) \ + S(getgroups, NeedsBigProcessLock::No) \ S(gethostname, NeedsBigProcessLock::No) \ S(getkeymap, NeedsBigProcessLock::No) \ S(getpeername, NeedsBigProcessLock::Yes) \ @@ -94,14 +94,14 @@ enum class NeedsBigProcessLock { S(getpid, NeedsBigProcessLock::No) \ S(getppid, NeedsBigProcessLock::Yes) \ S(getrandom, NeedsBigProcessLock::No) \ - S(getresgid, NeedsBigProcessLock::Yes) \ - S(getresuid, NeedsBigProcessLock::Yes) \ + S(getresgid, NeedsBigProcessLock::No) \ + S(getresuid, NeedsBigProcessLock::No) \ S(getrusage, NeedsBigProcessLock::Yes) \ S(getsid, NeedsBigProcessLock::Yes) \ S(getsockname, NeedsBigProcessLock::Yes) \ S(getsockopt, NeedsBigProcessLock::No) \ S(gettid, NeedsBigProcessLock::No) \ - S(getuid, NeedsBigProcessLock::Yes) \ + S(getuid, NeedsBigProcessLock::No) \ S(inode_watcher_add_watch, NeedsBigProcessLock::Yes) \ S(inode_watcher_remove_watch, NeedsBigProcessLock::Yes) \ S(ioctl, NeedsBigProcessLock::Yes) \ @@ -153,19 +153,19 @@ enum class NeedsBigProcessLock { S(set_mmap_name, NeedsBigProcessLock::Yes) \ S(set_process_name, NeedsBigProcessLock::Yes) \ S(set_thread_name, NeedsBigProcessLock::Yes) \ - S(setegid, NeedsBigProcessLock::Yes) \ - S(seteuid, NeedsBigProcessLock::Yes) \ - S(setgid, NeedsBigProcessLock::Yes) \ - S(setgroups, NeedsBigProcessLock::Yes) \ + S(setegid, NeedsBigProcessLock::No) \ + S(seteuid, NeedsBigProcessLock::No) \ + S(setgid, NeedsBigProcessLock::No) \ + S(setgroups, NeedsBigProcessLock::No) \ S(sethostname, NeedsBigProcessLock::No) \ S(setkeymap, NeedsBigProcessLock::No) \ S(setpgid, NeedsBigProcessLock::Yes) \ - S(setresgid, NeedsBigProcessLock::Yes) \ - S(setresuid, NeedsBigProcessLock::Yes) \ - S(setreuid, NeedsBigProcessLock::Yes) \ + S(setresgid, NeedsBigProcessLock::No) \ + S(setresuid, NeedsBigProcessLock::No) \ + S(setreuid, NeedsBigProcessLock::No) \ S(setsid, NeedsBigProcessLock::Yes) \ S(setsockopt, NeedsBigProcessLock::No) \ - S(setuid, NeedsBigProcessLock::Yes) \ + S(setuid, NeedsBigProcessLock::No) \ S(shutdown, NeedsBigProcessLock::No) \ S(sigaction, NeedsBigProcessLock::Yes) \ S(sigaltstack, NeedsBigProcessLock::Yes) \ diff --git a/Kernel/Syscalls/getuid.cpp b/Kernel/Syscalls/getuid.cpp index 14827020e7e..bb96709a696 100644 --- a/Kernel/Syscalls/getuid.cpp +++ b/Kernel/Syscalls/getuid.cpp @@ -10,35 +10,35 @@ namespace Kernel { ErrorOr Process::sys$getuid() { - VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); + VERIFY_NO_PROCESS_BIG_LOCK(this); TRY(require_promise(Pledge::stdio)); return uid().value(); } ErrorOr Process::sys$getgid() { - VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); + VERIFY_NO_PROCESS_BIG_LOCK(this); TRY(require_promise(Pledge::stdio)); return gid().value(); } ErrorOr Process::sys$geteuid() { - VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); + VERIFY_NO_PROCESS_BIG_LOCK(this); TRY(require_promise(Pledge::stdio)); return euid().value(); } ErrorOr Process::sys$getegid() { - VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); + VERIFY_NO_PROCESS_BIG_LOCK(this); TRY(require_promise(Pledge::stdio)); return egid().value(); } ErrorOr Process::sys$getresuid(Userspace user_ruid, Userspace user_euid, Userspace user_suid) { - VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); + VERIFY_NO_PROCESS_BIG_LOCK(this); TRY(require_promise(Pledge::stdio)); auto credentials = this->credentials(); @@ -54,7 +54,7 @@ ErrorOr Process::sys$getresuid(Userspace user_ruid, Userspace< ErrorOr Process::sys$getresgid(Userspace user_rgid, Userspace user_egid, Userspace user_sgid) { - VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); + VERIFY_NO_PROCESS_BIG_LOCK(this); TRY(require_promise(Pledge::stdio)); auto credentials = this->credentials(); @@ -70,7 +70,7 @@ ErrorOr Process::sys$getresgid(Userspace user_rgid, Userspace ErrorOr Process::sys$getgroups(size_t count, Userspace user_gids) { - VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); + VERIFY_NO_PROCESS_BIG_LOCK(this); TRY(require_promise(Pledge::stdio)); auto credentials = this->credentials(); diff --git a/Kernel/Syscalls/setuid.cpp b/Kernel/Syscalls/setuid.cpp index 758e09f4e68..0f22eabb424 100644 --- a/Kernel/Syscalls/setuid.cpp +++ b/Kernel/Syscalls/setuid.cpp @@ -10,7 +10,7 @@ namespace Kernel { ErrorOr Process::sys$seteuid(UserID new_euid) { - VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); + VERIFY_NO_PROCESS_BIG_LOCK(this); TRY(require_promise(Pledge::id)); if (new_euid == (uid_t)-1) @@ -41,7 +41,7 @@ ErrorOr Process::sys$seteuid(UserID new_euid) ErrorOr Process::sys$setegid(GroupID new_egid) { - VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); + VERIFY_NO_PROCESS_BIG_LOCK(this); TRY(require_promise(Pledge::id)); if (new_egid == (uid_t)-1) @@ -72,7 +72,7 @@ ErrorOr Process::sys$setegid(GroupID new_egid) ErrorOr Process::sys$setuid(UserID new_uid) { - VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); + VERIFY_NO_PROCESS_BIG_LOCK(this); TRY(require_promise(Pledge::id)); if (new_uid == (uid_t)-1) @@ -103,7 +103,7 @@ ErrorOr Process::sys$setuid(UserID new_uid) ErrorOr Process::sys$setgid(GroupID new_gid) { - VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); + VERIFY_NO_PROCESS_BIG_LOCK(this); TRY(require_promise(Pledge::id)); if (new_gid == (uid_t)-1) @@ -134,7 +134,7 @@ ErrorOr Process::sys$setgid(GroupID new_gid) ErrorOr Process::sys$setreuid(UserID new_ruid, UserID new_euid) { - VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); + VERIFY_NO_PROCESS_BIG_LOCK(this); TRY(require_promise(Pledge::id)); auto credentials = this->credentials(); @@ -171,7 +171,7 @@ ErrorOr Process::sys$setreuid(UserID new_ruid, UserID new_euid) ErrorOr Process::sys$setresuid(UserID new_ruid, UserID new_euid, UserID new_suid) { - VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); + VERIFY_NO_PROCESS_BIG_LOCK(this); TRY(require_promise(Pledge::id)); auto credentials = this->credentials(); @@ -207,7 +207,7 @@ ErrorOr Process::sys$setresuid(UserID new_ruid, UserID new_euid, UserID ErrorOr Process::sys$setresgid(GroupID new_rgid, GroupID new_egid, GroupID new_sgid) { - VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); + VERIFY_NO_PROCESS_BIG_LOCK(this); TRY(require_promise(Pledge::id)); auto credentials = this->credentials(); @@ -243,7 +243,7 @@ ErrorOr Process::sys$setresgid(GroupID new_rgid, GroupID new_egid, Grou ErrorOr Process::sys$setgroups(size_t count, Userspace user_gids) { - VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); + VERIFY_NO_PROCESS_BIG_LOCK(this); TRY(require_promise(Pledge::id)); auto credentials = this->credentials();