Andreas Kling
e44c1792a7
Kernel: Add distinct InodeIndex type
...
Use the DistinctNumeric mechanism to make InodeIndex a strongly typed
integer type.
2021-02-12 10:26:29 +01:00
Andreas Kling
c8a90a31b6
Kernel: Remove default arguments from Inode::resolve_as_link()
...
Nobody was calling it without specifying all arguments anyway.
2021-02-12 09:06:03 +01:00
Owen Smith
c2de22a635
Kernel: Merge split function and data sections into one during linking
...
Also add an assertion to make sure the safemem sections are never
discarded by the linker.
2021-02-12 08:57:26 +01:00
Andreas Kling
8c694ed6eb
Kernel: Don't call Thread::set_should_die() twice on every thread
...
This stops the "should already die" debug spam we've been seeing.
2021-02-11 23:33:42 +01:00
Andreas Kling
95064f8b58
Ext2FS: Convert #if EXT2_DEBUG => dbgln_if() and constexpr-if
2021-02-11 23:05:16 +01:00
Andreas Kling
abe4463b1c
Kernel: Remove an unnecessary InterruptDisabler in early initialization
2021-02-11 22:56:14 +01:00
Andreas Kling
a280cdf9ba
Ext2FS: Shrink Ext2FSDirectoryEntry from 16 to 12 bytes
...
The way we read/write directories is very inefficient, and this doesn't
solve any of that. It does however reduce memory usage of directory
entry vectors by 25% which has nice immediate benefits.
2021-02-11 22:45:50 +01:00
Andreas Kling
cef73f2010
Kernel: Remove CMake spam when setting up KUBSAN flags
2021-02-11 22:16:28 +01:00
Andreas Kling
54986228bf
Kernel: Oops, add missing #include to fix ENABLE_ALL_THE_DEBUG_MACROS
2021-02-11 22:15:55 +01:00
Andreas Kling
0dbb22e9e0
Kernel: Remove a handful of unused things in VM/ directory
...
Also add some missing initializers.
2021-02-11 22:02:39 +01:00
Andreas Kling
ba42d741cb
Kernel: Add explicit __serenity__ define to workaround CLion problem
...
CLion doesn't understand that we switch compilers mid-build (which I
can understand since it's a bit unusual.) Defining __serenity__ makes
the majority of IDE features work correctly in the kernel context.
2021-02-11 21:23:31 +01:00
Jean-Baptiste Boric
f8c352a022
Kernel: Fix undefined signed overflow in KernelRng's RTC fallback
2021-02-11 20:58:39 +01:00
Jean-Baptiste Boric
eedb6480df
Kernel: Don't assert if RTC believes we're in the past
2021-02-11 20:58:39 +01:00
Hendiadyoin1
4d5496b2b2
KUBSAN: Add nearly all missing -fsanitize handlers ( #5254 )
2021-02-11 20:58:01 +01:00
Andreas Kling
085f80aeac
Kernel: Remove unused root directory computation in Process creation
...
sys$fork() already takes care of children inheriting the parent's root
directory, so there was no need to do the same thing when creating a
new user process.
2021-02-09 19:18:13 +01:00
Andreas Kling
1f277f0bd9
Kernel: Convert all *Builder::appendf() => appendff()
2021-02-09 19:18:13 +01:00
Andreas Kling
e8f040139b
Kernel: Remove unused Thread::is_runnable_state()
2021-02-08 23:07:33 +01:00
Andreas Kling
4ff0f971f7
Kernel: Prevent execve/ptrace race
...
Add a per-process ptrace lock and use it to prevent ptrace access to a
process after it decides to commit to a new executable in sys$execve().
Fixes #5230 .
2021-02-08 23:05:41 +01:00
Andreas Kling
4b7b92c201
Kernel: Remove two unused fields from sys$execve's LoadResult
2021-02-08 22:31:03 +01:00
Andreas Kling
4cd2c475a8
Kernel: Make the space lock a RecursiveSpinLock
2021-02-08 22:28:48 +01:00
Andreas Kling
0d7af498d7
Kernel: Move ShouldAllocateTls enum from Process to execve.cpp
2021-02-08 22:24:37 +01:00
Andreas Kling
9ca42c4c0e
Kernel: Always hold space lock while calculating memory statistics
...
And put the locker at the top of the functions for clarity.
2021-02-08 22:23:29 +01:00
Andreas Kling
8bda30edd2
Kernel: Move memory statistics helpers from Process to Space
2021-02-08 22:23:29 +01:00
Andreas Kling
b1c9f93fa3
Kernel: Skip generic region lookup in sys$futex and sys$get_stack_bounds
...
Just ask the process space directly instead of using the generic region
lookup that also checks for kernel regions.
2021-02-08 22:23:29 +01:00
Andreas Kling
f39c2b653e
Kernel: Reorganize ptrace implementation a bit
...
The generic parts of ptrace now live in Kernel/Syscalls/ptrace.cpp
and the i386 specific parts are moved to Arch/i386/CPU.cpp
2021-02-08 19:34:41 +01:00
Andreas Kling
45231051e6
Kernel: Set the dumpable flag before switching spaces in sys$execve()
2021-02-08 19:15:42 +01:00
Andreas Kling
d746639171
Kernel: Remove outdated code to dump memory layout after exec load
2021-02-08 19:07:29 +01:00
Andreas Kling
f1b5def8fd
Kernel: Factor address space management out of the Process class
...
This patch adds Space, a class representing a process's address space.
- Each Process has a Space.
- The Space owns the PageDirectory and all Regions in the Process.
This allows us to reorganize sys$execve() so that it constructs and
populates a new Space fully before committing to it.
Previously, we would construct the new address space while still
running in the old one, and encountering an error meant we had to do
tedious and error-prone rollback.
Those problems are now gone, replaced by what's hopefully a set of much
smaller problems and missing cleanups. :^)
2021-02-08 18:27:28 +01:00
Andreas Kling
b2cba3036e
Kernel: Remove unused MemoryManager::validate_range()
...
This is no longer used since we've switched to using the MMU to
generate EFAULT errors.
2021-02-08 18:27:28 +01:00
Andreas Kling
cf5ab665e0
Kernel: Remove unused Process::for_each_thread_in_coredump()
2021-02-08 18:27:28 +01:00
AnotherTest
09a43969ba
Everywhere: Replace dbgln<flag>(...) with dbgln_if(flag, ...)
...
Replacement made by `find Kernel Userland -name '*.h' -o -name '*.cpp' | sed -i -Ee 's/dbgln\b<(\w+)>\(/dbgln_if(\1, /g'`
2021-02-08 18:08:55 +01:00
AnotherTest
1f8a633cc7
Kernel: Make Arch/i386/CPU.cpp safe to run through clang-format
...
This file was far too messy, and touching it was a major pain.
Also enable clang-format linting on it.
2021-02-08 18:08:55 +01:00
AnotherTest
53ce923e10
Everywhere: Fix obvious dbgln() bugs
...
This will allow compiletime dbgln() checks to pass
2021-02-08 18:08:55 +01:00
Ben Wiederhake
0a2304ba05
Everywhere: Fix weird includes
2021-02-08 18:03:57 +01:00
Tom
1d843c46eb
Kernel: KResultOr can use the same storage as the object for the error
...
Since it can only hold either an object or an error code, we can share
the same storage to hold either.
2021-02-08 18:00:38 +01:00
Tom
27a395d964
Kernel: Fix KResultOr copy-move from itself case
...
If move-assigning from itself we shouldn't do anything.
2021-02-07 23:02:57 +01:00
Tom
b22740c08e
Kernel: Use KResultOr::release_value in Process::create_kernel_thread
...
This should avoid an unneccessary reference bump.
2021-02-07 22:25:15 +01:00
Tom
f74e31c74d
Kernel: Change KResultOr::take_value to use move semantics
...
This may be more light weight than copying the object.
2021-02-07 22:25:15 +01:00
Andreas Kling
ad42d873e5
Kernel: Remove ancient unused Scheduler::beep() declaration
2021-02-07 20:45:09 +01:00
Andreas Kling
0d8262cbab
Kernel: Remove a handful of unused things from Thread
2021-02-07 20:26:53 +01:00
Andreas Kling
2ec8b4e177
Kernel: Don't allocate kernel stack twice per thread :^)
2021-02-07 20:13:51 +01:00
Andreas Kling
b466ede1ea
Kernel: Make sure we can allocate kernel stack before creating thread
...
Wrap thread creation in a Thread::try_create() helper that first
allocates a kernel stack region. If that allocation fails, we propagate
an ENOMEM error to the caller.
This avoids the situation where a thread is half-constructed, without a
valid kernel stack, and avoids having to do messy cleanup in that case.
2021-02-07 19:27:00 +01:00
Andreas Kling
5c45b0d32d
Kernel: Combine Thread::backtrace() and backtrace_impl() into one
2021-02-07 19:27:00 +01:00
Andreas Kling
fd3eca3acc
Kernel: Add initializer for Thread::m_tss
2021-02-07 19:27:00 +01:00
Andreas Kling
5c1c82cd33
Kernel: Remove unused function Process::backtrace()
2021-02-07 19:27:00 +01:00
Andreas Kling
b1813e5dae
Kernel: Remove some unused declarations from Process
2021-02-07 19:27:00 +01:00
Brian Gianforcaro
c95d48c8d6
Kernel: KUBSAN implementation of returns-nonnull-attribute
...
This didn't find anything in the current source.
2021-02-07 10:22:03 +01:00
William Bowling
b97d23a71f
Kernel: Use the resolved parent path when testing create veil ( #5231 )
2021-02-06 19:11:44 +01:00
Andreas Kling
04ff46bff4
Kernel: And some more KUBSAN checks :^)
...
Here comes a few more:
* enum
* object-size
* vptr
2021-02-06 17:39:49 +01:00
Andreas Kling
fad0332898
Kernel: Implement some more KUBSAN checks :^)
...
This patch enables the following -fsanitize sub-options:
* bounds
* bounds-strict
* integer-divide-by-zero
* return
* shift
* shift-base
* shift-exponent
2021-02-06 17:39:49 +01:00