summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-11-17 00:52:29 +0100
committerAndreas Kling <awesomekling@gmail.com>2018-11-17 00:52:29 +0100
commit95e0f6ad82d8305e77e8ab02268abb57f5cbc804 (patch)
treefda3a55a177f5fe56e1152ab45658fdd60ae7872
parentbb9766ee17a97735383d21ad873aed5d6cd65a9c (diff)
downloadserenity-95e0f6ad82d8305e77e8ab02268abb57f5cbc804.zip
Fix race condition in exec().
...also hook up sys$fstat in the syscall dispatcher.
-rw-r--r--Kernel/Process.cpp6
-rw-r--r--Kernel/Syscall.cpp4
2 files changed, 8 insertions, 2 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index 3acd64464f..94ab2fdd6b 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -363,7 +363,11 @@ int Process::do_exec(const String& path, Vector<String>&& arguments, Vector<Stri
}
}
- InterruptDisabler disabler;
+ // We cli() manually here because we don't want to get interrupted between do_exec() and Schedule::yield().
+ // The reason is that the task redirection we've set up above will be clobbered by the timer IRQ.
+ // If we used an InterruptDisabler that sti()'d on exit, we might timer tick'd too soon in exec().
+ cli();
+
Scheduler::prepare_to_modify_tss(*this);
m_name = parts.takeLast();
diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp
index f586d702ef..99e9969a9d 100644
--- a/Kernel/Syscall.cpp
+++ b/Kernel/Syscall.cpp
@@ -173,8 +173,10 @@ static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2,
return current->sys$fcntl((int)arg1, (int)arg2, (dword)arg3);
case Syscall::SC_ioctl:
return current->sys$ioctl((int)arg1, (unsigned)arg2, (unsigned)arg3);
+ case Syscall::SC_fstat:
+ return current->sys$fstat((int)arg1, (Unix::stat*)arg2);
default:
- kprintf("<%u> int0x80: Unknown function %x requested {%x, %x, %x}\n", current->pid(), function, arg1, arg2, arg3);
+ kprintf("<%u> int0x80: Unknown function %u requested {%x, %x, %x}\n", current->pid(), function, arg1, arg2, arg3);
break;
}
return 0;