1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-23 20:57:41 +00:00
serenity/Kernel
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
..
API Kernel: Add ioctl to get the EDID from a framebuffer 2022-01-23 22:45:21 +00:00
Arch Kernel: Implement Page Attribute Table (PAT) support and Write-Combine 2022-01-26 09:21:04 +02:00
Bus Kernel: Make VirtIO::ConsolePort construction OOM-fallible 2022-01-26 22:07:01 +00:00
Devices Kernel: Add try_create_device overload for static factory functions 2022-01-26 22:07:01 +00:00
FileSystem Kernel: Make Inode::register_watcher() OOM-fallible 2022-01-26 02:37:03 +02:00
Firmware Kernel: Replace {String => KString}::formatted in ACPISysFSDirectory 2022-01-21 16:27:21 +01:00
Graphics Kernel: Enable Write-Combine for FramebufferDevice 2022-01-26 09:21:04 +02:00
Heap Kernel: Include slabheaps in kmalloc statistics 2022-01-24 14:09:55 +02:00
Interrupts Kernel: Make map_typed() & map_typed_writable() fallible using ErrorOr 2022-01-13 22:40:25 +01:00
Library AK+Kernel: Remove one_ref_left() footgun 2022-01-11 01:12:16 +01:00
Locking Kernel: Remove no-longer-used Lockable template 2021-12-26 21:22:59 +01:00
Memory Kernel: Make VirtualRangeAllocator::carve_from_region OOM-fallible 2022-01-26 22:05:34 +00:00
Net Kernel: Use u64 instead of size_t for File::can_write offset 2022-01-25 22:41:17 +02:00
Prekernel Prekernel: Handle synchronous EL1 exceptions in C++ on aarch64 2022-01-24 06:57:59 +00:00
Storage Kernel/Storage: Dump detected devices and partitions before PANIC()'ing 2022-01-26 21:34:26 +00:00
Syscalls Kernel: Don't mess with thread state in Process::do_exec() 2022-01-27 11:18:25 +01:00
Tasks Kernel: Ignore allocation failures during thread finalization 2022-01-26 22:05:34 +00:00
Time Kernel: Create the time page region before initializing the timers 2022-01-18 21:00:46 +02:00
TTY Kernel: Use u64 instead of size_t for File::can_write offset 2022-01-25 22:41:17 +02:00
AddressSanitizer.cpp Everywhere: Use bgianf@serenityos.org for my copyright attribution 2021-04-22 21:15:54 +02:00
AddressSanitizer.h Everywhere: Use bgianf@serenityos.org for my copyright attribution 2021-04-22 21:15:54 +02:00
Assertions.h Kernel: Remove ASM_Wrapper include from platform independent processor.h 2021-12-01 11:22:04 -08:00
AtomicEdgeAction.h Kernel: Add per platform Processor.h headers 2021-10-14 01:23:08 +01:00
BootInfo.h Kernel: Add an x86 include check+error in x86/PageDirectory.h 2021-12-01 11:22:04 -08:00
CMakeLists.txt Kernel: Add ioctl to get the EDID from a framebuffer 2022-01-23 22:45:21 +00:00
CMOS.cpp Kernel: Move x86 IO instructions code into the x86 specific folder 2021-10-01 12:27:20 +02:00
CMOS.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
CommandLine.cpp Kernel: Add CommandLine option to disable or enable the PC speaker 2022-01-23 00:40:54 +00:00
CommandLine.h Kernel: Add CommandLine option to disable or enable the PC speaker 2022-01-23 00:40:54 +00:00
Coredump.cpp Kernel: Convert CoreDump to KString using try_serialize_absolute_path 2022-01-12 16:09:09 +02:00
Coredump.h Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T> 2021-11-08 01:10:53 +01:00
Debug.h.in Kernel/NVMe: Add initial NVMe driver support 2022-01-01 14:55:58 +01:00
DoubleBuffer.cpp Kernel: Share code between DoubleBuffer's read() and peek() 2021-11-21 20:22:48 +01:00
DoubleBuffer.h Kernel: Share code between DoubleBuffer's read() and peek() 2021-11-21 20:22:48 +01:00
embedmap.sh Kernel: Make new kernel build process work on macOS 2021-07-15 11:04:30 +02:00
Forward.h Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T> 2021-11-08 01:10:53 +01:00
FutexQueue.cpp Kernel: Don't register thread as custom data for FutexBlocker 2021-08-24 01:57:11 +02:00
FutexQueue.h Kernel: Don't register thread as custom data for FutexBlocker 2021-08-24 01:57:11 +02:00
GlobalProcessExposed.cpp Kernel: Make pledge serialization in /proc/all generation OOM-fallible 2022-01-26 02:37:03 +02:00
init.cpp Kernel: Perform DeviceManagement initialization after MM is initialized 2022-01-25 22:41:26 +02:00
KBuffer.h Kernel: Propagate overflow errors from Memory::page_round_up 2021-12-28 23:08:50 +01:00
KBufferBuilder.cpp Kernel+AK: Eliminate a couple of temporary String allocations 2021-12-30 14:16:03 +01:00
KBufferBuilder.h Kernel: Make Thread::backtrace() fallible using KString 2022-01-12 16:09:09 +02:00
KLexicalPath.cpp Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
KLexicalPath.h Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
kprintf.cpp Kernel: Simplify some if statements 2021-12-30 14:32:17 +01:00
kstdio.h Kernel+UE+LibC: Remove unused dbgputch syscall 2021-11-24 22:56:39 +01:00
KString.cpp Kernel: Add an error propagating KString::format(..) API :^) 2021-11-30 11:16:35 +01:00
KString.h Kernel: Add a KString::bytes() helper 2022-01-13 00:20:08 -08:00
KSyms.cpp Kernel: Remove the kmalloc_eternal heap :^) 2021-12-28 21:02:38 +01:00
KSyms.h Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
linker.ld Kernel+Toolchain: Use .init_array section for global constructors 2022-01-24 10:41:47 +00:00
MiniStdLib.cpp Kernel: Build MiniStdLib.cpp in aarch64 builds 2021-09-07 20:15:15 +01:00
mkmap.sh Kernel: Use the toolchain's nm in mkmap.sh 2021-12-30 18:10:51 +01:00
Multiboot.h Kernel: Only use multiboot framebuffer details if present 2022-01-06 22:34:11 +01:00
Panic.cpp Kernel: Ensure that CommandLine is initialized before choosing PanicMode 2022-01-21 19:34:10 +02:00
Panic.h Kernel/Graphics + SystemServer: Support text mode properly 2021-05-16 19:58:33 +02:00
PerformanceEventBuffer.cpp Kernel: Make PerformanceEventBuffer::add_process fallible with ErrorOr 2022-01-12 16:09:09 +02:00
PerformanceEventBuffer.h Kernel: Make PerformanceEventBuffer::add_process fallible with ErrorOr 2022-01-12 16:09:09 +02:00
PerformanceManager.h Kernel: Make PerformanceEventBuffer::add_process fallible with ErrorOr 2022-01-12 16:09:09 +02:00
PhysicalAddress.h AK: Convert AK::Format formatting helpers to returning ErrorOr<void> 2021-11-17 00:21:13 +01:00
Process.cpp Kernel: Don't mess with thread state in Process::do_exec() 2022-01-27 11:18:25 +01:00
Process.h Kernel: Remove non existent friend class from Process.h 2022-01-17 11:17:04 +01:00
ProcessExposed.cpp Kernel: Add some implied auto qualifiers 2021-12-30 14:32:17 +01:00
ProcessExposed.h Kernel+SystemServer: Add /dev/tty 2021-12-12 22:32:35 +01:00
ProcessGroup.cpp Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T> 2021-11-08 01:10:53 +01:00
ProcessGroup.h Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T> 2021-11-08 01:10:53 +01:00
ProcessProcFSTraits.cpp Kernel+SystemServer: Add /dev/tty 2021-12-12 22:32:35 +01:00
ProcessSpecificExposed.cpp Kernel: Make Processor::capture_stack_trace fallible using ErrorOr 2022-01-16 01:01:08 +02:00
Random.cpp Kernel: Make KernelRng not inherit from Lockable 2021-12-26 21:22:59 +01:00
Random.h Everywhere: Convert ByteBuffer factory methods from Optional -> ErrorOr 2022-01-24 22:36:09 +01:00
RTC.cpp Everywhere: Fix many spelling errors 2022-01-07 10:56:59 +01:00
RTC.h Kernel: Ensure we read valid values from the RTC CMOS registers 2021-08-04 19:53:04 +02:00
SanCov.cpp Kernel: Add some implied auto qualifiers 2021-12-30 14:32:17 +01:00
Scheduler.cpp Kernel: Use kernelputstr instead of dbgln when printing backtraces 2022-01-16 01:01:08 +02:00
Scheduler.h Kernel: Rename SpinLock => Spinlock 2021-08-22 03:34:10 +02:00
Sections.h Kernel: Move userspace virtual address range base to 0x10000 2021-12-22 00:02:36 -08:00
StdLib.cpp Kernel: Add some implied auto qualifiers 2021-12-30 14:32:17 +01:00
StdLib.h Kernel: Remove unused forward declaration of Syscall::StringArgument 2021-11-14 22:52:35 +01:00
Syscall.cpp Kernel: Add some implied auto qualifiers 2021-12-30 14:32:17 +01:00
Thread.cpp Kernel: Ignore allocation failures during thread finalization 2022-01-26 22:05:34 +00:00
Thread.h Kernel: Remove always-false Thread::drop_thread_count boolean parameter 2022-01-26 22:05:34 +00:00
ThreadBlockers.cpp Kernel: Add some implied auto qualifiers 2021-12-30 14:32:17 +01:00
ThreadTracer.cpp Kernel: Add cross platform RegisterState header and Aarch64 version 2021-10-15 21:48:45 +01:00
ThreadTracer.h Kernel: Add missing includes in ThreadTracer and WorkQueue 2021-12-30 14:32:17 +01:00
TimerQueue.cpp Kernel: Remove a bunch of unused TimerQueue functions 2021-09-07 22:16:25 +02:00
TimerQueue.h AK+Everywhere: Reduce the number of template parameters of IntrusiveList 2021-09-10 18:05:46 +03:00
UBSanitizer.cpp Kernel: Print KUBSAN backtrace to screen if KUBSAN is deadly 2021-12-29 17:58:44 +01:00
UnixTypes.h Kernel: Move {Process,Thread,Session,ProcessGroup}ID to Kernel/Forward.h 2021-08-14 19:58:11 +02:00
UserOrKernelBuffer.cpp Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T> 2021-11-08 01:10:53 +01:00
UserOrKernelBuffer.h Kernel+LibC: Move errno definitions to Kernel/API/POSIX 2021-12-16 22:21:35 +03:30
VirtualAddress.h AK: Convert AK::Format formatting helpers to returning ErrorOr<void> 2021-11-17 00:21:13 +01:00
WaitQueue.cpp Kernel: Don't register thread as custom data for WaitQueueBlocker 2021-08-24 01:57:11 +02:00
WaitQueue.h Kernel: Don't register thread as custom data for WaitQueueBlocker 2021-08-24 01:57:11 +02:00
WorkQueue.cpp Kernel: Mark kernel smart-pointer classes as [[nodiscard]] 2021-12-05 15:31:03 +01:00
WorkQueue.h Kernel: Add missing includes in ThreadTracer and WorkQueue 2021-12-30 14:32:17 +01:00