mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:27:43 +00:00
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:
parent
5963f2084e
commit
1e630fb78a
1 changed files with 6 additions and 0 deletions
|
@ -95,6 +95,12 @@ void Process::sys$exit_thread(Userspace<void*> exit_value)
|
||||||
{
|
{
|
||||||
REQUIRE_PROMISE(thread);
|
REQUIRE_PROMISE(thread);
|
||||||
cli();
|
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()));
|
Thread::current()->exit(reinterpret_cast<void*>(exit_value.ptr()));
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue