summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls
AgeCommit message (Collapse)Author
2022-08-23Kernel: Fix boot profilingSamuel Bowman
Boot profiling was previously broken due to init_stage2() passing the event mask to sys$profiling_enable() via kernel pointer, but a user pointer is expected. To fix this, I added Process::profiling_enable() as an alternative to Process::sys$profiling_enable which takes a u64 rather than a Userspace<u64 const*>. It's a bit of a hack, but it works.
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-22Kernel: Use Process::credentials() and remove user ID/group ID helpersAnthony Iacono
Move away from using the group ID/user ID helpers in the process to allow for us to take advantage of the immutable credentials instead.
2022-08-21Kernel: Make sys$recvfrom() with MSG_DONTWAIT not so racyAndreas Kling
Instead of temporary changing the open file description's "blocking" flag while doing a non-waiting recvfrom, we instead plumb the currently wanted blocking behavior all the way through to the underlying socket.
2022-08-21Kernel: Make Socket::connect() take credentials as inputAndreas Kling
2022-08-21Kernel: Make Socket::bind() take credentials as inputAndreas Kling
2022-08-21Kernel: Make File::{chown,chmod} take credentials as inputAndreas Kling
...instead of getting them from Process::current(). :^)
2022-08-21Kernel: Make VirtualFileSystem functions take credentials as inputAndreas Kling
Instead of getting credentials from Process::current(), we now require that they be provided as input to the various VFS functions. This ensures that an atomic set of credentials is used throughout an entire VFS operation.
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-21Kernel: Guard Process "protected data" with a spinlockAndreas Kling
This ensures that both mutable and immutable access to the protected data of a process is serialized. Note that there may still be multiple TOCTOU issues around this, as we have a bunch of convenience accessors that make it easy to introduce them. We'll need to audit those as well.
2022-08-21Kernel: Use RefPtr instead of LockRefPtr for CustodyAndreas Kling
By protecting all the RefPtr<Custody> objects that may be accessed from multiple threads at the same time (with spinlocks), we remove the need for using LockRefPtr<Custody> (which is basically a RefPtr with a built-in spinlock.)
2022-08-21Kernel/Syscall: Make anon_create to not use Process::allocate_fd methodLiav A
Instead, allocate when acquiring the lock on m_fds struct, which is safer to do in terms of safely mutating the m_fds struct, because we don't use the big process lock in this syscall.
2022-08-20Kernel: Get GID from credentials object in sys$setgroups()Andreas Kling
I missed one instance of these. Thanks Anthony Iacono for spotting it!
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-20Kernel: Add Credentials to hold a set of user and group IDsAndreas Kling
This patch adds a new object to hold a Process's user credentials: - UID, EUID, SUID - GID, EGID, SGID, extra GIDs Credentials are immutable and child processes initially inherit the Credentials object from their parent. Whenever a process changes one or more of its user/group IDs, a new Credentials object is constructed. Any code that wants to inspect and act on a set of credentials can now do so without worrying about data races.
2022-08-20Kernel: Make self-contained locking smart pointers their own classesAndreas Kling
Until now, our kernel has reimplemented a number of AK classes to provide automatic internal locking: - RefPtr - NonnullRefPtr - WeakPtr - Weakable This patch renames the Kernel classes so that they can coexist with the original AK classes: - RefPtr => LockRefPtr - NonnullRefPtr => NonnullLockRefPtr - WeakPtr => LockWeakPtr - Weakable => LockWeakable The goal here is to eventually get rid of the Lock* classes in favor of using external locking.
2022-08-18Kernel: Make sys$anon_create() allocate physical pages immediatelyAndreas Kling
This fixes an issue where a sharing process would map the "lazy committed page" early and then get stuck with that page even after it had been replaced in the VMObject by a page fault. Regressed in 27c1135d307efde8d9baef2affb26be568d50263, which made it happen every time with the backing bitmaps used for WebContent.
2022-08-18Kernel: Fix TOCTOU in sys$unveil()Andreas Kling
Make sure we reject the unveil attempt with EPERM if the veil was locked by another thread while we were parsing argument (and not holding the veil state spinlock.) Thanks Brian for spotting this! :^) Amendment to #14907.
2022-08-18Kernel: Don't do path resolution in sys$chdir() while holding spinlockAndreas Kling
Path resolution may do blocking I/O so we must not do it while holding a spinlock. There are tons of problems like this throughout the kernel and we need to find and fix all of them.
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-17Kernel: Require semicolon after VERIFY_{NO_,}PROCESS_BIG_LOCK_ACQUIREDLinus Groh
This matches out general macro use, and specifically other verification macros like VERIFY(), VERIFY_NOT_REACHED(), VERIFY_INTERRUPTS_ENABLED(), and VERIFY_INTERRUPTS_DISABLED().
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: Only lock file descriptor table once in sys$pipe()Andreas Kling
Instead of locking it twice, we now frontload all the work that doesn't touch the fd table, and then only lock it towards the end of the syscall. The benefit here is simplicity. The downside is that we do a bit of unnecessary work in the EMFILE error case, but we don't need to optimize that case anyway.
2022-08-16Kernel: Don't leak file descriptors in sys$pipe()Andreas Kling
If the final copy_to_user() call fails when writing the file descriptors to the output array, we have to make sure the file descriptors don't remain in the process file descriptor table. Otherwise they are basically leaked, as userspace is not aware of them. This matches the behavior of our sys$socketpair() implementation.
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-16Kernel: Remove unnecessary TOCTOU bug in sys$pipe()Andreas Kling
We don't need to explicitly check for EMFILE conditions before doing anything in sys$pipe(). The fd allocation code will take care of it for us anyway.
2022-08-15Kernel: Leak a ref() on the new Process ASAP in sys$fork()Andreas Kling
This fixes an issue where failing the fork due to OOM or other error, we'd end up destroying the Process too early. By the time we got to WaitBlockerSet::finalize(), it was long gone.
2022-08-10Kernel: Validate the sys$alarm signal send always succeedsBrian Gianforcaro
Previously we were ignoring this return code, instead use MUST(..) to make sure it always succeeds.
2022-07-27Everywhere: Make the codebase more architecture awareUndefine
2022-07-25Kernel/LibC: Implement posix syscall clock_getres()zzLinus
2022-07-22Kernel+LibC: Don't hardcode the maximum signal number everywhereTim Schumacher
2022-07-21Kernel: Support F_SETLKW in fcntlIdan Horowitz
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-21Kernel: Remove the Socket::{protocol,}connect ShouldBlock argumentIdan Horowitz
This argument is always set to description.is_blocking(), but description is also given as a separate argument, so there's no point to piping it through separately.
2022-07-15Kernel: Try to set [cm]time in Inode::did_modify_contentsHendiadyoin1
This indirectly resolves a fixme in sys$msync
2022-07-15Kernel: Handle multiple regions in sys$msyncHendiadyoin1
2022-07-15Kernel+LibC: Add posix_fallocate syscallHendiadyoin1
2022-07-15Kernel: Use find_last_split_view to get the executable name in do_execHendiadyoin1
2022-07-12Everywhere: Use default StringView constructor over nullptrsin-ack
While null StringViews are just as bad, these prevent the removal of StringView(char const*) as that constructor accepts a nullptr. No functional changes.
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: Stop leaking first thread on errors in sys$forkIdan Horowitz
Until the thread is first set as Runnable at the end of sys$fork, its state is Invalid, and as a result, the Finalizer which is searching for Dying threads will never find it if the syscall short-circuits due to an error condition like OOM. This also meant the parent Process of the thread would be leaked as well.
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-10Kernel: Stop reporting POLLHUP exclusively when available in sys$pollIdan Horowitz
As per Dr. Posix, unlike POLLERR and POLLNVAL, POLLHUP is only mutually exclusive with POLLOUT, all other events may be reported together with it.
2022-07-10Kernel: Report POLLNVAL events in sys$poll instead of returning EBADFIdan Horowitz
As required by Dr. Posix.
2022-07-10Kernel: Stop providing POLLRDHUP events in sys$poll by defaultIdan Horowitz
Dr. Posix specifies that only POLLERR, POLLHUP & POLLNVAL are provided by default.
2022-07-10Kernel: Set POLLHUP on WriteHangUp in sys$poll instead of POLLNVALIdan Horowitz
POLLNVAL signifies an invalid fd, not a write hang up.
2022-07-10Kernel: Accept SHUT_RD and SHUT_WR as shutdown() how valuesIdan Horowitz
The previous check for valid how values assumed this field was a bitmap and that SHUT_RDWR was simply a bitwise or of SHUT_RD and SHUT_WR, which is not the case.