1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 06:07:35 +00:00
serenity/Kernel/Syscalls
Andreas Kling 31c1094577 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.
2022-01-27 11:18:25 +01:00
..
access.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
alarm.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
anon_create.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
beep.cpp Kernel: Add CommandLine option to disable or enable the PC speaker 2022-01-23 00:40:54 +00:00
chdir.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
chmod.cpp Kernel+LibC+LibCore+UE: Implement fchmodat(2) 2022-01-12 14:54:12 +01:00
chown.cpp Kernel+LibC+LibCore: Add lchown and fchownat functions 2022-01-01 15:08:49 +01:00
clock.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
debug.cpp Kernel+UE+LibC: Remove unused dbgputch syscall 2021-11-24 22:56:39 +01:00
disown.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
dup2.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
emuctl.cpp Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T> 2021-11-08 01:10:53 +01:00
execve.cpp Kernel: Don't mess with thread state in Process::do_exec() 2022-01-27 11:18:25 +01:00
exit.cpp Kernel: Fix a few typos 2021-10-01 00:51:49 +01:00
fcntl.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
fork.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
fsync.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
ftruncate.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
futex.cpp Kernel: Fix futex syscall return values 2021-11-24 19:44:57 +01:00
get_dir_entries.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
get_stack_bounds.cpp Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T> 2021-11-08 01:10:53 +01:00
getrandom.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
getuid.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
hostname.cpp Kernel: Convert hostname to KString 2022-01-13 00:20:08 -08:00
inode_watcher.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
ioctl.cpp Kernel: Use copy_typed_from_user() in more places :^) 2021-12-18 11:30:10 +01:00
keymap.cpp Kernel: Replace String with NonnullOwnPtr<KString> in sys$getkeymap 2022-01-25 08:06:02 +01:00
kill.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
link.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
lseek.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
mkdir.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
mknod.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
mmap.cpp Kernel: Make AddressSpace::find_regions_intersecting OOM-fallible 2022-01-26 02:37:03 +02:00
mount.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
open.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
perf_event.cpp Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T> 2021-11-08 01:10:53 +01:00
pipe.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
pledge.cpp Kernel: Delay Process data unprotection in sys$pledge() 2022-01-02 18:08:02 +01:00
poll.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
prctl.cpp Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T> 2021-11-08 01:10:53 +01:00
process.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
profiling.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
ptrace.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
purge.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
read.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
readlink.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
realpath.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
rename.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
rmdir.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
sched.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
sendfd.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
setpgid.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
setuid.cpp Kernel: Fail gracefully due to OOM on HashTable set in sys$setgroups 2022-01-26 02:37:03 +02:00
sigaction.cpp Kernel: Make AddressSpace::find_regions_intersecting OOM-fallible 2022-01-26 02:37:03 +02:00
socket.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
stat.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
statvfs.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
sync.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
sysconf.cpp Kernel: Return the actual number of CPU cores that we have 2021-12-29 03:17:41 -08:00
thread.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
times.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
ttyname.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
umask.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
uname.cpp Kernel: Fix OOB write in sys$uname 2022-01-13 00:20:08 -08:00
unlink.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
unveil.cpp Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T> 2021-11-08 01:10:53 +01:00
utime.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
waitid.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00
write.cpp Kernel: Handle promise violations in the syscall handler 2021-12-29 18:08:15 +01:00