summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2022-11-13Kernel: Disallow jail creation from a process within a jailLiav A
We now disallow jail creation from a process within a jail because there is simply no valid use case to allow it, and we will probably not enable this behavior (which is considered a bug) again. Although there was no "real" security issue with this bug, as a process would still be denied to join that jail, there's an information reveal about the amount of jails that are or were present in the system.
2022-11-12Kernel/USB: Use proper verbs for Pipe transfer methodsb14ckcat
2022-11-12Kernel/USB: Add support for async & interrupt transfersb14ckcat
Add support for async transfers by using a separate kernel task to poll a list of active async transfers on a set time interval, and invoke their user-provided callback function when they are complete. Also add support for the interrupt class of transfers, building off of this async functionality.
2022-11-11Kernel: Add missing includes for Mount.h fileLiav A
2022-11-08Everywhere: Clean up "in in" comment typosNico Weber
Includes fetch editorial update https://github.com/whatwg/fetch/commit/3cafbdfc39250!
2022-11-08Kernel: Split the Ext2FileSystem.{cpp,h} files into smaller componentsLiav A
2022-11-08Kernel: Split the ISO9660FileSystem.{cpp,h} files to smaller componentsLiav A
2022-11-08Kernel: Split the DevPtsFS files into smaller componentsLiav A
2022-11-08Kernel: Split the Plan9FileSystem.{cpp,h} file into smaller componentsLiav A
2022-11-08Kernel: Split the ProcFS core file into smaller componentsLiav A
2022-11-08Kernel: Split the FATFileSystem.{cpp,h} files into smaller componentsLiav A
2022-11-08Kernel: Split the TmpFS core files into smaller componentsLiav A
2022-11-08Kernel: Split the SysFS core files into smaller componentsLiav A
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: Add copy_typed_from_user for non-const Userspace<T*>Liav A
2022-11-05Kernel: Make sys$msyscall() not take the big lockAndreas Kling
This function is already serialized by the address space lock.
2022-11-03Everywhere: Clean up "the the" comment typosNico Weber
2022-11-01AK+Kernel: Handle some allocation failures in IPv4Socket and TCPSocketGunnar Beutner
This adds try_* methods to AK::SinglyLinkedList and AK::SinglyLinkedListWithCount and updates the network stack to use those to gracefully handle allocation failures. Refs #6369.
2022-11-01AK+Kernel: Handle allocation failures in Device::try_make_requestGunnar Beutner
This adds try_* methods to AK::DoublyLinkedList and updates the Device class to use those to gracefully handle allocation failures. Refs #6369.
2022-11-01Kernel: Remove unused #includesGunnar Beutner
2022-11-01Kernel: Decrease number of captured variables for lambdaGunnar Beutner
This decreases the number of bytes necessary to capture the variables for this lambda. The next step will be to remove dynamic allocations from AK::Function which depends on this change to keep the size of AK::Function objects reasonable.
2022-10-27Kernel: Set priority of all threads within a process if requestedkleines Filmröllchen
This is intended to reflect the POSIX sched_setparam API, which has some cryptic language (https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_08_04_01 ) that as far as I can tell implies we should prioritize process scheduling policies over thread scheduling policies. Technically this means that a process must have its own sets of policies that are considered first by the scheduler, but it seems unlikely anyone relies on this behavior in practice. So we just override all thread's policies, making them (at least before calls to pthread_setschedparam) behave exactly like specified on the surface.
2022-10-27Kernel: Prevent regular users from accessing other processes' threadskleines Filmröllchen
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-26Kernel: Remove bunch of unused includes in SysFS/Processes.cppTimon Kruiper
2022-10-26Kernel/aarch64: Unify building kernel source files in CMakeLists.txtTimon Kruiper
This now builds most of the kernel source files for both x86(_64) and the aarch64 build. Also remove a bunch of stubbed functions. :^)
2022-10-26Kernel: Move bar0_space_size declaration out of arch-specific ifdefsTimon Kruiper
This change allows this file to be built for aarch64.
2022-10-26Kernel: Include missing headers for various filesTimon Kruiper
With these missing header files, we can now build these files for aarch64.
2022-10-26Kernel: Don't expose processor information for aarch64 in sysfsTimon Kruiper
We do not (yet) acquire this information for the aarch64 processors.
2022-10-26Kernel: Stub more functions to progress aarch64 buildTimon Kruiper
2022-10-26Kernel: Use generic functions to change interrupt state of ProcessorTimon Kruiper
This allows these files to be built for aarch64.
2022-10-26Kernel/aarch64: Branch to local halt function instead of C++ oneTimon Kruiper
The kernel image grew so much that it wasn't possible to jump to the C++ symbol anymore, since this generated a 'relocation truncated' error when linking.
2022-10-26Kernel: Move PAGE_MASK define to the shared CPU.h headerTimon Kruiper
These are the same for both x86 and aarch64 for now. Also update some include paths to use the generic CPU.h header.
2022-10-25Kernel+Userland: Move /sys/firmware/power_state to /sys/kernel directoryLiav A
Let's put the power_state global node into the /sys/kernel directory, because that directory represents all global nodes and variables being related to the Kernel. It's also a mutable node, that is more acceptable being in the mentioned directory due to the fact that all other files in the /sys/firmware directory are just firmware blobs and are not mutable at all.
2022-10-25Kernel/ProcFS: Remove all unnecessary componentsLiav A
Now that all global nodes are located in the /sys/kernel directory, we can safely drop the global nodes in /proc, which includes both /proc/net and /proc/sys directories as well. This in fact leaves the ProcFS to only have subdirectories for processes and the "self" symbolic link to reflect the current process being run.
2022-10-25Kernel: Introduce global variables and stats in /sys/kernel directoryLiav A
The ProcFS is an utter mess currently, so let's start move things that are not related to processes-info. To ensure it's done in a sane manner, we start by duplicating all /proc/ global nodes to the /sys/kernel/ directory, then we will move Userland to use the new directory so the old directory nodes can be removed from the /proc directory.
2022-10-24Kernel/FileSystem: Remove hardcoded unveil path of /usr/lib/Loader.soLiav A
If a program needs to execute a dynamic executable program, then it should unveil /usr/lib/Loader.so by itself and not rely on the Kernel to allow using this binary without any sense of respect to unveil promises being made by the running parent program.
2022-10-24AK+Everywhere: Turn bool keep_empty to an enum in split* functionsdemostanis
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-23Kernel/Graphics: Handle correctly unknown ioctls on a DisplayConnectorLiav A
In such case, we should not assert but instead just return EINVAL.
2022-10-22Kernel/FileSystem: Discard safely filesystems when unmounted last timeLiav A
This commit reached that goal of "safely discarding" a filesystem by doing the following: 1. Stop using the s_file_system_map HashMap as it was an unsafe measure to access pointers of FileSystems. Instead, make sure to register all FileSystems at the VFS layer, with an IntrusiveList, to avoid problems related to OOM conditions. 2. Make sure to cleanly remove the DiskCache object from a BlockBased filesystem, so the destructor of such object will not need to do that in the destruction point. 3. For ext2 filesystems, don't cache the root inode at m_inode_cache HashMap. The reason for this is that when unmounting an ext2 filesystem, we lookup at the cache to see if there's a reference to a cached inode and if that's the case, we fail with EBUSY. If we keep the m_root_inode also being referenced at the m_inode_cache map, we have 2 references to that object, which will lead to fail with EBUSY. Also, it's much simpler to always ask for a root inode and get it immediately from m_root_inode, instead of looking up the cache for that inode.
2022-10-22Kernel: Append root filesystem to the VFS FileBackedFileSystem listLiav A
2022-10-22Kernel: Introduce support for using FileSystem object in multiple mountsLiav A
The idea is to enable mounting FileSystem objects across multiple mounts in contrast to what happened until now - each mount has its own unique FileSystem object being attached to it. Considering a situation of mounting a block device at 2 different mount points at in system, there were a couple of critical flaws due to how the previous "design" worked: 1. BlockBasedFileSystem(s) that pointed to the same actual device had a separate DiskCache object being attached to them. Because both instances were not synchronized by any means, corruption of the filesystem is most likely achieveable by a simple cache flush of either of the instances. 2. For superblock-oriented filesystems (such as the ext2 filesystem), lack of synchronization between both instances can lead to severe corruption in the superblock, which could render the entire filesystem unusable. 3. Flags of a specific filesystem implementation (for example, with xfs on Linux, one can instruct to mount it with the discard option) must be honored across multiple mounts, to ensure expected behavior against a particular filesystem. This patch put the foundations to start fix the issues mentioned above. However, there are still major issues to solve, so this is only a start.
2022-10-22Kernel/FileSystem: Add a few missing includesLiav A
In preparation to future commits, we need to ensure that OpenFileDescription.h doesn't include the VirtualFileSystem.h file to avoid include loops.
2022-10-22Kernel+USB: Move descriptor bookkeeping into seperate structure(s)Jesse Buhagiar
We now have a seperately allocated structure for the bookkeeping information in the QueueHead and TransferDescriptor UHCI strucutres. This way, we can support 64-bit pointers in UHCI, fixing a problem where 32-bit pointers would truncate the upper 32-bits of the (virtual) address of the descriptor, causing a crash. Co-authored-by: b14ckcat <b14ckcat@protonmail.com>
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.