فهرست منبع

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.
Ben Wiederhake 4 سال پیش
والد
کامیت
1e630fb78a
1فایلهای تغییر یافته به همراه6 افزوده شده و 0 حذف شده
  1. 6 0
      Kernel/Syscalls/thread.cpp

+ 6 - 0
Kernel/Syscalls/thread.cpp

@@ -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();
 }