summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2020-12-30AK+Format: Remove TypeErasedFormatParams& from format function.asynts
2020-12-30Kernel: Prevent sign bit extension when creating a PDPTELuke
When doing the cast to u64 on the page directory physical address, the sign bit was being extended. This only beomes an issue when crossing the 2 GiB boundary. At >= 2 GiB, the physical address has the sign bit set. For example, 0x80000000. This set all the reserved bits in the PDPTE, causing a GPF when loading the PDPT pointer into CR3. The reserved bits are presumably there to stop you writing out a physical address that the CPU physically cannot handle, as the size of the reserved bits is determined by the physical address width of the CPU. This fixes this by casting to FlatPtr instead. I believe the sign extension only happens when casting to a bigger type. I'm also using FlatPtr because it's a pointer we're writing into the PDPTE. sizeof(FlatPtr) will always be the same size as sizeof(void*). This also now asserts that the physical address in the PDPTE is within the max physical address the CPU supports. This is better than getting a GPF, because CPU::handle_crash tries to do the same operation that caused the GPF in the first place. That would cause an infinite loop of GPFs until the stack was exhausted, causing a triple fault. As far as I know and tested, I believe we can now use the full 32-bit physical range without crashing. Fixes #4584. See that issue for the full debugging story.
2020-12-30Kernel: Embed a Metadata notes entry in coredumpsLinus Groh
2020-12-30Kernel: Add sys$set_coredump_metadata() syscallLinus Groh
This can be used by applications to store information (key/value pairs) likely useful for debugging, which will then be embedded in the coredump.
2020-12-30Kernel: Embed a ProcessInfo notes entry in coredumpsLinus Groh
2020-12-30Kernel: Consolidate the various BlockCondition::unblock variantsTom
The unblock_all variant used to ASSERT if a blocker didn't unblock, but it wasn't clear from the name that it would do that. Because the BlockCondition already asserts that no blockers are left at destruction time, it would still catch blockers that haven't been unblocked for whatever reason. Fixes #4496
2020-12-30AK: Make binary_search signature more generic.asynts
2020-12-30Kernel: Fix HPET::update_time to set ticks within the valid rangeTom
ticks_this_second must be less than the ticks per second (frequency).
2020-12-29Build: Support non-i686 toolchainsmeme
* Add SERENITY_ARCH option to CMake for selecting the target toolchain * Port all build scripts but continue to use i686 * Update GitHub Actions cache to include BuildIt.sh
2020-12-29Kernel: Hold InodeVMObject reference while inspecting it in sys$mmap()Andreas Kling
2020-12-29Kernel: Remove unnecessary non-const Inode::shared_vmobject()Andreas Kling
2020-12-29Kernel+LibC: Add a very limited sys$mremap() implementationAndreas Kling
This syscall can currently only remap a shared file-backed mapping into a private file-backed mapping.
2020-12-29Kernel/VM: Make local_offset in PhysicalRegion::find_one_free_page unsignedLuke
An extension to #4613, as I didn't notice that it also happens here.
2020-12-29Kernel/VM: Make local_offset in PhysicalRegion::free_page_at unsignedLuke
Anything above or equal to the 2 GB mark has the left most bit set (0x8000...), which was falsely interpreted as negative due to local_offset being signed. This makes it unsigned by using FlatPtr. To check for underflow as was intended, lets use Checked instead. Fixes #4585
2020-12-29Revert "Kernel: Convert read_block method to get a reference instead of pointer"Andreas Kling
This reverts commit 092a13211a4216c19c08280bd5e5803e1030f087. Fixes #4611.
2020-12-27Kernel: Introduce a new partitioning subsystemLiav A
The partitioning code was very outdated, and required a full refactor. The new subsystem removes duplicated code and uses more AK containers. The most important change is that all implementations of the PartitionTable class conform to one interface, which made it possible to remove unnecessary code in the EBRPartitionTable class. Finding partitions is now done in the StorageManagement singleton, instead of doing so in init.cpp. Also, now we don't try to find partitions on demand - the kernel will try to detect if a StorageDevice is partitioned, and if so, will check what is the partition table, which could be MBR, GUID or EBR. Then, it will create DiskPartitionMetadata object for each partition that is available in the partition table. This object will be used by the partition enumeration code to create a DiskPartition with the correct minor number.
2020-12-27Kernel: Add DiskPartitionMetadata ClassLiav A
This class will be used to describe a partition of a StorageDevice, without creating a DiskPartition object.
2020-12-27Kernel: Move Partition code files to the Storage folderLiav A
This folder is more appropriate for these files.
2020-12-27Kernel: Introduce the DevFSLiav A
The DevFS along with DevPtsFS give a complete solution for populating device nodes in /dev. The main purpose of DevFS is to eliminate the need of device nodes generation when building the system. Later on, DevFS will assist with exposing disk partition nodes.
2020-12-27Kernel: Add a method to determine the desired permissions of a DeviceLiav A
This method will be used later in DevFS, to set the appropriate permissions for each device node.
2020-12-27Kernel: Convert read_block method to get a reference instead of pointerLiav A
BlockBasedFileSystem::read_block method should get a reference of a UserOrKernelBuffer. If we need to force caching a block, we will call other method to do so.
2020-12-27AK: Use direct-list-initialization for Vector::empend() (#4564)Nathan Lanza
clang trunk with -std=c++20 doesn't seem to properly look for an aggregate initializer here when the type being constructed is a simple aggregate (e.g. `struct Thing { int a; int b; };`). This template fails to compile in a usage added 12/16/2020 in `AK/Trie.h`. Both forms of initialization are supposed to call the aggregate-initializers but direct-list-initialization delegating to aggregate initializers is a new addition in c++20 that might not be implemented yet.
2020-12-27Kernel: CoreDump::write_program_headers: set NOTE p_memsz to p_fileszBrendan Coles
2020-12-27Kernel: Allow sys$rename() to rename symlinksAndreas Kling
Previously, this syscall would try to rename the target of the link, not the link itself.
2020-12-27Kernel: Tag more methods and types as [[nodiscard]]Brian Gianforcaro
Tag methods at where not obvserving the return value is an obvious error with [[nodiscard]] to catch potential future bugs.
2020-12-27Kernel: Take into account the time keeper's frequency (if no HPET)Tom
The PIT is now also running at a rate of ~250 ticks/second, so rather than assuming there are 1000 ticks/second we need to query the timer being used for the actual frequency. Fixes #4508
2020-12-27Kernel: Remove the per-process icon_id and sys$set_process_icon()Andreas Kling
This was a goofy kernel API where you could assign an icon_id (int) to a process which referred to a global shbuf with a 16x16 icon bitmap inside it. Instead of this, programs that want to display a process icon now retrieve it from the process executable instead.
2020-12-27Kernel: Expose process executable paths in /proc/allAndreas Kling
2020-12-27Kernel: Lock target process when generating core dumpAndreas Kling
Dumping core can happen at the end of a profiling run, and in that case we have to protect the target process and take the lock while iterating over its region map. Fixes #4509.
2020-12-26Kernel: Remove subheap from list before removing memoryTom
When the ExpandableHeap calls the remove_memory function, the subheap is assumed to be removed and freed entirely. remove_memory may drop the underlying memory at any time, but it also may cause further allocation requests. Not removing it from the list before calling remove_memory could cause a memory allocation in that subheap while remove_memory is executing. which then causes issues once the underlying memory is actually freed.
2020-12-26Kernel: Allow 'elevating' unveil permissions if implicitly inherited from '/'AnotherTest
This can happen when an unveil follows another with a path that is a sub-path of the other one: ```c++ unveil("/home/anon/.config/whoa.ini", "rw"); unveil("/home/anon", "r"); // this would fail, as "/home/anon" inherits // the permissions of "/", which is None. ```
2020-12-26Kernel: Implement unveil() as a prefix-treeAnotherTest
Fixes #4530.
2020-12-26Everywhere: void arguments to C functionsLenny Maiorani
Problem: - C functions with no arguments require a single `void` in the argument list. Solution: - Put the `void` in the argument list of functions in C header files.
2020-12-26LibC: Enable compiler warnings for printf format stringsSahan Fernando
2020-12-26Kernel: Reset the process dumpable flag on successful non-setid execAndreas Kling
Once we've committed to a new memory layout and non-setid credentials, we can reset the dumpable flag.
2020-12-25Kernel+LibC: Introduce a "dumpable" flag for processesAndreas Kling
This new flag controls two things: - Whether the kernel will generate core dumps for the process - Whether the EUID:EGID should own the process's files in /proc Processes are automatically made non-dumpable when their EUID or EGID is changed, either via syscalls that specifically modify those ID's, or via sys$execve(), when a set-uid or set-gid program is executed. A process can change its own dumpable flag at any time by calling the new sys$prctl(PR_SET_DUMPABLE) syscall. Fixes #4504.
2020-12-25Kernel: Make /proc/PID directories owned by the EUID:EGIDAndreas Kling
This is instead of the UID:GID, since that was allowing some very bad information leaks like spawning "su" as an unprivileged user and having full /proc access to it. Work towards #4504.
2020-12-25Kernel: Fix build with E1000_DEBUGAndreas Kling
2020-12-25AK: Remove custom %w format string specifierAndreas Kling
This was a non-standard specifier alias for %04x. This patch replaces all uses of it with new-style formatting functions instead.
2020-12-25AK: Remove custom %b format string specifierAndreas Kling
This was a non-standard specifier alias for %02x. This patch replaces all uses of it with new-style formatting functions instead.
2020-12-25Kernel: Allocate new main thread stack before committing to execAndreas Kling
If the allocation fails (e.g ENOMEM) we want to simply return an error from sys$execve() and continue executing the current executable. This patch also moves make_userspace_stack_for_main_thread() out of the Thread class since it had nothing in particular to do with Thread.
2020-12-25Kernel: Move ELF auxiliary vector building out of Process classAndreas Kling
Process had a couple of members whose only purpose was holding on to some temporary data while building the auxiliary vector. Remove those members and move the vector building to a free function in execve.cpp
2020-12-25LibELF: Move AuxiliaryValue into the ELF namespaceAndreas Kling
2020-12-25Kernel+LibELF: Abort ELF executable load sooner when something failsAndreas Kling
Make it possible to bail out of ELF::Image::for_each_program_header() and then do exactly that if something goes wrong during executable loading in the kernel. Also make the errors we return slightly more nuanced than just ENOEXEC.
2020-12-25Kernel: Remove an unnecessary cast in sys$execve()Andreas Kling
2020-12-25Kernel: Don't fetch full inode metadata in sys$execve()Andreas Kling
We only need the size, so let's not fetch all the metadata.
2020-12-25Kernel: Add back missing ELF::Image validity checkAndreas Kling
If the image is not a valid ELF we should just fail ASAP.
2020-12-25Kernel: Convert dbg() => dbgln() in sys$execve()Andreas Kling
2020-12-25Kernel: Add formatter for VirtualAddressAndreas Kling
2020-12-25Kernel: Simplify ELF loading logic in sys$execve() somewhatAndreas Kling
Get rid of the lambda functions and put the logic inline in the program header traversal loop instead. This makes the code quite a bit shorter and hopefully makes it easier to see what's going on.