Skip to content

Commit 93741d8

Browse files
committed
Fix: Check for context switch before killing was wrong
It may so happen that we are killing the parent of the current thread process. In that case PID of the current process and the one being killed is different but context of then are same and therefore should switch to use kernel context before killing is started.
1 parent 0cd3df8 commit 93741d8

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/kernel/x86/process.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -472,11 +472,9 @@ static bool kprocess_kill_process (KProcessInfo** process, U8 exitCode)
472472
}
473473
INFO ("All child processes killed/adopted. Now killing parent: %x", l_process->processID);
474474

475-
// If current process is not the process being killed, then there is no need to change
476-
// Page Directories.
477-
if (currentProcess != NULL && currentProcess->processID == l_process->processID) {
478-
// In order to destroy the PD of the current process, it is required to switch to
479-
// the Kernel PD, otherwise we would be killing the PD while using it.
475+
// If current process is the process being killed, then it is required to switch to the
476+
// Kernel PD, otherwise we would be killing the PD while using it.
477+
if (currentProcess != NULL && currentProcess->context == l_process->context) {
480478
register x86_CR3 cr3 = { 0 };
481479
cr3.pcd = x86_PG_DEFAULT_IS_CACHING_DISABLED;
482480
cr3.pwt = x86_PG_DEFAULT_IS_WRITE_THROUGH;

0 commit comments

Comments
 (0)