From efeb01e35fccc6ecc0ce0d6c33102dd5379ddf0f Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Fri, 6 Aug 2021 15:21:08 +0300 Subject: [PATCH] Kernel: Disable big process lock for sys$get_stack_bounds This syscall only reads from the shared m_space field, but that field is only over written to by Process::attach_resources, before the process was initialized (aka, before syscalls can happen), by Process::finalize which is only called after all the process' threads have exited (aka, syscalls can not happen anymore), and by Process::do_exec which calls all other syscall-capable threads before doing so. Space's find_region_containing already holds its own lock, and as such there's no need to hold the big lock. --- Kernel/API/Syscall.h | 2 +- Kernel/Syscalls/get_stack_bounds.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel/API/Syscall.h b/Kernel/API/Syscall.h index 1236c31595..0ee2f8a6dc 100644 --- a/Kernel/API/Syscall.h +++ b/Kernel/API/Syscall.h @@ -177,7 +177,7 @@ enum class NeedsBigProcessLock { S(unveil, NeedsBigProcessLock::Yes) \ S(perf_event, NeedsBigProcessLock::Yes) \ S(shutdown, NeedsBigProcessLock::Yes) \ - S(get_stack_bounds, NeedsBigProcessLock::Yes) \ + S(get_stack_bounds, NeedsBigProcessLock::No) \ S(ptrace, NeedsBigProcessLock::Yes) \ S(sendfd, NeedsBigProcessLock::Yes) \ S(recvfd, NeedsBigProcessLock::Yes) \ diff --git a/Kernel/Syscalls/get_stack_bounds.cpp b/Kernel/Syscalls/get_stack_bounds.cpp index 2a8c92f5a1..2235923714 100644 --- a/Kernel/Syscalls/get_stack_bounds.cpp +++ b/Kernel/Syscalls/get_stack_bounds.cpp @@ -11,7 +11,7 @@ namespace Kernel { KResultOr Process::sys$get_stack_bounds(Userspace user_stack_base, Userspace user_stack_size) { - VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); + VERIFY_NO_PROCESS_BIG_LOCK(this); auto& regs = Thread::current()->get_register_dump_from_stack(); FlatPtr stack_pointer = regs.userspace_sp(); auto* stack_region = address_space().find_region_containing(Memory::VirtualRange { VirtualAddress(stack_pointer), 1 });