summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem
AgeCommit message (Collapse)Author
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-05-02Kernel: Don't check pledges or veil against code coverage data filesAndrew Kaster
Coverage tools like LLVM's source-based coverage or GNU's --coverage need to be able to write out coverage files from any binary, regardless of its security posture. Not ignoring these pledges and veils means we can't get our coverage data out without playing some serious tricks. However this is pretty terrible for normal exeuction, so only skip these checks when we explicitly configured userspace for coverage.
2022-04-21Kernel: Don't require AnonymousFiles to be mmap'd completelykleines Filmröllchen
AnonymousFile always allocates in multiples of a page size when created with anon_create. This is especially an issue if we use AnonymousFile shared memory to store a shared data structure that isn't exactly a multiple of a page in size. Therefore, we can just allow mmaps of AnonymousFile to map only an initial part of the shared memory. This makes SharedSingleProducerCircularQueue work when it's introduced later.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-04-01Kernel: Allow SysFS components to have non-zero sizeLiav A
This is important for dmidecode because it does an fstat on the DMI blobs, trying to figure out their size. Because we already know the size of the blobs when creating the SysFS components, there's no performance penalty whatsoever, and this allows dmidecode to not use the /dev/mem device as a fallback.
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-17Kernel: Use default constructors/destructorsLenny Maiorani
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
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-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-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: Honor permission mode when creating new directories in DevTmpFSLiav A
2022-02-14Kernel: Make Inode::set_shared_vmobject() OOM-fallibleIdan Horowitz
Allocating a WeakPtr can fail, so this let's us properly propagate said failure.
2022-02-13Kernel: Use try_make_weak_ptr() instead of make_weak_ptr()Idan Horowitz
2022-02-13Kernel/VFS: Add FIXMEs about error codes leaking data from veiled pathsMax Wipfli
Error codes can leak information about veiled paths, if the path resolution fails with e.g. EACCESS. This is non-trivial to fix, as there is a group of error codes we want to propagate to the caller, such as ENOMEM.
2022-02-13Kernel/VFS: Validate paths against process veil in mkdir()Max Wipfli
VirtualFileSystem::mkdir() relies on resolve_path() returning an error, since it is only interested in the out_parent passed as a pointer. Since resolve_path_without_veil returns an error, no process veil validation is done by resolve_path() in that case. Due to this problem, mkdir() should use resolve_path_without_veil() and then manually validate if the parent directory of the to-be-created directory is unveiled with 'c' permissions. This fixes a bug where the mkdir syscall would not respect the process veil at all.
2022-02-13Kernel/VFS: Clear out_parent if path is veiledMax Wipfli
Previously, VirtualFileSystem::resolve_path() could return a non-null RefPtr<Custody>* out_parent even if the function errored because the path has been veiled. If code relies on recieving the parent custody even if the path is veiled, it should just call resolve_path_without_veil and do the veil validation manually. This is because it could be that the parent is unveiled but the child isn't or the other way round.
2022-02-07Kernel: Robustify and rename Inode bound socket APIAndreas Kling
Rename the bound socket accessor from socket() to bound_socket(). Also return RefPtr<LocalSocket> instead of a raw pointer, to make it harder for callers to mess up.
2022-02-03Revert "Kernel: Protect InodeWatcher internals with spinlock instead of mutex"Andreas Kling
This reverts commit 0bebf013e348f52f218535ebd3d82c9599ea5818. This caused a deadlock when handling a crashed process, so let's revert it until we can figure out what went wrong.
2022-02-03Kernel: Protect Inode flock list with spinlock instead of mutexAndreas Kling
2022-02-03Kernel: Protect InodeWatcher internals with spinlock instead of mutexAndreas Kling
2022-02-03Kernel: Protect Inode's list of watchers with spinlock instead of mutexAndreas Kling
2022-02-03Kernel: Protect mounted filesystem list with spinlock instead of mutexAndreas Kling
2022-02-03Kernel: Convert OpenFileDescriptor from mutex to spinlockAndreas Kling
A mutex is useful when we need to be able to block the current thread until it's available. This is overkill for OpenFileDescriptor. First off, this patch wraps the main state member variables inside a SpinlockProtected<State> to enforce synchronized access. This also avoids "free locking" where figuring out which variables are guarded by which lock is left as an unamusing exercise for the reader. Then we remove mutex locking from the functions that simply call through to the underlying File or Inode, since those fields never change anyway, and the target objects perform their own synchronization.
2022-01-29Kernel: Use HashCompatible HashMap lookups instead of specifying a hashIdan Horowitz
2022-01-26Kernel: Make Inode::register_watcher() OOM-fallibleIdan Horowitz
2022-01-26Kernel: Make InodeWatcher inode registration completely OOM-fallibleIdan Horowitz
InodeWatcher::register_inode was already partially fallible, but the insertion of the inodes and watch descriptions into their respective hash maps was not. Note that we cannot simply TRY the insertion into both, as that could result in an inconsistent state, instead we must remove the inode from the inode hash map if the insertion into the watch description hash map failed.
2022-01-25Kernel: Use u64 instead of size_t for BlockBasedFileSystem::read_blockIdan Horowitz
This ensures offsets will not be truncated on large filesystems on i686
2022-01-25Kernel: Use u64 instead of size_t for BlockBasedFileSystem::write_blockIdan Horowitz
This ensures offsets will not be truncated on large filesystems on i686
2022-01-25Kernel: Use u64 instead of size_t for File::can_write offsetIdan Horowitz
This ensures offsets will not be truncated on large files on i686.
2022-01-25Kernel: Use u64 instead of size_t for File::can_read offsetIdan Horowitz
This ensures offsets will not be truncated on large files on i686.
2022-01-25AK: Standardize the behaviour of GenericLexer::consume_until overloadsIdan Horowitz
Before this commit all consume_until overloads aside from the Predicate one would consume (and ignore) the stop char/string, while the Predicate overload would not, in order to keep behaviour consistent, the other overloads no longer consume the stop char/string as well.
2022-01-24Everywhere: Convert ByteBuffer factory methods from Optional -> ErrorOrSam Atkins
Apologies for the enormous commit, but I don't see a way to split this up nicely. In the vast majority of cases it's a simple change. A few extra places can use TRY instead of manual error checking though. :^)
2022-01-24Kernel: Make DiskCache::ensure OOM-fallible using ErrorOrIdan Horowitz
2022-01-23Kernel: Use ErrorOr in BlockBased and Ext2 filesystem raw read and writeDavid Briggs
These functions used to return booleans which withheld useful error information for callers. Internally they would suppress and convert Error objects. We now log or propagate these errors up the stack.
2022-01-21Kernel: Use KString instead of String in InodeWatcher::Event's pathIdan Horowitz
2022-01-21Kernel: Use KString instead of String in Ext2FSInode's lookup cacheIdan Horowitz
2022-01-14Kernel/TmpFS: Remove inode map from TmpFSAndreas Kling
The HashMap of InodeIndex->Inode in TmpFS only had one purpose: looking up parent inodes by index. Instead of using a map for this, we can simply give each inode a WeakPtr to its parent inode. This saves us the trouble of dealing with the fallibility of HashMap allocations, and it just generally simpler. :^)
2022-01-13Kenrel: Use a KString for Ext2FSDirectoryEntry::nameIdan Horowitz
This brings Ext2FileSystem one step closer to being OOM-safe.
2022-01-12Revert "Kernel: Use a StringView for Ext2FSDirectoryEntry::name"Idan Horowitz
This reverts commit d1d24eaef49d48ce88716e10039e9f63d286f385. I missed the fact that traverse_as_directory uses a temporary buffer, meaning that entries created based on its callback will point to free'd memory.
2022-01-12Kernel: Convert Inode event APIs to use StringViews instead of StringsIdan Horowitz
These APIs allocate a copy internally anyways, so there's no point to making another one for them.
2022-01-12Kernel: Use a StringView for Ext2FSDirectoryEntry::nameIdan Horowitz
This is a temporary struct, so there's no need to allocate a long term storage for these strings.
2022-01-12Kernel: Remove the Custody::absolute_path() APIIdan Horowitz
With the last user removed this non-fallible API can now be removed.
2022-01-12Kernel: Convert Mount::absolute_path to ErrorOr<NonnullOwnPtr<KString>>Idan Horowitz
2022-01-12Kernel: Use Vector::try_append in Custody::try_serialize_absolute_pathIdan 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-12Kernel: Harden DevPtsFSInode::traverse_as_directory against OOMBrian Gianforcaro
Use the try variants of AK::StringBuilder append APIs to harden this function against OOM.
2022-01-11Kernel: Synchronize removals from TmpFS inode mapAndreas Kling
Previously we were uncaching inodes from TmpFSInode::one_ref_left(). This was not safe, since one_ref_left() was effectively being called on a raw pointer after decrementing the local ref count and observing it become 1. There was a race here where someone else could trigger the destructor by unreffing to 0 before one_ref_left() got called, causing us to call one_ref_left() on a deleted inode. We fix this by using the new remove_from_secondary_lists() mechanism in ListedRefCounted and synchronizing all access to the TmpFS inode map with the main Inode::all_instances() lock. There's probably a nicer way to solve this.
2022-01-11Kernel: Remove empty Ext2FSInode::one_ref_left()Andreas Kling