summaryrefslogtreecommitdiff
path: root/Kernel/API
AgeCommit message (Collapse)Author
2023-02-06Kernel: Protect Thread::m_name with a spinlockSam Atkins
This replaces manually grabbing the thread's main lock. This lets us remove the `get_thread_name` and `set_thread_name` syscalls from the big lock. :^)
2023-02-06Kernel: Protect Process::m_name with a spinlockSam Atkins
This also lets us remove the `get_process_name` and `set_process_name` syscalls from the big lock. :^)
2023-02-06Kernel: Remove create_inode_watcher syscall from the big lockSam Atkins
2023-02-06Kernel: Remove pledge syscall from the big lockSam Atkins
This already does all its dangerous work inside `with_mutable_protected_data()`.
2023-02-03Kernel/aarch64: Include Error.h to fix aarch64 missing ErrorOrSteffen Rusitschka
2023-02-02Kernel: Remove trap based syscall handlingAgustin Gianni
This patch removes the x86 mechanism for calling syscalls, favoring the more modern syscall instruction. It also moves architecture dependent code from functions that are meant to be architecture agnostic therefore paving the way for adding more architectures.
2023-01-21Kernel+Libraries: Don't include limits.h from LibELF/Validation.hAndrew Kaster
The fallout of this is that Kernel/Syscalls/execve.cpp doesn't have access to ARG_MAX anymore, so move that definition to Kernel/API as well
2023-01-21Kernel+Libraries: Move defines and types from sys/auxv.h to Kernel/APIAndrew Kaster
And don't include <sys/auxv.h> from LibELF/AuxiliaryVector.h, to reduce the number of Kernel files that include LibC headers.
2023-01-21Kernel+Userland: Move LibC/sys/ioctl_numbers to Kernel/API/Ioctl.hAndrew Kaster
This header has always been fundamentally a Kernel API file. Move it where it belongs. Include it directly in Kernel files, and make Userland applications include it via sys/ioctl.h rather than directly.
2023-01-21Kernel+LibC: Move name length constants to Kernel/API from limits.hAndrew Kaster
Reduce inclusion of limits.h as much as possible at the same time. This does mean that kmalloc.h is now including Kernel/API/POSIX/limits.h instead of LibC/limits.h, but the scope could be limited a lot more. Basically every file in the kernel includes kmalloc.h, and needs the limits.h include for PAGE_SIZE.
2023-01-21Kernel+LibC: Move LibC/signal_numbers.h to Kernel/API/POSIXAndrew Kaster
Make Userland and Tests users just include signal.h, and move Kernel users to the new API file.
2023-01-10Kernel+LibCore: Make %sid path parsing not take agesAndreas Kling
Before this patch, Core::SessionManagement::parse_path_with_sid() would figure out the root session ID by sifting through /sys/kernel/processes. That file can take quite a while to generate (sometimes up to 40ms on my machine, which is a problem on its own!) and with no caching, many of our programs were effectively doing this multiple times on startup when unveiling something in /tmp/session/%sid/ While we should find ways to make generating /sys/kernel/processes fast again, this patch addresses the specific problem by introducing a new syscall: sys$get_root_session_id(). This extracts the root session ID by looking directly at the process table and takes <1ms instead of 40ms. This cuts WebContent process startup time by ~100ms on my machine. :^)
2022-12-28Kernel: Remove i686 supportLiav A
2022-12-16Kernel/Memory: Add option to annotate region mapping as immutableLiav A
We add this basic functionality to the Kernel so Userspace can request a particular virtual memory mapping to be immutable. This will be useful later on in the DynamicLoader code. The annotation of a particular Kernel Region as immutable implies that the following restrictions apply, so these features are prohibited: - Changing the region's protection bits - Unmapping the region - Annotating the region with other virtual memory flags - Applying further memory advises on the region - Changing the region name - Re-mapping the region
2022-12-16Kernel: Reintroduce the msyscall syscall as the annotate_mapping syscallLiav A
This syscall will be used later on to ensure we can declare virtual memory mappings as immutable (which means that the underlying Region is basically immutable for both future annotations or changing the protection bits of it).
2022-12-11Kernel: Bump maximum pthread stack size to 32MiBsin-ack
The Zig compiler asks for this much stack on its main thread via the use of PT_GNU_STACK.
2022-12-11Kernel+LibC+LibELF: Set stack size based on PT_GNU_STACK during execvesin-ack
Some programs explicitly ask for a different initial stack size than what the OS provides. This is implemented in ELF by having a PT_GNU_STACK header which has its p_memsz set to the amount that the program requires. This commit implements this policy by reading the p_memsz of the header and setting the main thread stack size to that. ELF::Image::validate_program_headers ensures that the size attribute is a reasonable value.
2022-12-11Kernel+LibC+Tests: Implement `pwritev(2)`sin-ack
While this isn't really POSIX, it's needed by the Zig port and was simple enough to implement.
2022-12-11Kernel+LibC: Implement `setregid(2)`sin-ack
This copies and adapts the setresgid syscall, following in the footsteps of setreuid and setresuid.
2022-12-11Kernel+LibC+LibCore+UserspaceEmulator: Implement `faccessat(2)`sin-ack
Co-Authored-By: Daniel Bertalan <dani@danielbertalan.dev>
2022-12-11Kernel+LibC+LibCore: Implement `renameat(2)`sin-ack
Now with the ability to specify different bases for the old and new paths.
2022-12-11Kernel+LibC: Implement `readlinkat(2)`sin-ack
Co-Authored-By: Daniel Bertalan <dani@danielbertalan.dev>
2022-12-11Kernel+LibC+LibCore: Implement `symlinkat(2)`sin-ack
Co-Authored-By: Daniel Bertalan <dani@danielbertalan.dev>
2022-12-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
2022-11-26Kernel+LibCore+LibC: Implement support for forcing unveil on execLiav A
To accomplish this, we add another VeilState which is called LockedInherited. The idea is to apply exec unveil data, similar to execpromises of the pledge syscall, on the current exec'ed program during the execve sequence. When applying the forced unveil data, the veil state is set to be locked but the special state of LockedInherited ensures that if the new program tries to unveil paths, the request will silently be ignored, so the program will continue running without receiving an error, but is still can only use the paths that were unveiled before the exec syscall. This in turn, allows us to use the unveil syscall with a special utility to sandbox other userland programs in terms of what is visible to them on the filesystem, and is usable on both programs that use or don't use the unveil syscall in their code.
2022-11-05LibC: Add missing definitions for IPv6 packet infoClemens Wasser
2022-11-05Kernel: Add support for jailsLiav A
Our implementation for Jails resembles much of how FreeBSD jails are working - it's essentially only a matter of using a RefPtr in the Process class to a Jail object. Then, when we iterate over all processes in various cases, we could ensure if either the current process is in jail and therefore should be restricted what is visible in terms of PID isolation, and also to be able to expose metadata about Jails in /sys/kernel/jails node (which does not reveal anything to a process which is in jail). A lifetime model for the Jail object is currently plain simple - there's simpy no way to manually delete a Jail object once it was created. Such feature should be carefully designed to allow safe destruction of a Jail without the possibility of releasing a process which is in Jail from the actual jail. Each process which is attached into a Jail cannot leave it until the end of a Process (i.e. when finalizing a Process). All jails are kept being referenced in the JailManagement. When a last attached process is finalized, the Jail is automatically destroyed.
2022-11-05Kernel: Make sys$msyscall() not take the big lockAndreas Kling
This function is already serialized by the address space lock.
2022-10-27Kernel+LibC: Report correct scheduling priority limitskleines Filmröllchen
The priority range was changed several years ago, but the userland-reported limits were just forgotten :skeleyak:. Move the thread priority constants into an API header so that userland can use it properly.
2022-10-27Kernel: Make scheduler control syscalls more generickleines Filmröllchen
The syscalls are renamed as they no longer reflect the exact POSIX functionality. They can now handle setting/getting scheduler parameters for both threads and processes.
2022-10-24Kernel: Add definitions for SO_SNDLOWAT and SO_RCVLOWATGunnar Beutner
2022-10-24Kernel: Add definition for MSB_EORGunnar Beutner
None of the protocols we support at the moment use this, but it makes boost happy.
2022-10-24Kernel: Add support for MSG_NOSIGNAL and properly send SIGPIPEGunnar Beutner
Previously we didn't send the SIGPIPE signal to processes when sendto()/sendmsg()/etc. returned EPIPE. And now we do. This also adds support for MSG_NOSIGNAL to suppress the signal.
2022-10-22Kernel+Base: Introduce MS_NOREGULAR mount flagLiav A
This flag doesn't conform to any POSIX standard nor is found in any OS out there. The idea behind this mount flag is to ensure that only non-regular files will be placed in a filesystem, which includes device nodes, symbolic links, directories, FIFOs and sockets. Currently, the only valid case for using this mount flag is for TmpFS instances, where we want to mount a TmpFS but disallow any kind of regular file and only allow other types of files on the filesystem.
2022-10-14Kernel: Implement userspace support for syscalls on AARCH64Gunnar Beutner
There are no guarantees that the final syscall API will look like this but at least for now this lets us compile the userland binaries.
2022-10-10Everywhere: Replace uses of __serenity__ with AK_OS_SERENITYAndrew Kaster
Now that we have OS macros for essentially every supported OS, let's try to use them everywhere.
2022-09-18Kernel: Add missing include in APIBen Wiederhake
This remained undetected for a long time as HeaderCheck is disabled by default. This commit makes the following file compile again: // file: compile_me.cpp #include <Kernel/API/POSIX/ucontext.h> // That's it, this was enough to cause a compilation error.
2022-08-23Kernel: Remove big lock from sys$socketJames Bellamy
With the implementation of the credentials object the socket syscall no longer needs the big lock.
2022-08-22Kernel: Make sys$utime() and sys$utimensat() not take the big lockAndreas Kling
2022-08-22Kernel: Make sys$mknod() not take the big lockAndreas Kling
2022-08-21Kernel: Make sys$getppid() not take the big lockAndreas Kling
This only needs to access the process PPID, which is protected by the "protected data" lock.
2022-08-20Kernel+LibC: Enforce a limit on the number of supplementary group IDsAndreas Kling
This patch adds the NGROUPS_MAX constant and enforces it in sys$setgroups() to ensure that no process has more than 32 supplementary group IDs. The number doesn't mean anything in particular, just had to pick a number. Perhaps one day we'll have a reason to change it.
2022-08-20Kernel: Mark syscalls that get/set user/group ID as not needing big lockAndreas Kling
Now that these operate on the neatly atomic and immutable Credentials object, they should no longer require the process big lock for synchronization. :^)
2022-08-18Kernel: Make sys$unveil() not take the big process lockSamuel Bowman
The unveil syscall uses the UnveilData struct which is already SpinlockProtected, so there is no need to take the big lock.
2022-08-16Kernel: Make sys$socketpair() not take the big lockAndreas Kling
This system call mainly accesses the file descriptor table, and this is already guarded by MutexProtected.
2022-08-16Kernel: Make sys$pipe() not take the big lockAndreas Kling
This system call mainly accesses the file descriptor table, and this is already guarded by MutexProtected.
2022-08-15Kernel: Shrink default userspace stack size from 4 MiB to 1 MiBAndreas Kling
This knocks 70 MiB off our idle footprint, (from 350 MiB to 280 MiB.)
2022-07-25Kernel/LibC: Implement posix syscall clock_getres()zzLinus
2022-07-23Kernel+Userland: Add ioctl to set process ownership of DisplayConnectorLiav A
Now that the infrastructure of the Graphics subsystem is quite stable, it is time to try to fix a long-standing problem, which is the lack of locking on display connector devices. Reading and writing from multiple processes to a framebuffer controlled by the display connector is not a huge problem - it could be solved with POSIX locking. The real problem is some program that will try to do ioctl operations on a display connector without the WindowServer being aware of that which can lead to very bad situations, for example - assuming a framebuffer is encoded at a known resolution and certain display timings, but another process changed the ModeSetting of the display connector, leading to inconsistency on the properties of the current ModeSetting. To solve this, there's a new "master" ioctl to take "ownership" and another one to release that ownership of a display connector device. To ensure we will not hold a Process object forever just because it has an ownership over a display connector, we hold it with a weak reference, and if the process is gone, someone else can take an ownership.
2022-07-23Kernel+Userland: Rename FB.h => Graphics.hLiav A
This header file represents the entire interface between the kernel and userland, and as such, no longer should be called FB.h but something that represents the whole graphics subsystem.