summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2020-01-11ping: Use pledge()Andreas Kling
2020-01-11Kernel: Implement bind mountsSergey Bugaev
You can now bind-mount files and directories. This essentially exposes an existing part of the file system in another place, and can be used as an alternative to symlinks or hardlinks. Here's an example of doing this: # mkdir /tmp/foo # mount /home/anon/myfile.txt /tmp/foo -o bind # cat /tmp/foo This is anon's file.
2020-01-11Kernel+LibC: Implement a few mount flagsSergey Bugaev
We now support these mount flags: * MS_NODEV: disallow opening any devices from this file system * MS_NOEXEC: disallow executing any executables from this file system * MS_NOSUID: ignore set-user-id bits on executables from this file system The fourth flag, MS_BIND, is defined, but currently ignored.
2020-01-11Kernel+LibC: Add O_EXEC, move exec permission checking to VFS::open()Sergey Bugaev
O_EXEC is mentioned by POSIX, so let's have it. Currently, it is only used inside the kernel to ensure the process has the right permissions when opening an executable.
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: Simplify VFS::Mount handlingSergey Bugaev
No need to pass around RefPtr<>s and NonnullRefPtr<>s and no need to heap-allocate them. Also remove VFS::mount(NonnullRefPtr<FS>&&, StringView path) - it has been unused for a long time.
2020-01-11Kernel: Oops, recvfrom() is not quite ready for SMAP protections yetAndreas Kling
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: Remove SmapDisabler in bind()Andreas Kling
2020-01-11Kernel: Remove SmapDisabler in clock_nanosleep()Andreas Kling
2020-01-11Kernel: Remove validate_read_str() as nothing uses it anymore :^)Andreas Kling
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: Expose a process's filesystem root as a /proc/PID/root symlinkAndreas Kling
In order to preserve the absolute path of the process root, we save the custody used by chroot() before stripping it to become the new "/". There's probably a better way to do this.
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: Custody::absolute_path() should always return "/" for rootsAndreas Kling
A Custody with no parent is always *a* root (although not necessarily the *real* root.)
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: Copy Region's "is_mmap" flag when cloning regions for fork()Andreas Kling
Otherwise child processes will not be allowed to munmap(), madvise(), etc. on the cloned regions!
2020-01-10Kernel: Fix kernel null deref on process crash during join_thread()Andreas Kling
The join_thread() syscall is not supposed to be interruptible by signals, but it was. And since the process death mechanism piggybacked on signal interrupts, it was possible to interrupt a pthread_join() by killing the process that was doing it, leading to confusing due to some assumptions being made by Thread::finalize() for threads that have a pending joiner. This patch fixes the issue by making "interrupted by death" a distinct block result separate from "interrupted by signal". Then we handle that state in join_thread() and tidy things up so that thread finalization doesn't get confused by the pending joiner being gone. Test: Tests/Kernel/null-deref-crash-during-pthread_join.cpp
2020-01-10Kernel: Remove SmapDisablers in fchmod() and fchown()Andreas Kling
2020-01-10Kernel: unlink() should not follow symlinksAndreas Kling
2020-01-10TmpFS: Synthesize "." and ".." in traverse_as_directory()Andreas Kling
As Sergey pointed out, it's silly to have proper entries for . and .. in TmpFS when we can just synthesize them on the fly. Note that we have to tolerate removal of . and .. via remove_child() to keep VFS::rmdir() happy.
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-10ProcFS: Don't expose kernel-only regions to users via /proc/PID/vmAndreas Kling
The superuser is still allowed to see them, but kernel-only VM regions are now excluded from /proc/PID/vm.
2020-01-10Kernel: Page allocation should not use memset_user() when zeroingAndreas Kling
We're not zeroing new pages through a userspace address, so this should not use memset_user().
2020-01-10Kernel+LibELF: Enable SMAP protection during non-syscall exec()Andreas Kling
When loading a new executable, we now map the ELF image in kernel-only memory and parse it there. Then we use copy_to_user() when initializing writable regions with data from the executable. Note that the exec() syscall still disables SMAP protection and will require additional work. This patch only affects kernel-originated process spawns.
2020-01-09Base: Let's make home directories 700 to keep things private :^)Andreas Kling
2020-01-09Kernel: Don't apply process umask to the LocalSocket prebind modeAndreas Kling
2020-01-09Kernel: connect() should EISCONN on already-connected LocalSocketAndreas Kling
This was causing us to try and accept the same client socket multiple times on the server side, tripping an assertion in Socket::accept().
2020-01-09Build: Add fast build mode that does not clean everything or run testsDov Alperin
Passing the "-f" or "--fast" option to the ./makeall.sh script will build everything without cleaning first, and then will skip tests.
2020-01-09Kernel: Removed an unused global variableAndreas Kling
2020-01-09Kernel: Rename {ss,esp}_if_crossRing to userspace_{ss,esp}Andreas Kling
These were always so awkwardly named.
2020-01-09Kernel: Prune a bunch of removed syscalls from the listAndreas Kling
2020-01-09Kernel: Make some static keyboard data constAndreas Kling
This moves it to the kernel's .rodata section which we write protect in MemoryManager initialization.
2020-01-09Kernel: Take path+length in the unlink() and umount() syscallsAndreas Kling
2020-01-09Kernel: Ignore closed fd's when considering select() unblockAndreas Kling
This fixes a null RefPtr deref (which asserts) in the scheduler if a file descriptor being select()'ed is closed by a second thread while blocked in select(). Test: Kernel/null-deref-close-during-select.cpp
2020-01-09Kernel: Remove unused variable Thread::m_userspace_stack_regionAndreas Kling
2020-01-09Kernel: mmap(..., MAP_PRIVATE, fd, offset) is not supportedAndrew Kaster
Make mmap return -ENOTSUP in this case to make sure users don't get confused and think they're using a private mapping when it's actually shared. It's currenlty not possible to open a file and mmap it MAP_PRIVATE, and change the perms of the private mapping to ones that don't match the permissions of the underlying file.
2020-01-08IPv4: Randomize the first TCP sequence numberAndreas Kling
Fixes #185.
2020-01-08Kernel: open() and openat() should ignore non-permission bits in modeAndreas Kling
2020-01-08Kernel: Opening a file with O_TRUNC should update mtimeAndreas Kling
2020-01-08Kernel: ftruncate() should update mtimeAndreas Kling
2020-01-08Kernel: Remove unused syscall for setting the signal maskAndreas Kling
2020-01-08Kernel: Fix SMAP violation in join_thread()Andreas Kling
2020-01-08ProcFS: Reads past the end of a generated file should be zero-lengthAndreas Kling