summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2021-03-11Kernel: Add MemoryManager::set_page_writable_direct()Andreas Kling
This helper function goes directly to the page tables and makes a virtual address writable or non-writable.
2021-03-11Kernel: Allow kmalloc_aligned() alignment up to 4096Andreas Kling
This allows us to get kmalloc() memory aligned to the VM page size.
2021-03-11Kernel: Silence debug spam about chown and symlink during bootAndreas Kling
2021-03-10Kernel: Move process pledge promises into protected dataAndreas Kling
2021-03-10Kernel: Move process "dumpable" flag into protected dataAndreas Kling
2021-03-10Kernel: Move process parent PID into protected data :^)Andreas Kling
2021-03-10Kernel: Move process extra_gids into protected data :^)Andreas Kling
2021-03-10Kernel: Move select Process members into protected memoryAndreas Kling
Process member variable like m_euid are very valuable targets for kernel exploits and until now they have been writable at all times. This patch moves m_euid along with a whole bunch of other members into a new Process::ProtectedData struct. This struct is remapped as read-only memory whenever we don't need to write to it. This means that a kernel write primitive is no longer enough to overwrite a process's effective UID, you must first unprotect the protected data where the UID is stored. :^)
2021-03-10Kernel: Add non-const KBuffer::impl() getterAndreas Kling
2021-03-10Kernel: Build with -WvlaAndreas Kling
Now that all use of VLA's (variable-length arrays) has been purged from the kernel, let's make sure we don't reintroduce them.
2021-03-10Kernel: Remove VLA usage in Ext2FS block traversal codeAndreas Kling
This was using up to 12KB of kernel stack in the triply indirect case and looks generally spooky. Let's just allocate a ByteBuffer for now and take the performance hit (of heap allocation). Longer term we can reorganize the code to reduce the majority of the heap churn.
2021-03-10Kernel: Turn a VLA into a statically-sized array in dump_backtrace()Andreas Kling
2021-03-09Kernel: Convert klog() => dmesgln() in TCPSocketAndreas Kling
2021-03-09Kernel: Convert klog() => dmesgln() in MemoryManagerAndreas Kling
2021-03-09Kernel: Use dbgln_if() and PANIC() in Thread.cppAndreas Kling
2021-03-09Kernel: Convert klog() => dmesgln() in IPv4SocketAndreas Kling
2021-03-09Kernel: Convert klog() => dmesgln() in PageDirectoryAndreas Kling
2021-03-09Kernel: Convert klog() => dmesgln() in E1000NetworkAdapterAndreas Kling
2021-03-09Kernel: Convert klog() => dmesgln() in init()Andreas Kling
2021-03-09Kernel: Convert klog() => dmesgln() in ARP/routing codeAndreas Kling
2021-03-09Kernel: Convert klog() to dmesgln() in RegionAndreas Kling
2021-03-09Kernel: Convert klog() => dmesgln() in AnonymousVMObjectAndreas Kling
2021-03-09Kernel: Convert klog() => dmesgln() in HPETAndreas Kling
2021-03-09Kernel: Convert klog() => dmesgln() in KernelRngAndreas Kling
2021-03-09Kernel: Convert klog() => dmesgln() in VMWareBackdoorAndreas Kling
2021-03-09Kernel: Convert klog() => dmesgln() in PS2MouseDeviceAndreas Kling
2021-03-09Kernel: Remove some unused things in kmalloc.cppAndreas Kling
2021-03-09Kernel: Convert klog() => dmesgln() in kmallocAndreas Kling
2021-03-09Kernel: Convert klog() => dmesgln() in filesystem codeAndreas Kling
2021-03-09Kernel: Remove ancient FIFO_DEBUG codeAndreas Kling
2021-03-09Kernel+UserspaceEmulator: Add sys$emuctl() system callAndreas Kling
This returns ENOSYS if you are running in the real kernel, and some other result if you are running in UserspaceEmulator. There are other ways we could check if we're inside an emulator, but it seemed easier to just ask. :^)
2021-03-08Kernel: Add bitwise operators for Thread::FileBlocker::BlockFlags enumBrian Gianforcaro
Switch to using type-safe bitwise operators for the BlockFlags class, this cleans up a lot of boilerplate casts which are necessary when the enum is declared as `enum class`.
2021-03-08Kernel: Make MemoryManager API type-safe for Region::Access enumBrian Gianforcaro
Increase type-safety moving the MemoryManager APIs which take a Region::Access to actually use that type instead of a `u8`. Eventually the actually m_access can be moved there as well, but I hit some weird bug where it wasn't using the correct operators in `set_access_bit(..)` even though it's declared (and tested). Something to fix-up later.
2021-03-08Everywhere: Remove unnecessary whitespace at the end of some lines.Emanuele Torre
2021-03-08Kernel: Manually reset the XCR0 registerLuke
According to the Intel manual: "After reset, all bits (except bit 0) in XCR0 are cleared to zero; XCR0[0] is set to 1." Sadly we can't trust this, for example VirtualBox starts with bits 0-4 set, so let's do it ourselves. Fixes #5653
2021-03-07Kernel: Fix pointer over/underflow in create_threadBen Wiederhake
The expression (u8*)params.m_stack_location + stack_size … causes UBSan to spit out the warning KUBSAN: addition of unsigned offset to 0x00000002 overflowed to 0xb0000003 … even though there is no actual overflow happening here. This can be reproduced by running: $ syscall create_thread 0 [ 0 0 0 0 0xb0000001 2 ] Technically, this is a true-positive: The C++-reference is incredibly strict about pointer-arithmetic: > A pointer to non-array object is treated as a pointer to the first element > of an array with size 1. […] [A]ttempts to generate a pointer that isn't > pointing at an element of the same array or one past the end invoke > undefined behavior. https://en.cppreference.com/w/cpp/language/operator_arithmetic Frankly, this feels silly. So let's just use FlatPtr instead. Found by fuzz-syscalls. Undocumented bug. Note that FlatPtr is an unsigned type, so user_esp.value() - 4 is defined even if we end up with a user_esp of 0 (this can happen for example when params.m_stack_size = 0 and params.m_stack_location = 0). The result would be a Kernelspace-pointer, which would then be immediately flagged by 'MM.validate_user_stack' as invalid, as intended.
2021-03-07Kernel: Expose sysctl 'ubsan_is_deadly' to panic the Kernel on UBBen Wiederhake
This makes it easier to find UB, for example when fuzzing the Kernel. This can be enabled by default, thanks to @boricj's work in 32e1354b9b0050dd2920c8506cef2841789e14df.
2021-03-07Kernel: Fix unaligned read inside map_ebda()Jean-Baptiste Boric
2021-03-06Kernel: Address all 32 HPET comparators correctlyLiav A
Instead of declaring a reserved area from byte 0x160 to 0x400, we change the declaration of TimerStructure array to be 32 units. Also, a static_assert was added, to ensure that the calculation is right.
2021-03-06Revert "Kernel: Fix HPET timer structure layout"Liav A
This reverts commit af2220448834fb0bff5132bf68104719819862ce. According to the HPET specification, each theoretical comparator takes 32 bytes in the MMIO space. Although I hardly believe that any system will implement all 32 comparators, in practice if a machine happens to have more than 3 comparators, we need to address the comparators correctly if we want to use them.
2021-03-05Kernel: Implement ScatterList for handling scattered DMA pagesLiav A
This class is used in the AHCI code to handle a big request of read/write to the disk. If we happen to encounter such request, we will get the needed amount of physical pages from the already-allocated physical pages in AHCIPort, and with that we will create a ScatterList that will create a Region that maps all of these pages in a contiguous virtual memory range. Then, we could easily copy to/from this range, before and after calling the operation on the StorageDevice as needed with read or write operations.
2021-03-05Kernel: Add AnonymousVMObject constructor for a Vector of physical pagesLiav A
This will be used later on by the AHCI code to create a Region that spans over scattered DMA pages.
2021-03-05Kernel: Add basic AHCI functionalityLiav A
The hierarchy is AHCIController, AHCIPortHandler, AHCIPort and SATADiskDevice. Each AHCIController has at least one AHCIPortHandler. An AHCIPortHandler is an interrupt handler that takes care of enumeration of handled AHCI ports when an interrupt occurs. Each AHCIPort takes care of one SATADiskDevice, and later on we can add support for Port multiplier. When we implement support of Message signalled interrupts, we can spawn many AHCIPortHandlers, and allow each one of them to be responsible for a set of AHCIPorts.
2021-03-05Kernel: Use global mechanism to determine minor number of Storage DeviceLiav A
2021-03-05Kernel: Make ATA macros to be publicLiav A
2021-03-05Kernel: Add enum values for later implementation of AHCILiav A
2021-03-05Kernel: Add Declaration of IDEChannel class in PATADiskDevice.hLiav A
2021-03-04Kernel: Define a KERNEL_VIRTUAL_BASE in the linker scriptAndreas Kling
Slightly nicer than saying "0xc0000000" over and over.
2021-03-04Kernel: Make the kernel compile & link for x86_64Andreas Kling
It's now possible to build the whole kernel with an x86_64 toolchain. There's no bootstrap code so it doesn't work yet (obviously.)
2021-03-04Kernel: Remove repeated_{in,out}16()Andreas Kling
These were some wrappers around x86 "insw/outsw" that are no longer used for anything, so let's remove them.