summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2020-06-27Kernel: Make Random work on CPUs without rdrandPeter Elliott
- If rdseed is not available, fallback to rdrand. - If rdrand is not available, block for entropy, or use insecure prng depending on if user wants fast or good random.
2020-06-27Kernel: Add g_cpu_supports_rdseed3541
CPUs which support RDRAND do not necessarily support RDSEED. This introduces a flag g_cpu_supports_rdseed which is set appropriately by CPUID. This causes Haswell CPUs in particular (and probably a lot of AMD chips) to now fail to boot with #2634, rather than an illegal instruction. It seems like the KernelRng needs either an initial reseed call or more random events added before the first call to get_good_random, but I don't feel qualified to make that kind of change.
2020-06-25Kernel: Harvest randomness from various driversPeter Elliott
Random now gets entropy from the following drivers: - KeyboardDevice - PATAChannel - PS2MouseDevice - E1000NetworkAdapter - RTL8139NetworkAdapter Of these devices, PS2MouseDevice and PATAChannel provide the vast majority of the entropy.
2020-06-25LibCrypto: Add CTR cipher modePeter Elliott
Kernel: Changed fortuna implementation to use CTR mode instead of manually implementing a counter.
2020-06-25Kernel: Replace existing random implementation with FortunaPeter Elliott
2020-06-25Kernel: Implement the Fortuna PRNG algorithmPeter Elliott
2020-06-25Kernel: Port mounts to reference inodes directlySergey Bugaev
...instead of going through their identifiers. See the previous commit for reasoning.
2020-06-25Kernel: Deemphasize inode identifiersSergey Bugaev
These APIs were clearly modeled after Ext2FS internals, and make perfect sense in Ext2FS context. The new APIs are more generic, and map better to the semantics exported to the userspace, where inode identifiers only appear in stat() and readdir() output, but never in any input. This will also hopefully reduce the potential for races (see commit https://github.com/SerenityOS/serenity/commit/c44b4d61f350703fcf1bbd8f6e353b9c6c4210c2). Lastly, this makes it way more viable to implement a filesystem that only synthesizes its inodes lazily when queried, and destroys them when they are no longer in use. With inode identifiers being used to reference inodes, the only choice for such a filesystem is to persist any inode it has given out the identifier for, because it might be queried at any later time. With direct references to inodes, the filesystem will know when the last reference is dropped and the inode can be safely destroyed.
2020-06-25Kernel: Minor cleanups in sendfd/recvfdAndreas Kling
Applying some nice suggestions by @bugaevc. :^)
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-22Kernel: Silence debug spam on execAndreas Kling
2020-06-22Kernel: Silence some debug spam in SchedulerAndreas Kling
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-21Kernel: Use map_typed() in HPET code and add a register access helperAndreas Kling
2020-06-20Kernel: Remove DMI decoder from the kernelAndreas Kling
As suggested by @supercomputer7, we can simply expose this as a blob and decode it in userspace instead. Fixes #2599.
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-18Kernel: Add "setkeymap" pledge promiseAndreas Kling
2020-06-17Kernel: Unbreak sys$setkeymap()Andreas Kling
This syscall was disabling SMAP too late and would crash every time when trying to set a new keymap.
2020-06-17Kernel: clang-format ENUMERATE_SYSCALLSNico Weber
2020-06-17Kernel: Don't remove shbuf permission-to-reattach when releasingAndreas Kling
The "Reference" object is not just a counter, it also represents the permission to map a shbuf itself. Without this change, a shbuf could not be re-mapped by the same process after it released all of its refs on it.
2020-06-17Meta: Scale back overly informal user-facing stringsAndreas Kling
We were getting a little overly memey in some places, so let's scale things back to business-casual. Informal language is fine in comments, commits and debug logs, but let's keep the runtime nice and presentable. :^)
2020-06-17Kernel: Use symbolic constants for file modesSergey Bugaev
This fixes a bug where the mode of a FIFO was reported as 001000 instead of 0010000 (you see the difference? me nethier), and hopefully doesn't introduce new bugs. I've left 0777 and similar in a few places, because that is *more* readable than its symbolic version.
2020-06-17Kernel+LibC: Do not return -ENAMETOOLONG from sys$readlink()Sergey Bugaev
That's not how readlink() is supposed to work: it should copy as many bytes as fit into the buffer, and return the number of bytes copied. So do that, but add a twist: make sys$readlink() actually return the whole size, not the number of bytes copied. We fix up this return value in userspace, to make LibC's readlink() behave as expected, but this will also allow other code to allocate a buffer of just the right size. Also, avoid an extra copy of the link target.
2020-06-16Kernel: TTY:VirtualConsole, replace character attribute with code_pointHüseyin ASLITÜRK
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-06-13Kernel: KeyboardDevice, remove char mapping logicHüseyin ASLITÜRK
Remove char mapping logic and constant character map.
2020-06-13Kernel: Process, replace internal data type to CharacterMapDataHüseyin ASLITÜRK
2020-06-12AK: Make string-to-number conversion helpers return OptionalAndreas Kling
Get rid of the weird old signature: - int StringType::to_int(bool& ok) const And replace it with sensible new signature: - Optional<int> StringType::to_int() const
2020-06-09Kernel: Allow sys$accept(address = nullptr)Sergey Bugaev
2020-06-04Kernel: Detect APs and boot them into protected modeTom
This isn't fully working, the APs pretend like they're fully initialized and are just halted permanently for now.
2020-06-04Kernel: Add mechanism to identity map the lowest 2MBTom
2020-06-03Kernel: Add scancode value to KeyEventHüseyin ASLITÜRK
2020-06-02Kernel: Always inline some KResult / KResultOr<> methodsSergey Bugaev
Namely, those that contain assertions that can be easily eliminated at call site.
2020-06-02Kernel: Allow File::close() to failSergey Bugaev
And pass the result through to sys$close() return value. Fixes https://github.com/SerenityOS/serenity/issues/427
2020-06-01HPET: Fix accessing HPET registersTom
This resolves a bochs panic during bootup: [Kernel]: HPET @ P0x07ff0fc0 00691951632p[HPET ] >>PANIC<< Unsupported HPET read at address 0x0000fed00100 These changes however don't fully resolve #2162
2020-05-31Kernel: Tighten up some promise checksSergey Bugaev
Since we're not keeping compatibility with OpenBSD about what promises are required for which syscalls, tighten things up so that they make more sense.
2020-05-31Kernel: Fix overflow in Process::validate_{read,write}_typed()Sergey Bugaev
Userspace could pass us a large count to overflow the check. I'm not enough of a haxx0r to write an actual exploit though.
2020-05-31Kernel: Fix glitched audio output in SB16 driverAndreas Kling
We were not setting the DMA transfer mode correctly. I have absolutely no clue how this could ever have worked, but it did work for months until it suddenly didn't. Anyways, this fixes that. The sound is still a little bit glitchy and that could probably be fixed by using the SB16's auto-initialized mode.
2020-05-30LibVT: Allow updating the window progress via an escape sequenceAndreas Kling
You can now request an update of the terminal's window progress by sending this escape sequence: <esc>]9;<value>;<max_value>;<escape><backslash> I'm sure we can find many interesting uses for this! :^)
2020-05-30AK+LibC: Add TODO() as an alternative to ASSERT_NOT_REACHED()Andreas Kling
I've been using this in the new HTML parser and it makes it much easier to understand the state of unfinished code branches. TODO() is for places where it's okay to end up but we need to implement something there. ASSERT_NOT_REACHED() is for places where it's not okay to end up, and something has gone wrong.
2020-05-29Ports: Fix CMake-based portsPaul Redmond
The SDL port failed to build because the CMake toolchain filed pointed to the old root. Now the toolchain file assumes that the Root is in Build/Root. Additionally, the AK/ and Kernel/ headers need to be installed in the root too.
2020-05-29Meta: Add a script check the presence of "#pragma once" in header filesEmanuele Torre
.. and make travis run it. I renamed check-license-headers.sh to check-style.sh and expanded it so that it now also checks for the presence of "#pragma once" in .h files. It also checks the presence of a (single) blank line above and below the "#pragma once" line. I also added "#pragma once" to all the files that need it: even the ones we are not check. I also added/removed blank lines in order to make the script not fail. I also ran clang-format on the files I modified.
2020-05-29Kernel+Userland: Support remounting filesystems :^)Sergey Bugaev
This makes it possible to change flags of a mount after the fact, with the caveats outlined in the man page.
2020-05-29Kernel: Misc tweaksSergey Bugaev
2020-05-29Kernel+Base: Mount root filesystem read-only :^)Sergey Bugaev
We remount /home and /root as read-write, to keep the ability to modify files there. /tmp remains read-write, as it is mounted from a TmpFS.
2020-05-29Kernel: Support read-only filesystem mountsSergey Bugaev
This adds support for MS_RDONLY, a mount flag that tells the kernel to disallow any attempts to write to the newly mounted filesystem. As this flag is per-mount, and different mounts of the same filesystems (such as in case of bind mounts) can have different mutability settings, you have to go though a custody to find out if the filesystem is mounted read-only, instead of just asking the filesystem itself whether it's inherently read-only. This also adds a lot of checks we were previously missing; and moves some of them to happen after more specific checks (such as regular permission checks). One outstanding hole in this system is sys$mprotect(PROT_WRITE), as there's no way we can know if the original file description this region has been mounted from had been opened through a readonly mount point. Currently, we always allow such sys$mprotect() calls to succeed, which effectively allows anyone to circumvent the effect of MS_RDONLY. We should solve this one way or another.
2020-05-29Kernel+LibC: Move O_* and MS_* flags to UnixTypes.hSergey Bugaev
That's where the other similar definitions reside. Also, use bit shift operations for MS_* values.
2020-05-29Kernel: Fix error case in Process::create_user_process()Sergey Bugaev
If we fail to exec() the target executable, don't leak the thread (this actually triggers an assertion when destructing the process), and print an error message.