summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls
AgeCommit message (Collapse)Author
2021-05-07Kernel: Move process creation perf events to PerformanceManagerBrian Gianforcaro
2021-05-07Kernel: Add PerformanceManager static class, move perf event APIs thereBrian Gianforcaro
The current method of emitting performance events requires a bit of boiler plate at every invocation, as well as having to ignore the return code which isn't used outside of the perf event syscall. This change attempts to clean that up by exposing high level API's that can be used around the code base.
2021-05-05Kernel: Modify TimeManagement::current_time(..) API so it can't fail. (#6869)Brian Gianforcaro
The fact that current_time can "fail" makes its use a bit awkward. All callers in the Kernel are trusted besides syscalls, so assert that they never get there, and make sure all current callers perform validation of the clock_id with TimeManagement::is_valid_clock_id(). I have fuzzed this change locally for a bit to make sure I didn't miss any obvious regression.
2021-05-02Kernel: Change Inode::{read/write}_bytes interface to KResultOr<ssize_t>Brian Gianforcaro
The error handling in all these cases was still using the old style negative values to indicate errors. We have a nicer solution for this now with KResultOr<T>. This change switches the interface and then all implementers to use the new style.
2021-05-01Kernel: Make processes start with a 16-byte-aligned stackSahan Fernando
2021-05-01Kernel: Harden sys$setgroups Vector usage against OOMBrian Gianforcaro
2021-04-30Kernel+LibELF: Support initializing values of TLS dataItamar
Previously, TLS data was always zero-initialized. To support initializing the values of TLS data, sys$allocate_tls now receives a buffer with the desired initial data, and copies it to the master TLS region of the process. The DynamicLinker gathers the initial TLS image and passes it to sys$allocate_tls. We also now require the size passed to sys$allocate_tls to be page-aligned, to make things easier. Note that this doesn't waste memory as the TLS data has to be allocated in separate pages anyway.
2021-04-30Kernel: Give a name to the Master TLS region allocationItamar
2021-04-30Kernel: Accepted socket file descriptors should not inherit flagsGunnar Beutner
For example Linux accepts an additional argument for flags in accept4() that let the user specify what flags they want. However, by default accept() should not inherit those flags from the listener socket.
2021-04-30Kernel/LibC: Implement `setreuid`Jesse Buhagiar
2021-04-29Kernel: Harden sys$select Vector usage against OOM.Brian Gianforcaro
Theoretically the append should never fail as we have in-line storage of FD_SETSIZE, which should always be enough. However I'm planning on removing the non-try variants of AK::Vector when compiling in kernel mode in the future, so this will need to go eventually. I suppose it also protects against some unforeseen bug where we we can append more than FD_SETSIZE items.
2021-04-29Kernel: Harden sys$munmap Vector usage against OOM.Brian Gianforcaro
Theoretically the append should never fail as we have in-line storage of 2, which should be enough. However I'm planning on removing the non-try variants of AK::Vector when compiling in kernel mode in the future, so this will need to go eventually. I suppose it also protects against some unforeseen bug where we we can append more than 2 items.
2021-04-29Kernel: Harden sys$purge Vector usage against OOM.Brian Gianforcaro
sys$purge() is a bit unique, in that it is probably in the systems advantage to attempt to limp along if we hit OOM while processing the vmobjects to purge. This change modifies the algorithm to observe OOM and continue trying to purge any previously visited VMObjects.
2021-04-29Kernel: Harden sys$poll Vector usage against OOM.Brian Gianforcaro
2021-04-29Kernel: Harden sys$execve Vector usage against OOM.Brian Gianforcaro
2021-04-29Kernel: Harden sys$readv / sys$writev Vector usage against OOM.Brian Gianforcaro
2021-04-29Kernel: Harden sys$sendmsg / sys$recvmsg Vector usage against OOM.Brian Gianforcaro
2021-04-28Kernel: Avoid overrunning the user-specified buffers in select()Gunnar Beutner
2021-04-28Kernel+LibC: Implement the socketpair() syscallGunnar Beutner
2021-04-27Kernel: Check futex command if realtime clock is usedJelle Raaijmakers
2021-04-26Kernel: Fix incorrect argument for thread_exit eventsGunnar Beutner
2021-04-26Kernel: Log thread exits for global profilesGunnar Beutner
2021-04-26Kernel: Avoid calling characters() where not necessaryGunnar Beutner
2021-04-26Kernel+Profiler: Improve profiling subsystemGunnar Beutner
This turns the perfcore format into more a log than it was before, which lets us properly log process, thread and region creation/destruction. This also makes it unnecessary to dump the process' regions every time it is scheduled like we did before. Incidentally this also fixes 'profile -c' because we previously ended up incorrectly dumping the parent's region map into the profile data. Log-based mmap support enables profiling shared libraries which are loaded at runtime, e.g. via dlopen(). This enables profiling both the parent and child process for programs which use execve(). Previously we'd discard the profiling data for the old process. The Profiler tool has been updated to not treat thread IDs as process IDs anymore. This enables support for processes with more than one thread. Also, there's a new widget to filter which process should be displayed.
2021-04-25Everywhere: Remove empty line after function body opening curly braceLinus Groh
2021-04-25Kernel: Remove the now defunct `LOCKER(..)` macro.Brian Gianforcaro
2021-04-24Kernel: Support null act argument for sigaction syscallJelle Raaijmakers
Userspace can provide a null argument for the `act` argument to the `sigaction` syscall to not set any new behavior. This is described here: https://pubs.opengroup.org/onlinepubs/007904875/functions/sigaction.html Without this fix, the `copy_from_user(...)` invocation on `user_act` fails and makes the syscall return early.
2021-04-23AK: Rename adopt() to adopt_ref()Andreas Kling
This makes it more symmetrical with adopt_own() (which is used to create a NonnullOwnPtr from the result of a naked new.)
2021-04-23Kernel: Don't allow to kill kernel processesMaciej Zygmanowski
The protection was only for SIGKILL before.
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-20Kernel: Remove requirement for the thread entitlement for the futex syscallGunnar Beutner
GCC inserts calls to pthread_mutex_lock when compiling C++ code with threads enabled.
2021-04-19Kernel: Add a syscall to clear the profiling bufferBrian Gianforcaro
While profiling all processes the profile buffer lives forever. Once you have copied the profile to disk, there's no need to keep it in memory. This syscall surfaces the ability to clear that buffer.
2021-04-18Kernel: Add ptrace commands for reading/writing the debug registersFalseHonesty
This adds PT_PEEKDEBUG and PT_POKEDEBUG to allow for reading/writing the debug registers, and updates the Kernel's debug handler to read the new information from the debug status register.
2021-04-18Kernel+LibC: Clean up how assertions work in the kernel and LibCGunnar Beutner
This also brings LibC's abort() function closer to the spec.
2021-04-18Kernel: Allow system calls from the dynamic loaderGunnar Beutner
Previously the dynamic loader would become unused after it had invoked the program's entry function. However, in order to support exceptions and - at a later point - dlfcn functionality we need to call back into the dynamic loader at runtime. Because the dynamic loader has a static copy of LibC it'll attempt to invoke syscalls directly from its text segment. For this to work the executable region for the dynamic loader needs to have syscalls enabled.
2021-04-18Everywhere: Fix a bunch of typosLinus Groh
2021-04-14Kernel: Read the ELF header from the inode rather than the mapped pagesGunnar Beutner
Reading from the mapping doesn't work when the text segment has a non-zero offset because in that case the first mapped page doesn't contain the ELF header.
2021-04-14Kernel: Make sure the offset stays the same when using mremap()Gunnar Beutner
When using mmap() on a file with a non-zero offset subsequent calls to mremap() would incorrectly reset the offset to zero.
2021-04-12Kernel: Replace process' regions vector with a Red Black treeIdan Horowitz
This should provide some speed up, as currently searches for regions containing a given address were performed in O(n) complexity, while this container allows us to do those in O(logn).
2021-04-12Kernel: Remove old region from process' regions vector before splittingIdan Horowitz
This does not affect functionality right now, but it means that the regions vector will now never have any overlapping regions, which will allow the use of balance binary search trees instead of a vector in the future. (since they require keys to be exclusive)
2021-04-03Kernel: Introduce a new HID subsystemLiav A
The end goal of this commit is to allow to boot on bare metal with no PS/2 device connected to the system. It turned out that the original code relied on the existence of the PS/2 keyboard, so VirtualConsole called it even though ACPI indicated the there's no i8042 controller on my real machine because I didn't plug any PS/2 device. The code is much more flexible, so adding HID support for other type of hardware (e.g. USB HID) could be much simpler. Briefly describing the change, we have a new singleton called HIDManagement, which is responsible to initialize the i8042 controller if exists, and to enumerate its devices. I also abstracted a bit things, so now every Human interface device is represented with the HIDDevice class. Then, there are 2 types of it - the MouseDevice and KeyboardDevice classes; both are responsible to handle the interface in the DevFS. PS2KeyboardDevice, PS2MouseDevice and VMWareMouseDevice classes are responsible for handling the hardware-specific interface they are assigned to. Therefore, they are inheriting from the IRQHandler class.
2021-03-29Kernel: Support write() after setting O_APPEND on a non-seekable fileItamar
Previously, Process::do_write would error if the O_APPEND flag was set on a non-seekable file. Other systems (such as Linux) seem to be OK with doing this, so we now do not attempt to seek to the end the file if it's not seekable.
2021-03-29Kernel: Let's also not reverse the blocking flag for FIONBIO..Andreas Kling
2021-03-29Kernel: Let's allow unsetting non-blocking mode with FIONBIO as wellAndreas Kling
Thanks to almightyhydra for pointing this out! :^)
2021-03-28Kernel+LibC: Implement sys$ioctl() FIONBIOAndreas Kling
This is another (older) way of making a file descriptor non-blocking.
2021-03-21Kernel::CPU: Move headers into common directoryHendiadyoin1
Alot of code is shared between i386/i686/x86 and x86_64 and a lot probably will be used for compatability modes. So we start by moving the headers into one Directory. We will probalby be able to move some cpp files aswell.
2021-03-19Kernel: Set TLS-related members of Process after loading static programItamar
We previously ignored these values in the return value of load_elf_object, which causes us to not allocate a TLS region for statically-linked programs.
2021-03-19Kernel: Make FileDescription::seek() return KResultOr<off_t>Andreas Kling
This exposed a bunch of places where errors were not propagated, so this patch is forced to deal with them as well.
2021-03-19Kernel: Refactor storage stack with u64 as mmap offsetJean-Baptiste Boric
2021-03-17LibC+Kernel: Switch off_t to 64 bitsJean-Baptiste Boric