summaryrefslogtreecommitdiff
path: root/Kernel/Process.h
AgeCommit message (Collapse)Author
2022-07-25Kernel/LibC: Implement posix syscall clock_getres()zzLinus
2022-07-21Kernel: Clean up sys$futex and add support for cross-process futexesIdan Horowitz
2022-07-21Kernel: Propagate OOM conditions out of sys$futexIdan Horowitz
2022-07-15Kernel+LibC: Add posix_fallocate syscallHendiadyoin1
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
2022-07-10Kernel+LibC+LibCore: Pass fcntl extra argument as pointer-sized variablegggggg-gggggg
The extra argument to fcntl is a pointer in the case of F_GETLK/F_SETLK and we were pulling out a u32, leading to pointer truncation on x86_64. Among other things, this fixes Assistant on x86_64 :^)
2022-07-08Kernel: Implement `sigsuspend` using a SignalBlockerTim Schumacher
`sigsuspend` was previously implemented using a poll on an empty set of file descriptors. However, this broke quite a few assumptions in `SelectBlocker`, as it verifies at least one file descriptor to be ready after waking up and as it relies on being notified by the file descriptor. A bare-bones `sigsuspend` may also be implemented by relying on any of the `sigwait` functions, but as `sigsuspend` features several (currently unimplemented) restrictions on how returns work, it is a syscall on its own.
2022-07-05Kernel: Do a POSIX-correct signal handler reset on execTim Schumacher
2022-06-19Kernel: Create /proc/pid/cmdline to expose process arguments in procfsAndrew Kaster
In typical serenity style, they are just a JSON array
2022-05-21Kernel+LibC+VFS: Implement utimensat(3)Ariel Don
Create POSIX utimensat() library call and corresponding system call to update file access and modification times.
2022-05-06Kernel: Add /proc/{pid}/children to ProcFSMacDue
This exposes the child processes for a process as a directory of symlinks to the respective /proc entries for each child. This makes for an easier and possibly more efficient way to find and count a process's children. Previously the only method was to parse the entire /proc/all JSON file.
2022-04-23Kernel+LibC+LibCore: Implement the unlinkat(2) syscallsin-ack
2022-04-09Kernel: Remove big lock from `sys$set_coredump_metadata`Luke Wilde
The only requirement for this syscall is to make Process::m_coredump_properties SpinlockProtected.
2022-04-06Kernel: Track big lock blocked threads in separate listJelle Raaijmakers
When we lock a mutex, eventually `Thread::block` is invoked which could in turn invoke `Process::big_lock().restore_exclusive_lock()`. This would then try to add the current thread to a different blocked thread list then the one in use for the original mutex being locked, and because it's an intrusive list, the thread is removed from its original list during the `.append()`. When the original mutex eventually unblocks, we no longer have the thread in the intrusive blocked threads list and we panic. Solve this by making the big lock mutex special and giving it its own blocked thread list. Because the process big lock is temporary and is being actively removed from e.g. syscalls, it's a matter of time before we can also remove the fix introduced by this commit. Fixes issue #9401.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-26Kernel: Add a 'no_error' pledge promiseAli Mohammad Pur
This makes pledge() ignore promises that would otherwise cause it to fail with EPERM, which is very useful for allowing programs to run under a "jail" so to speak, without having them termiate early due to a failing pledge() call.
2022-03-22Kernel: Don't assume paths of TTYs and pseudo terminals anymoreLiav A
The obsolete ttyname and ptsname syscalls are removed. LibC doesn't rely on these anymore, and it helps simplifying the Kernel in many places, so it's an overall an improvement. In addition to that, /proc/PID/tty node is removed too as it is not needed anymore by userspace to get the attached TTY of a process, as /dev/tty (which is already a character device) represents that as well.
2022-03-22Kernel: Make mmap validation functions return ErrorOr<void>int16
2022-03-22Kernel: Move mmap validation functions to Processint16
2022-03-08Kernel: Put Process unveil state in a SpinlockProtected containerAndreas Kling
This makes path resolution safe to perform without holding the big lock.
2022-03-08Kernel: Put Process's current directory in a SpinlockProtectedAndreas Kling
Also let's call it "current_directory" instead of "cwd" everywhere.
2022-03-04Kernel: Fill some siginfo and ucontext fields on SA_SIGINFOAli Mohammad Pur
There's no reason to fill in any of these fields if SA_SIGINFO is not given, as the signal handler won't be reading from them at all.
2022-03-04Kernel: Move signal handlers from being thread state to process stateAli Mohammad Pur
POSIX requires that sigaction() and friends set a _process-wide_ signal handler, so move signal handlers and flags inside Process. This also fixes a "pid/tid confusion" FIXME, as we can now send the signal to the process and let that decide which thread should get the signal (which is the thread with tid==pid, but that's now the Process's problem). Note that each thread still retains its signal mask, as that is local to each thread.
2022-02-28Kernel: Add getrusage() syscallLucas CHOLLET
Only the two timeval fields are maintained, as required by the POSIX standard.
2022-02-27Everywhere: Make JSON serialization fallibleIdan Horowitz
This allows us to eliminate a major source of infallible allocation in the Kernel, as well as lay down the groundwork for OOM fallibility in userland.
2022-02-27Kernel: Add OpenFileDescriptions::try_enumerate for fallible iterationIdan Horowitz
This API will allow users to short circuit iteration and properly propagate errors.
2022-02-27Kernel: Add Process::try_for_each_thread() for fallible iterationIdan Horowitz
This API will allow users to short circuit iteration and properly propagate errors.
2022-02-19Kernel: Fixed argument passing for profiling_enable syscallJakub Berkop
Arguments larger than 32bit need to be passed as a pointer on a 32bit architectures. sys$profiling_enable has u64 event_mask argument, which means that it needs to be passed as an pointer. Previously upper 32bits were filled by garbage.
2022-02-16AK+Kernel: Specialize Trie for NNOP<KString> and use it in UnveilNodeIdan Horowitz
This let's us avoid the infallible String allocations.
2022-02-15AK+Kernel: OOM-harden most parts of TrieAli Mohammad Pur
The only part of Unveil that can't handle OOM gracefully is the String::formatted() use in the node metadata.
2022-02-14Kernel/Profiling: Add profiling to read syscallJakub Berkop
Syscalls to read can now be profiled, allowing us to monitor filesystem usage by different applications.
2022-02-13Kernel: Use try_make_weak_ptr() instead of make_weak_ptr()Idan Horowitz
2022-02-13Kernel: Expose maximum argument limit in sysconfAndrew Kaster
Move the definitions for maximum argument and environment size to Process.h from execve.cpp. This allows sysconf(_SC_ARG_MAX) to return the actual argument maximum of 128 KiB to userspace.
2022-01-29Kernel: Stop using HashMap in MutexIdan Horowitz
This commit removes the usage of HashMap in Mutex, thereby making Mutex be allocation-free. In order to achieve this several simplifications were made to Mutex, removing unused code-paths and extra VERIFYs: * We no longer support 'upgrading' a shared lock holder to an exclusive holder when it is the only shared holder and it did not unlock the lock before relocking it as exclusive. NOTE: Unlike the rest of these changes, this scenario is not VERIFY-able in an allocation-free way, as a result the new LOCK_SHARED_UPGRADE_DEBUG debug flag was added, this flag lets Mutex allocate in order to detect such cases when debugging a deadlock. * We no longer support checking if a Mutex is locked by the current thread when the Mutex was not locked exclusively, the shared version of this check was not used anywhere. * We no longer support force unlocking/relocking a Mutex if the Mutex was not locked exclusively, the shared version of these functions was not used anywhere.
2022-01-29Kernel: Switch process file descriptor table from spinlock to mutexAndreas Kling
There's no reason for this to use a spinlock. Instead, let's allow threads to block if someone else is using the descriptor table.
2022-01-29Kernel: Convert process file descriptor table to a SpinlockProtectedAndreas Kling
Instead of manually locking in the various member functions of Process::OpenFileDescriptions, simply wrap it in a SpinlockProtected.
2022-01-17Kernel: Remove non existent friend class from Process.hBrian Gianforcaro
clang-tidy correctly flagged that ProcFSProcessOpenFileDescriptions does not exist.
2022-01-16Kernel: Make Process::m_list_node non-mutableAndreas Kling
The mutable keyword was not achieving anything, so let's remove it.
2022-01-16Kernel: Remove useless return value from procfs_get_thread_stackIdan Horowitz
2022-01-13Kernel: Perform exec-into-new-image directly in sys$execve()Andreas Kling
This ensures that everything allocated on the stack in Process::exec() gets cleaned up. We had a few leaks related to the parsing of shebang (#!) executables that get fixed by this.
2022-01-13Kernel: Convert hostname to KStringIdan Horowitz
2022-01-13Kernel: Make Process::dump_perfcore OOM-fallible using KStringIdan Horowitz
2022-01-12Kernel+LibC+LibCore+UE: Implement `fchmodat(2)`Daniel Bertalan
This function is an extended version of `chmod(2)` that lets one control whether to dereference symlinks, and specify a file descriptor to a directory that will be used as the base for relative paths.
2022-01-07Everywhere: Fix spelling mistakesmjz19910
2021-12-29Kernel: Handle promise violations in the syscall handlerBrian Gianforcaro
Previously we would crash the process immediately when a promise violation was found during a syscall. This is error prone, as we don't unwind the stack. This means that in certain cases we can leak resources, like an OwnPtr / RefPtr tracked on the stack. Or even leak a lock acquired in a ScopeLockLocker. To remedy this situation we move the promise violation handling to the syscall handler, right before we return to user space. This allows the code to follow the normal unwind path, and grantees there is no longer any cleanup that needs to occur. The Process::require_promise() and Process::require_no_promises() functions were modified to return ErrorOr<void> so we enforce that the errors are always propagated by the caller.
2021-12-29Kernel: Remove now unused REQUIRE_PROMISE and REQUIRE_NO_PROMISES macrosBrian Gianforcaro
2021-12-29Kernel: Port Process to ListedRefCountedIdan Horowitz
2021-12-29Kernel: Remove Process::all_processes()Idan Horowitz
This was only used in ProcFS, which can use the `processes()` list just as well, so let's remove it.
2021-12-18Kernel: Make sys${ftruncate,pread} take off_t as const pointerAndreas Kling
These syscalls don't write back to the off_t value (unlike sys$lseek) so let's take Userspace<off_t const*> instead of Userspace<off_t*>.
2021-12-12Kernel+SystemServer: Add /dev/ttyDaniel Bertalan
This file refers to the controlling terminal associated with the current process. It's specified by POSIX, and is used by ports like openssh to interface with the terminal even if the standard input/output is redirected to somewhere else. Our implementation leverages ProcFS's existing facilities to create process-specific symbolic links. In our setup, `/dev/tty` is a symbolic link to `/proc/self/tty`, which itself is a symlink to the appropriate `/dev/pts` entry. If no TTY is attached, `/dev/tty` is left dangling.