Kernel: Avoid creating unkillable processes

Found by fuzz-syscalls. Can be reproduced by running this in the Shell:

    $ syscall exit_thread

This leaves the process in the 'Dying' state but never actually removes it.

Therefore, avoid this scenario by pretending to exit the entire process.
This commit is contained in:
Ben Wiederhake 2021-02-10 21:17:30 +01:00 committed by Andreas Kling
parent 5963f2084e
commit 1e630fb78a
Notes: sideshowbarker 2024-07-18 22:23:10 +09:00

View file

@ -95,6 +95,12 @@ void Process::sys$exit_thread(Userspace<void*> exit_value)
{
REQUIRE_PROMISE(thread);
cli();
if (this->thread_count() == 1) {
// If this is the last thread, instead kill the process.
this->sys$exit(0);
}
Thread::current()->exit(reinterpret_cast<void*>(exit_value.ptr()));
ASSERT_NOT_REACHED();
}