diff options
author | Andreas Kling <kling@serenityos.org> | 2022-01-27 11:18:25 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-01-27 11:18:25 +0100 |
commit | 31c109457729f6ebb7c590f4303f185f8611f147 (patch) | |
tree | 92cbafacbd4164ddc0d1131ba656831ffe82ca26 /Userland/Utilities/ping.cpp | |
parent | b7d316d291f56647894fab3b3039cf48b1712843 (diff) | |
download | serenity-31c109457729f6ebb7c590f4303f185f8611f147.zip |
Kernel: Don't mess with thread state in Process::do_exec()
We were marking the execing thread as Runnable near the end of
Process::do_exec().
This was necessary for exec in processes that had never been scheduled
yet, which is a specific edge case that only applies to the very first
userspace process (normally SystemServer). At this point, such threads
are in the Invalid state.
In the common case (normal userspace-initiated exec), making the current
thread Runnable meant that we switched away from its current state:
Running. As the thread is indeed running, that's a bogus change!
This created a short time window in which the thread state was bogus,
and any attempt to block the thread would panic the kernel (due to a
bogus thread state in Thread::block() leading to VERIFY_NOT_REACHED().)
Fix this by not touching the thread state in Process::do_exec()
and instead make the first userspace thread Runnable directly after
calling Process::exec() on it in try_create_userspace_process().
It's unfortunate that exec() can be called both on the current thread,
and on a new thread that has never been scheduled. It would be good to
not have the latter edge case, but fixing that will require larger
architectural changes outside the scope of this fix.
Diffstat (limited to 'Userland/Utilities/ping.cpp')
0 files changed, 0 insertions, 0 deletions