diff --git a/Kernel/API/Syscall.h b/Kernel/API/Syscall.h index de83141dd8..9a648103cd 100644 --- a/Kernel/API/Syscall.h +++ b/Kernel/API/Syscall.h @@ -148,7 +148,7 @@ enum class NeedsBigProcessLock { S(sched_setparam, NeedsBigProcessLock::No) \ S(sendfd, NeedsBigProcessLock::No) \ S(sendmsg, NeedsBigProcessLock::Yes) \ - S(set_coredump_metadata, NeedsBigProcessLock::Yes) \ + S(set_coredump_metadata, NeedsBigProcessLock::No) \ S(set_mmap_name, NeedsBigProcessLock::Yes) \ S(set_process_name, NeedsBigProcessLock::Yes) \ S(set_thread_name, NeedsBigProcessLock::Yes) \ diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 1057328ab2..0b60ae622d 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -874,15 +874,18 @@ void Process::set_dumpable(bool dumpable) ErrorOr Process::set_coredump_property(NonnullOwnPtr key, NonnullOwnPtr value) { - // Write it into the first available property slot. - for (auto& slot : m_coredump_properties) { - if (slot.key) - continue; - slot.key = move(key); - slot.value = move(value); - return {}; - } - return ENOBUFS; + return m_coredump_properties.with([&](auto& coredump_properties) -> ErrorOr { + // Write it into the first available property slot. + for (auto& slot : coredump_properties) { + if (slot.key) + continue; + slot.key = move(key); + slot.value = move(value); + return {}; + } + + return ENOBUFS; + }); } ErrorOr Process::try_set_coredump_property(StringView key, StringView value) diff --git a/Kernel/Process.h b/Kernel/Process.h index 4148440d4c..0f83fee862 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -500,11 +500,14 @@ public: template ErrorOr for_each_coredump_property(Callback callback) const { - for (auto const& property : m_coredump_properties) { - if (property.key && property.value) - TRY(callback(*property.key, *property.value)); - } - return {}; + return m_coredump_properties.with([&](auto const& coredump_properties) -> ErrorOr { + for (auto const& property : coredump_properties) { + if (property.key && property.value) + TRY(callback(*property.key, *property.value)); + } + + return {}; + }); } ErrorOr set_coredump_property(NonnullOwnPtr key, NonnullOwnPtr value); @@ -833,7 +836,7 @@ private: OwnPtr value; }; - Array m_coredump_properties; + SpinlockProtected> m_coredump_properties; NonnullRefPtrVector m_threads_for_coredump; mutable RefPtr m_procfs_traits; diff --git a/Kernel/Syscalls/execve.cpp b/Kernel/Syscalls/execve.cpp index 8c84727b70..c79fd18928 100644 --- a/Kernel/Syscalls/execve.cpp +++ b/Kernel/Syscalls/execve.cpp @@ -525,8 +525,9 @@ ErrorOr Process::do_exec(NonnullRefPtr main_program_d return {}; })); - for (auto& property : m_coredump_properties) + m_coredump_properties.for_each([](auto& property) { property = {}; + }); auto* current_thread = Thread::current(); current_thread->reset_signals_for_exec(); diff --git a/Kernel/Syscalls/process.cpp b/Kernel/Syscalls/process.cpp index 8ef8fed952..cd7bafc721 100644 --- a/Kernel/Syscalls/process.cpp +++ b/Kernel/Syscalls/process.cpp @@ -50,7 +50,7 @@ ErrorOr Process::sys$set_process_name(Userspace user_name, ErrorOr Process::sys$set_coredump_metadata(Userspace user_params) { - VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) + VERIFY_NO_PROCESS_BIG_LOCK(this) auto params = TRY(copy_typed_from_user(user_params)); if (params.key.length == 0 || params.key.length > 16 * KiB)