mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
Kernel: Ensure jailed processes can be reaped by a jailed parent process
We were detaching from the jail process list too early. To ensure we detach properly, leverage the remove_from_secondary_lists method so the possibly jailed parent process can still see the dying process and therefore clean it properly.
This commit is contained in:
parent
67aceb6c67
commit
5a94e8dfd0
Notes:
sideshowbarker
2024-07-17 02:28:18 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/5a94e8dfd0 Pull-request: https://github.com/SerenityOS/serenity/pull/18199 Issue: https://github.com/SerenityOS/serenity/issues/17810 Reviewed-by: https://github.com/gmta ✅
2 changed files with 13 additions and 7 deletions
|
@ -785,13 +785,6 @@ void Process::finalize()
|
||||||
m_fds.with_exclusive([](auto& fds) { fds.clear(); });
|
m_fds.with_exclusive([](auto& fds) { fds.clear(); });
|
||||||
with_mutable_protected_data([&](auto& protected_data) { protected_data.tty = nullptr; });
|
with_mutable_protected_data([&](auto& protected_data) { protected_data.tty = nullptr; });
|
||||||
m_executable.with([](auto& executable) { executable = nullptr; });
|
m_executable.with([](auto& executable) { executable = nullptr; });
|
||||||
m_jail_process_list.with([this](auto& list_ptr) {
|
|
||||||
if (list_ptr) {
|
|
||||||
list_ptr->attached_processes().with([&](auto& list) {
|
|
||||||
list.remove(*this);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
m_attached_jail.with([](auto& jail) {
|
m_attached_jail.with([](auto& jail) {
|
||||||
if (jail)
|
if (jail)
|
||||||
jail->detach({});
|
jail->detach({});
|
||||||
|
@ -845,6 +838,17 @@ void Process::unblock_waiters(Thread::WaitBlocker::UnblockFlags flags, u8 signal
|
||||||
waiter_process->m_wait_blocker_set.unblock(*this, flags, signal);
|
waiter_process->m_wait_blocker_set.unblock(*this, flags, signal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Process::remove_from_secondary_lists()
|
||||||
|
{
|
||||||
|
m_jail_process_list.with([this](auto& list_ptr) {
|
||||||
|
if (list_ptr) {
|
||||||
|
list_ptr->attached_processes().with([&](auto& list) {
|
||||||
|
list.remove(*this);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void Process::die()
|
void Process::die()
|
||||||
{
|
{
|
||||||
auto expected = State::Running;
|
auto expected = State::Running;
|
||||||
|
|
|
@ -204,6 +204,8 @@ public:
|
||||||
|
|
||||||
~Process();
|
~Process();
|
||||||
|
|
||||||
|
virtual void remove_from_secondary_lists();
|
||||||
|
|
||||||
ErrorOr<NonnullRefPtr<Thread>> create_kernel_thread(void (*entry)(void*), void* entry_data, u32 priority, NonnullOwnPtr<KString> name, u32 affinity = THREAD_AFFINITY_DEFAULT, bool joinable = true);
|
ErrorOr<NonnullRefPtr<Thread>> create_kernel_thread(void (*entry)(void*), void* entry_data, u32 priority, NonnullOwnPtr<KString> name, u32 affinity = THREAD_AFFINITY_DEFAULT, bool joinable = true);
|
||||||
|
|
||||||
bool is_profiling() const { return m_profiling; }
|
bool is_profiling() const { return m_profiling; }
|
||||||
|
|
Loading…
Reference in a new issue