summaryrefslogtreecommitdiff
path: root/Kernel/Syscall.h
AgeCommit message (Collapse)Author
2020-07-04Kernel: Move headers intended for userspace use into Kernel/API/Andreas Kling
2020-06-24Kernel+LibC: Add sys$recvfd() and sys$sendfd() for fd passingAndreas Kling
These new syscalls allow you to send and receive file descriptors over a local domain socket. This will enable various privilege separation techniques and other good stuff. :^)
2020-06-23LibC+Kernel: Implement ppollNico Weber
ppoll() is similar() to poll(), but it takes its timeout as timespec instead of as int, and it takes an additional sigmask parameter. Change the sys$poll parameters to match ppoll() and implement poll() in terms of ppoll().
2020-06-22LibC: Implement pselectNico Weber
pselect() is similar() to select(), but it takes its timeout as timespec instead of as timeval, and it takes an additional sigmask parameter. Change the sys$select parameters to match pselect() and implement select() in terms of pselect().
2020-06-18Kernel+LibC: Remove setreuid() / setregid() againNico Weber
It looks like they're considered a bad idea, so let's not add them before we need them. I figured it's good to have them in git history if we ever do need them though, hence the add/remove dance.
2020-06-18Kernel+LibC: Implement seteuid() and friends!Nico Weber
Add seteuid()/setegid() under _POSIX_SAVED_IDS semantics, which also requires adding suid and sgid to Process, and changing setuid()/setgid() to honor these semantics. The exact semantics aren't specified by POSIX and differ between different Unix implementations. This patch makes serenity follow FreeBSD. The 2002 USENIX paper "Setuid Demystified" explains the differences well. In addition to seteuid() and setegid() this also adds setreuid()/setregid() and setresuid()/setresgid(), and the accessors getresuid()/getresgid(). Also reorder uid/euid functions so that they are the same order everywhere (namely, the order that geteuid()/getuid() already have).
2020-06-17Kernel: clang-format ENUMERATE_SYSCALLSNico Weber
2020-06-16Kernel: Replace char and u8 data types to u32 for code pointHüseyin ASLITÜRK
Remove character property from event and add code_point property.
2020-05-16Kernel: Remove sys$getdtablesize()Andreas Kling
I'm not sure why this was a syscall. If we need this we can add it in LibC as a wrapper around sysconf(_SC_OPEN_MAX).
2020-05-16Kernel: Remove the "kernel info page" used for fast gettimeofday()Andreas Kling
We stopped using gettimeofday() in Core::EventLoop a while back, in favor of clock_gettime() for monotonic time. Maintaining an optimization for a syscall we're not using doesn't make a lot of sense, so let's go back to the old-style sys$gettimeofday().
2020-04-26Kernel: Added the ability to set the hostname via new syscallLuke Payne
Userland/hostname: Now takes parameter to set the hostname LibC/unistd: Added sethostname function
2020-04-13ptrace: Report error in PT_PEEK via errnoItamar
The syscall wrapper for ptrace needs to return the peeked value when using PT_PEEK. Because of this, the user has to check errno to detect an error in PT_PEEK. This commit changes the actual syscall's interface (only for PT_PEEK) to allow the syscall wrapper to detect an error and change errno.
2020-04-12Kernel+LibC: Add minherit() and MAP_INHERIT_ZEROAndreas Kling
This patch adds the minherit() syscall originally invented by OpenBSD. Only the MAP_INHERIT_ZERO mode is supported for now. If set on an mmap region, that region will be zeroed out on fork().
2020-04-06Kernel & Userland: Allow to mount image files formatted with Ext2FSLiav A
2020-04-03Revert "Kernel & Userland: Allow to mount image files formatted with Ext2FS"Andreas Kling
This reverts commit a60ea79a41845767ce40f225de20da7c99534ad1. Reverting these changes since they broke things. Fixes #1608.
2020-04-02Kernel & Userland: Allow to mount image files formatted with Ext2FSLiav A
2020-03-28Kernel: Add 'ptrace' syscallItamar
This commit adds a basic implementation of the ptrace syscall, which allows one process (the tracer) to control another process (the tracee). While a process is being traced, it is stopped whenever a signal is received (other than SIGCONT). The tracer can start tracing another thread with PT_ATTACH, which causes the tracee to stop. From there, the tracer can use PT_CONTINUE to continue the execution of the tracee, or use other request codes (which haven't been implemented yet) to modify the state of the tracee. Additional request codes are PT_SYSCALL, which causes the tracee to continue exection but stop at the next entry or exit from a syscall, and PT_GETREGS which fethces the last saved register set of the tracee (can be used to inspect syscall arguments and return value). A special request code is PT_TRACE_ME, which is issued by the tracee and causes it to stop when it calls execve and wait for the tracer to attach.
2020-03-24Interrupts: Assert if trying to install an handler on syscall vectorLiav A
Installing an interrupt handler on the syscall IDT vector can lead to fatal results, so we must assert if that happens.
2020-03-22Kernel: Run clang-format on filesShannon Booth
Let's rip off the band-aid
2020-03-19Kernel: Add new syscall to allow changing the system dateLiav A
2020-03-16Kernel: Add sys$get_stack_bounds() for finding the stack base & sizeAndreas Kling
This will be useful when implementing conservative garbage collection.
2020-02-28Kernel: Merge the shbuf_get_size() syscall into shbuf_get()Andreas Kling
Add an extra out-parameter to shbuf_get() that receives the size of the shared buffer. That way we don't need to make a separate syscall to get the size, which we always did immediately after.
2020-02-28Kernel+LibC: Rename shared buffer syscalls to use a prefixAndreas Kling
This feels a lot more consistent and Unixy: create_shared_buffer() => shbuf_create() share_buffer_with() => shbuf_allow_pid() share_buffer_globally() => shbuf_allow_all() get_shared_buffer() => shbuf_get() release_shared_buffer() => shbuf_release() seal_shared_buffer() => shbuf_seal() get_shared_buffer_size() => shbuf_get_size() Also, "shared_buffer_id" is shortened to "shbuf_id" all around.
2020-02-16Kernel+LibC: Allow sys$mmap() callers to specify address alignmentAndreas Kling
This is exposed via the non-standard serenity_mmap() call in userspace.
2020-02-16Kernel: Move all code into the Kernel namespaceAndreas Kling
2020-02-10Kernel+LibC: Merge sys$stat() and sys$lstat()Andreas Kling
There is now only one sys$stat() instead of two separate syscalls.
2020-02-08Net: Add a basic sys$shutdown() implementationAndreas Kling
Calling shutdown prevents further reads and/or writes on a socket. We should do a few more things based on the type of socket, but this initial implementation just puts the basic mechanism in place. Work towards #428.
2020-02-05Kernel+LibC: Add sys$waitid(), and make sys$waitpid() wrap itSergey Bugaev
sys$waitid() takes an explicit description of whether it's waiting for a single process with the given PID, all of the children, a group, etc., and returns its info as a siginfo_t. It also doesn't automatically imply WEXITED, which clears up the confusion in the kernel.
2020-02-02Kernel: Start working on a syscall for logging performance eventsAndreas Kling
This patch introduces sys$perf_event() with two event types: - PERF_EVENT_MALLOC - PERF_EVENT_FREE After the first call to sys$perf_event(), a process will begin keeping these events in a buffer. When the process dies, that buffer will be written out to "perfcore" in the current directory unless that filename is already taken. This is probably not the best way to do this, but it's a start and will make it possible to start doing memory allocation profiling. :^)
2020-01-27Kernel: Remove SmapDisablers in sys$getsockname() and sys$getpeername()Andreas Kling
Instead use the user/kernel copy helpers to only copy the minimum stuff needed from to/from userspace. Based on work started by Brian Gianforcaro.
2020-01-20Kernel: Add a basic implementation of unveil()Andreas Kling
This syscall is a complement to pledge() and adds the same sort of incremental relinquishing of capabilities for filesystem access. The first call to unveil() will "drop a veil" on the process, and from now on, only unveiled parts of the filesystem are visible to it. Each call to unveil() specifies a path to either a directory or a file along with permissions for that path. The permissions are a combination of the following: - r: Read access (like the "rpath" promise) - w: Write access (like the "wpath" promise) - x: Execute access - c: Create/remove access (like the "cpath" promise) Attempts to open a path that has not been unveiled with fail with ENOENT. If the unveiled path lacks sufficient permissions, it will fail with EACCES. Like pledge(), subsequent calls to unveil() with the same path can only remove permissions, not add them. Once you call unveil(nullptr, nullptr), the veil is locked, and it's no longer possible to unveil any more paths for the process, ever. This concept comes from OpenBSD, and their implementation does various things differently, I'm sure. This is just a first implementation for SerenityOS, and we'll keep improving on it as we go. :^)
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
2020-01-17Kernel+LibC: Unify sys$open() and sys$openat()Sergey Bugaev
The syscall is now called sys$open(), but it behaves like the old sys$openat(). In userspace, open_with_path_length() is made a wrapper over openat_with_path_length().
2020-01-11ping: Use pledge()Andreas Kling
2020-01-11Kernel+LibC: Add support for mount flagsSergey Bugaev
At the moment, the actual flags are ignored, but we correctly propagate them all the way from the original mount() syscall to each custody that resides on the mounted FS.
2020-01-11Kernel: Use the Syscall string and buffer types moreAndreas Kling
While I was updating syscalls to stop passing null-terminated strings, I added some helpful struct types: - StringArgument { const char*; size_t; } - ImmutableBuffer<Data, Size> { const Data*; Size; } - MutableBuffer<Data, Size> { Data*; Size; } The Process class has some convenience functions for validating and optionally extracting the contents from these structs: - get_syscall_path_argument(StringArgument) - validate_and_copy_string_from_user(StringArgument) - validate(ImmutableBuffer) - validate(MutableBuffer) There's still so much code around this and I'm wondering if we should generate most of it instead. Possible nice little project.
2020-01-11Kernel: Pass a parameter struct to mount()Andreas Kling
This was the last remaining syscall that took a null-terminated string and figured out how long it was by walking it in kernelspace *shudder*.
2020-01-11Kernel: Pass a parameter struct to rename()Andreas Kling
2020-01-11Kernel: Pass a parameter struct to symlink()Andreas Kling
2020-01-11Kernel: Pass a parameter struct to mknod()Andreas Kling
2020-01-11Kernel: Pass a parameter struct to chown()Andreas Kling
2020-01-10Kernel: Add a basic chroot() syscall :^)Andreas Kling
The chroot() syscall now allows the superuser to isolate a process into a specific subtree of the filesystem. This is not strictly permanent, as it is also possible for a superuser to break *out* of a chroot, but it is a useful mechanism for isolating unprivileged processes. The VFS now uses the current process's root_directory() as the root for path resolution purposes. The root directory is stored as an uncached Custody in the Process object.
2020-01-10Kernel: Pass characters+length to link()Andreas Kling
2020-01-10Kernel: Rename Syscall::SyscallString => Syscall::StringArgumentAndreas Kling
2020-01-10Kernel: Pass characters+length to readlink()Andreas Kling
Note that I'm developing some helper types in the Syscall namespace as I go here. Once I settle on some nice types, I will convert all the other syscalls to use them as well.
2020-01-10Kernel: Enable SMAP protection during the execve() syscallAndreas Kling
The userspace execve() wrapper now measures all the strings and puts them in a neat and tidy structure on the stack. This way we know exactly how much to copy in the kernel, and we don't have to use the SMAP-violating validate_read_str(). :^)
2020-01-09Kernel: Prune a bunch of removed syscalls from the listAndreas Kling
2020-01-08Kernel: Remove unused syscall for setting the signal maskAndreas Kling
2020-01-06Kernel: Pass name+length to mmap() and remove SmapDisablerAndreas Kling
2020-01-06Kernel: Pass name+length to set_mmap_name() and remove SmapDisablerAndreas Kling