summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2020-08-22Kernel: Fix kmalloc memory corruptionTom
Rather than hardcoding where the kmalloc pool should be, place it at the end of the kernel image instead. This avoids corrupting global variables or other parts of the kernel as it grows. Fixes #3257
2020-08-22Kernel: Make PhysicalPage not movable and use atomic ref countingTom
We should not be moving ref-counted objects.
2020-08-22Kernel: Copy command line to a safe placeTom
This avoids kmalloc overwriting it because it may be within the kmalloc or eternal pool.
2020-08-22AK: Get rid of make_singleton functionTom
Just default the InitFunction template argument.
2020-08-22Kernel: Fix regression where MemoryManager is initialized twiceTom
MemoryManager cannot use the Singleton class because MemoryManager::initialize is called before the global constructors are run. That caused the Singleton to be re-initialized, causing it to create another MemoryManager instance.
2020-08-22Kernel: Move Singleton class to AKTom
2020-08-21Kernel: Fix reading RTCNico Weber
The CMOS sets bit 2 (0x4) if times are binary, if it's not set they're in BCD. The CMOS sets bit 1 (0x1) if hours are on a 12 hour clock. In that case, the highest bit in the hour byte is set for PM times (both in binary and BCD times). Three bugs: 1. The lower 7 bits were masked off incorrectly when calling bcd_to_binary(). Use 0x7F as mask, not 0x70. 2. The highest bit to check if a time was PM was checked after BCD conversion of the low 7 bits, which clobbered that bit. Do the check before BCD conversion. 3. In the 12 hour clock, midnight and noon are "12", so those need to be converted to 0 even if for non-PM times (else midnight is "12", not "0"). With this, SerenityOS consistently shows UTC as the current time, as it should. If folks want it to display local time instead, they can get this by adding `-rtc base=localtime` to Meta/run.sh -- but a better fix would be to add timezone management and convert from UTC system clock to the user timezone at display time.
2020-08-21AK+LibC+Kernel: Move the implementation of memmem to AKAnotherTest
2020-08-21Kernel: Fix assertion when releasing contiguous memory regionTom
There is no guarantee that the memory manager lock is held when physical pages are released, so just acquire the memory manager lock.
2020-08-21Kernel: Switch singletons to use new Singleton classTom
Fixes #3226
2020-08-21Kernel: Add an atomic Singleton classTom
This allows easier one-time thread-safe atomic initialization of the various singletons in the Kernel.
2020-08-20Kernel: Log time in addition to date in RTC startupNico Weber
2020-08-20Kernel: Pack arguments, environment and auxiliary values betterAndreas Kling
Previously we were putting strings at the bottom of the allocated stack region, and pointer arrays (argv, env, auxv) at the top. There was no reason for this other than "it seemed easier to do it that way at the time I wrote it." This patch packs the strings and pointer vectors into the same area at the top of the stack. This reduces the memory footprint of all programs by 4 KiB. :^)
2020-08-19Kernel: Distinguish between new and old process groups with equal pgidsAnotherTest
This does not add any behaviour change to the processes, but it ties a TTY to an active process group via TIOCSPGRP, and returns the TTY to the kernel when all processes in the process group die. Also makes the TTY keep a link to the original controlling process' parent (for SIGCHLD) instead of the process itself.
2020-08-19Ext2FS: Fix inode link leak on all new inodesAndreas Kling
The initial inode link count was wrong in Ext2FS, as the act of adding new inodes to their new parent bumps the count. This regressed in df66c28479e9206adeef1f40f8c0e448c8aea77e.
2020-08-19Kernel: Use Userspace<T> for the recvfrom syscall, and Socket implementationBrian Gianforcaro
This fixes a bunch of unchecked kernel reads and writes, seems like they would might exploitable :). Write of sockaddr_in size to any address you please...
2020-08-19Kernel: Use Userspace<T> for the sendto syscall, and Socket implementationBrian Gianforcaro
Note that the data member is of type ImmutableBufferArgument, which has no Userspace<T> usage. I left it alone for now, to be fixed in a future change holistically for all usages.
2020-08-19Kernel: Remove unneeded #include in ProcessorInfo.cpp (#3211)Muhammad Zahalqa
2020-08-19Kernel: Remove an unimplemented function (#3210)Muhammad Zahalqa
2020-08-19Kernel: Do not wait before first attempt at locking SpinLock (#3212)Muhammad Zahalqa
2020-08-18Kernel: Remove the now-unused FS::DirectoryEntryAndreas Kling
This object was cumbersome and annoying (mostly due to its manually managed, statically sized name buffer.) And now we no longer need it!
2020-08-18Ext2FS: Stop using FS::DirectoryEntryAndreas Kling
We were only using this as a temporary helper object while constructing directories. Create a simpler Ext2FSDirectoryEntry instead for this.
2020-08-18TmpFS: Stop using FS::DirectoryEntry in TmpFSInodeAndreas Kling
The list of children can just be a bunch of { name, inode }.
2020-08-18TmpFS: Avoid unnecessary inode lookup in TmpFSInode::lookup()Andreas Kling
We don't have to ask the VFS to find our child inode, we have a pointer to it right here.
2020-08-18Kernel: Add DirectoryEntryView for VFS directory traversalAndreas Kling
Unlike DirectoryEntry (which is used when constructing directories), DirectoryEntryView does not manage storage for file names. Names are just StringViews. This is much more suited to the directory traversal API and makes it easier to implement this in file system classes since they no longer need to create temporary name copies while traversing.
2020-08-18Kernel: ProcessorInfo.cpp remove unused headersMuhammad Zahalqa
2020-08-17Kernel: Remove unneeded header (#3196)Muhammad Zahalqa
AK/HashTable.h is not needed from SpuriousInterruptHandler
2020-08-17Kernel: Bump process thread count to a 32-bit valueAndreas Kling
We should support more than 65535 threads, after all. :^)
2020-08-17Kernel: Don't use copy_from_user() for kernelspace read in perf eventsAndreas Kling
Fixes #3182.
2020-08-17Kernel: Emit ProcFS pledge/veil properties as "N/A" for kernel processesBrian Gianforcaro
Pledges and Veil state don't really make sense for kernel mode processes, as they can do what ever they want since they are in kernel mode. Make this clear in the system monitor UI by marking these entries as null.
2020-08-17Kernel: Remove a comment that has been stale since 7a64f55c0fNico Weber
2020-08-17Kernel: Remove strncpy() and strrchr()Andreas Kling
These are not called anywhere in the kernel anyway.
2020-08-16Kernel: Switch a comment to GiBNico Weber
2020-08-16AK: Rename KB, MB, GB to KiB, MiB, GiBNico Weber
The SI prefixes "k", "M", "G" mean "10^3", "10^6", "10^9". The IEC prefixes "Ki", "Mi", "Gi" mean "2^10", "2^20", "2^30". Let's use the correct name, at least in code. Only changes the name of the constants, no other behavior change.
2020-08-15AK: Rename span() to bytes() when appropriate.asynts
I originally defined the bytes() method for the String class, because it made it obvious that it's a span of bytes instead of span of characters. This commit makes this more consistent by defining a bytes() method when the type of the span is known to be u8. Additionaly, the cast operator to Bytes is overloaded for ByteBuffer and such.
2020-08-15Meta: Install source files at /usr/src/serenityItamar
2020-08-15Kernel: Fix behaviour of PT_TRACEME in ptraceItamar
The behaviour of the PT_TRACEME feature has been broken for some time, this change fixes it. When this ptrace flag is used, the traced process should be paused before exiting execve. We previously were sending the SIGSTOP signal at a stage where interrupts are disabled, and the traced process continued executing normally, without pausing and waiting for the tracer. This change fixes it.
2020-08-15Kernel+LibC+UserspaceEmulator: Bring back sys$dup2()Andreas Kling
This is racy in userspace and non-racy in kernelspace so let's keep it in kernelspace. The behavior change where CLOEXEC is preserved when dup2() is called with (old_fd == new_fd) was good though, let's keep that.
2020-08-15Kernel+LibC+UserspaceEmulator: Remove sys$dup() and sys$dup2()Andreas Kling
We can just implement these in userspace, so yay two less syscalls!
2020-08-15Kernel: Briefly resume stopped threads when being killedTom
We need to briefly put Stopped threads back into Running state so that the kernel stacks can get cleaned up when they're being killed. Fixes #3130
2020-08-14Kernel: mark kmalloc with attributesMuhammad Zahalqa
2020-08-13Kernel: Request random numbers for syscall stack noise in larger chunks (#3125)Nico Weber
Cuts time needed for `disasm /bin/id` from 2.5s to 1s -- identical to the time it needs when not doing the random adjustment at all. The downside is that it's now very easy to get the random offsets with out-of-bounds reads, so it does make this mitigation less effective.
2020-08-13Kernel: Simplify the way we check for "serial_debug" on command lineAndreas Kling
2020-08-13Kernel: Remove strdup() since nothing uses itAndreas Kling
2020-08-13Kernel: Fix rng regression from bc7a149039Nico Weber
2020-08-13Kernel: Don't request a random u32 when all but 5 bits are immediately ↵Nico Weber
masked off
2020-08-12Kernel: Tell compiler about invisible callsBen Wiederhake
This makes the Kernel build cleanly with -Wmissing-declarations.
2020-08-12Kernel: Group C++ ABI functions togetherBen Wiederhake
As suggested in #3096.
2020-08-12Kernel: Module symbol declarations for type-checkingBen Wiederhake
With this, if a future module misses the 'extern "C"' or uses a wrong type, they get a nice compiler error instead of runtime errors or weird behavior. Also, this works towards getting the Kernel ready for -Wmissing-declarations.
2020-08-12Kernel: Avoid linking errors when calling Kernel APIBen Wiederhake
The compiler can't see that the definitions inside the .h file aren't meant to be public symbols. So in a hypothetical program which uses the Kernel API, each(\!) compilation unit that includes FB.h would define those fb_get_size_in_bytes symbols. If that happens twice or more times, that would cause linker errors. Since the functions are very short, inlining them seems like a good idea. Also, using FB.h should be possible even if the containing compilation unit doesn't already define size_t, so I added that header (stddef), too.