summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2021-03-12Kernel: Convert klog() => AK::Format in APICTimerAndreas Kling
2021-03-12Kernel: Convert klog() => AK::Format in ACPI::ParserAndreas Kling
2021-03-12Kernel: Convert klog() => AK::Format in RTL8139NetworkAdapterAndreas Kling
2021-03-12Kernel: Remove debug spam in DevFSAndreas Kling
2021-03-11Everywhere: Rename "logo" key to "super" keyAndreas Kling
This seems to be the most common way to refer to this key, so let's call it what people actually call it.
2021-03-11Kernel: Suppress logging during kmalloc heap expansionAndreas Kling
The system is extremely sensitive to heap allocations during heap expansion. This was causing frequent OOM panics under various loads. Work around the issue for now by putting the logging behind KMALLOC_DEBUG. Ideally dmesgln() & friends would not reqiure any heap allocations, but we're not there right now. Fixes #5724.
2021-03-11Kernel: Always protect process data immediately after constructionAndreas Kling
2021-03-11Kernel: Inherit the dumpable flag on sys$fork()Andreas Kling
This regressed at some point recently. All children were non-dumpable until manually opting into it.
2021-03-11Kernel: Move process termination status/signal into protected dataAndreas Kling
2021-03-11Kernel: Move process thread lists into protected dataAndreas Kling
2021-03-11Kernel: Move process signal trampoline address into protected dataAndreas Kling
2021-03-11Kernel: Move process umask into protected data :^)Andreas Kling
2021-03-11Kernel: Don't keep protected Process data in a separate allocationAndreas Kling
The previous architecture had a huge flaw: the pointer to the protected data was itself unprotected, allowing you to overwrite it at any time. This patch reorganizes the protected data so it's part of the Process class itself. (Actually, it's a new ProcessBase helper class.) We use the first 4 KB of Process objects themselves as the new storage location for protected data. Then we make Process objects page-aligned using MAKE_ALIGNED_ALLOCATED. This allows us to easily turn on/off write-protection for everything in the ProcessBase portion of Process. :^) Thanks to @bugaevc for pointing out the flaw! This is still not perfect but it's an improvement.
2021-03-11Kernel: Add MAKE_ALIGNED_ALLOCATED helper macroAndreas Kling
This macro inserts operator new/delete into a class, allowing you to very easily specify a specific heap alignment.
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.