summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2021-07-27Kernel: Make LoopbackAdapter always link upMaciej Zygmanowski
2021-07-26Kernel: Fix integer overflow in KCOV_SETBUFSIZE ioctlPatrick Meyer
2021-07-27Kernel: Make KCOVDevice::ioctl() return KResultAli Mohammad Pur
Recent ioctl() changes broke this, this commit fixes that and the build.
2021-07-27Kernel: Shutdown on panic in self-test modeLiav A
Instead of doing a reset via triple-fault, let's just shutdown the QEMU virtual machine because this is already a QEMU-specific handling code for Self-Test CI mode.
2021-07-27Kernel: Modify the IOCTL API to return KResultBrian Gianforcaro
The kernel has been gradually moving towards KResult from just bare int's, this change migrates the IOCTL paths.
2021-07-27Kernel+LibC: Use argument for TIOCGPGRP ioctl valueBrian Gianforcaro
In preparation for modifying the Kernel IOCTL API to return KResult instead of int, we need to fix this ioctl to an argument to receive it's return value, instead of using the actual function return value.
2021-07-27Kernel: Utilize AK::Userspace<T> in the ioctl interfaceBrian Gianforcaro
It's easy to forget the responsibility of validating and safely copying kernel parameters in code that is far away from syscalls. ioctl's are one such example, and bugs there are just as dangerous as at the root syscall level. To avoid this case, utilize the AK::Userspace<T> template in the ioctl kernel interface so that implementors have no choice but to properly validate and copy ioctl pointer arguments.
2021-07-26Kernel: Add option to build with coverage instrumentation and KCOVPatrick Meyer
GCC and Clang allow us to inject a call to a function named __sanitizer_cov_trace_pc on every edge. This function has to be defined by us. By noting down the caller in that function we can trace the code we have encountered during execution. Such information is used by coverage guided fuzzers like AFL and LibFuzzer to determine if a new input resulted in a new code path. This makes fuzzing much more effective. Additionally this adds a basic KCOV implementation. KCOV is an API that allows user space to request the kernel to start collecting coverage information for a given user space thread. Furthermore KCOV then exposes the collected program counters to user space via a BlockDevice which can be mmaped from user space. This work is required to add effective support for fuzzing SerenityOS to the Syzkaller syscall fuzzer. :^) :^)
2021-07-26Kernel: Remove invalid '#' format modifier for printing a faulting addrAli Mohammad Pur
This was mistakenly added in 306d898ee56c0d277d865dd4e3afba3d95eab9aa.
2021-07-26Kernel: Un-unmap-after-init CommandLine::boot_mode()Ali Mohammad Pur
This function is now used when the kernel panics, so unmapping it would make the kernel panic while in panic, which is not a good thing :P
2021-07-26Kernel: Show the unmapped-after-init symbol being accessedAli Mohammad Pur
This makes it a lot easier to figure out what unmapped function is being accessed, and a lot easier to reason about _why_ it is being accessed.
2021-07-26Build: Only specify -fzero-call-used-regs with compiler >= GCC 11.1Brian Gianforcaro
This fixes the use case of using clang, or building inside CLion with an older host compiler.
2021-07-26Kernel: Don't try to return a committed page that we don't haveAndreas Kling
When we get a COW fault and discover that whoever we were COW'ing together with has either COW'ed that page on their end (or they have unmapped/exited) we simplify life for ourselves by clearing the COW bit and keeping the page we already have. (No need to COW if the page is not shared!) The act of doing this does not return a committed page to the pool. In fact, that committed page we had reserved for this purpose was used up (allocated) by our COW buddy when they COW'ed the page. This fixes a kernel panic when running TestLibCMkTemp. :^)
2021-07-26Kernel: Clear the COW bits when making an AnonymousVMObject volatileAndreas Kling
2021-07-26Kernel: Make some debug logging in Scheduler CPU agnosticAndreas Kling
2021-07-26Kernel: Remove unused Scheduler::yield_from_critical()Andreas Kling
2021-07-26Kernel: Fix handful of clang-tidy warnings in SchedulerAndreas Kling
All of them "static member accessed through instance".
2021-07-26Kernel: PANIC() instead of manually halting the processor in abort()Ali Mohammad Pur
2021-07-26Kernel: Reset on panic in self-test modeAli Mohammad Pur
This makes a kernel panic immediately fail the on-target CI job. Otherwise the failed job looks like a test timeout unless one digs into the details of the job.
2021-07-25Kernel: Remove ContiguousVMObject, let AnonymousVMObject do the jobAndreas Kling
We don't need an entirely separate VMObject subclass to influence the location of the physical pages. Instead, we simply allocate enough physically contiguous memory first, and then pass it to the AnonymousVMObject constructor that takes a span of physical pages.
2021-07-25Kernel: Run clang-format on AnonymousVMObject.cppAndreas Kling
2021-07-25Utilities: Support static assignment of the ARP tablebrapru
2021-07-25Kernel: Support ioctl SIOCSARP and SIOCDARPbrapru
Creates ioctl calls necessary to set/delete an entry from the ARP table
2021-07-25Kernel: Add update option to remove an entry from the ARP tablebrapru
Allows for specifying whether to set/delete an entry from the table.
2021-07-25Kernel: Remove unnecessary counting of VMObject-attached RegionsAndreas Kling
VMObject already has an IntrusiveList of all the Regions that map it. We were keeping a counter in addition to this, and only using it in a single place to avoid iterating over the list in case it only had 1 entry. Simplify VMObject by removing this counter and always iterating the list even if there's only 1 entry. :^)
2021-07-25Kernel: Remove unused enum Region::SetVolatileErrorAndreas Kling
2021-07-25Kernel: Remove unnecessary weak pointer from Region to owning ProcessAndreas Kling
This was previously used for a single debug logging statement during memory purging. There are no remaining users of this weak pointer, so let's get rid of it.
2021-07-25Kernel: Add missing locking when registering VMObjectDeletedHandlersAndreas Kling
2021-07-25Kernel: Remove unused madvise(MADV_GET_VOLATILE)Andreas Kling
This was used to query the volatile state of a memory region, however nothing ever actually used it.
2021-07-25Kernel: Don't COW volatile VM objectsAndreas Kling
If a purgeable VM object is in the "volatile" state when we're asked to make a COW clone of it, make life simpler by simply "purging" the cloned object right away. This effectively means that a fork()'ed child process will discover its purgeable+volatile regions to be empty if/when it tries making them non-volatile.
2021-07-25Kernel: Minor cleanup around purge() during physical page allocationAndreas Kling
2021-07-25Kernel: Make purgeable memory a VMObject level concept (again)Andreas Kling
This patch changes the semantics of purgeable memory. - AnonymousVMObject now has a "purgeable" flag. It can only be set when constructing the object. (Previously, all anonymous memory was effectively purgeable.) - AnonymousVMObject now has a "volatile" flag. It covers the entire range of physical pages. (Previously, we tracked ranges of volatile pages, effectively making it a page-level concept.) - Non-volatile objects maintain a physical page reservation via the committed pages mechanism, to ensure full coverage for page faults. - When an object is made volatile, it relinquishes any unused committed pages immediately. If later made non-volatile again, we then attempt to make a new committed pages reservation. If this fails, we return ENOMEM to userspace. mmap() now creates purgeable objects if passed the MAP_PURGEABLE option together with MAP_ANONYMOUS. anon_create() memory is always purgeable.
2021-07-25Kernel+LibSystem: Add a 4th syscall argumentAndreas Kling
Let's allow passing 4 function arguments to a syscall. The 4th argument goes into ESI or RSI.
2021-07-24Kernel/NE2000: Harvest entropy from NE2000 interruptsThomas Wagenveld
2021-07-24Kernel/NE2000: Assume link status is upThomas Wagenveld
Right now, NE2000 NICs don't work because the link is down by default and this will never change. Of all the NE2000 documentation I looked at I could not find a link status indicator, so just assume the link is up.
2021-07-24Kernel/NE2000: Correct receive ring buffer wrap-aroundThomas Wagenveld
next_packet_page points to a page, but was being compared to a byte offset rather than a page offset when adjusting the BOUNDARY register when the ring buffer wraps around. Fixes #8327.
2021-07-24Kernel: Put a note about the unconditional unblanking of bochs-displayLiav A
This removes the FIXME note and explains why it's not so bad to do this.
2021-07-23Kernel: Add missing .globl definitionsGunnar Beutner
This ensures that we can properly take the address of these symbols in other code.
2021-07-23Kernel: Mark a few more things as READONLY_AFTER_INITGunnar Beutner
2021-07-23Kernel: Always build the kernel without default libsGunnar Beutner
When building the kernel from within SerenityOS we would link it against default libs which doesn't really make sense to me.
2021-07-23Kernel: Make some of the assembly code position-independent on x86_64Gunnar Beutner
2021-07-23Prekernel: Don't build the prekernel as a PIE imageGunnar Beutner
This is unnecessary because the prekernel is always loaded at a known base address.
2021-07-23Kernel: Make -pie work for x86_64Gunnar Beutner
2021-07-23Kernel: Use StringView when parsing pledges in sys$pledge(..)Brian Gianforcaro
This ensures no potential allocation as in some cases the pledge char* could be promoted to AK::String by the compiler to execute the comparison.
2021-07-23Kernel: Fix bug where we half apply pledges in sys$pledge(..)Brian Gianforcaro
This bug manifests it self when the caller to sys$pledge() passes valid promises, but invalid execpromises. The code would apply the promises and then return an error for the execpromises. This leaves the user in a confusing state, as the promises were silently applied, but we return an error suggesting the operation has failed. Avoid this situation by tweaking the implementation to only apply the promises / execpromises after all validation has occurred.
2021-07-23Kernel: Migrate sys$pledge to use the KString APIBrian Gianforcaro
This avoids potential unhandled OOM that's possible with the old copy_string_from_user API.
2021-07-23Kernel: Annotate kernel_base and friends as READONLY_AFTER_INITBrian Gianforcaro
We don't want kernel_base to be modifiable by an attacker or a stray memory scribbler bug, so lets mark it as READONLY_AFTER_INIT.
2021-07-23Kernel: Migrate sys$unveil to use the KString APIBrian Gianforcaro
This avoids potential unhandled OOM that's possible with the old copy_string_from_user API.
2021-07-23Kernel: Use StringView literals for fs_type match in sys$mount(..)Brian Gianforcaro
2021-07-23Kernel: Remove another ARCH ifdef using RegisterState::flags()Brian Gianforcaro