Commit graph

16779 commits

Author SHA1 Message Date
Brian Gianforcaro ddd79fe2cf Kernel: Add WaitQueue::wait_forever and it use it for all infinite waits.
In preparation for marking BlockingResult [[nodiscard]], there are a few
places that perform infinite waits, which we never observe the result of
the wait. Instead of suppressing them, add an alternate function which
returns void when performing and infinite wait.
2021-02-15 08:28:57 +01:00
Andreas Kling 4ac286903d Meta: Add Ports/build_installed.sh to the lint-ports ignore list 2021-02-15 07:51:40 +01:00
Ben Wiederhake ad4d9eaaf9 Meta: Lint AvailablePorts.md
As requested by popular demand ;)
https://github.com/SerenityOS/serenity/pull/5325#discussion_r575657614
2021-02-15 07:41:16 +01:00
Ben Wiederhake 87e4bcdf69 Everywhere: Canonicalize 'ReadMe' capitalization
We now follow a common capitalization throughout the project:

./Ports/openssh/ReadMe.md
./Ports/python3/patches/ReadMe.md
./Ports/ReadMe.md
./Meta/Lagom/ReadMe.md
./ReadMe.md

This filename is still obvious enough to be seen immediately.
2021-02-15 07:41:16 +01:00
Andreas Kling 68e3616971 Kernel: Forked children should inherit the signal trampoline address
Fixes #5347.
2021-02-14 18:38:46 +01:00
Andreas Kling 8ee42e47df Kernel: Mark a handful of things in CPU.cpp as READONLY_AFTER_INIT 2021-02-14 18:12:00 +01:00
Andreas Kling 99f596fd51 Kernel: Mark a handful of things in kmalloc.cpp as READONLY_AFTER_INIT 2021-02-14 18:12:00 +01:00
Andreas Kling 7a78a4915a Kernel: Mark a handful of things in init.cpp as READONLY_AFTER_INIT 2021-02-14 18:12:00 +01:00
Andreas Kling 49f463f557 Kernel: Mark a handful of things in Thread.cpp READONLY_AFTER_INIT 2021-02-14 18:12:00 +01:00
Andreas Kling c5c68bbd84 Kernel: Mark a handful of things in Scheduler.cpp READONLY_AFTER_INIT 2021-02-14 18:12:00 +01:00
Andreas Kling 00107a0dc1 Kernel: Mark a handful of things in Process.cpp READONLY_AFTER_INIT 2021-02-14 18:12:00 +01:00
Andreas Kling f0a1d9bfa5 Kernel: Mark the x86 IDT as READONLY_AFTER_INIT
We never need to modify the interrupt descriptor table after finishing
initialization, so let's make it an error to do so.
2021-02-14 18:12:00 +01:00
Andreas Kling a10accd48c Kernel: Print a helpful panic message for READONLY_AFTER_INIT crashes 2021-02-14 18:12:00 +01:00
Andreas Kling d8013c60bb Kernel: Add mechanism to make some memory read-only after init finishes
You can now use the READONLY_AFTER_INIT macro when declaring a variable
and we will put it in a special ".ro_after_init" section in the kernel.

Data in that section remains writable during the boot and init process,
and is then marked read-only just before launching the SystemServer.

This is based on an idea from the Linux kernel. :^)
2021-02-14 18:11:32 +01:00
Linus Groh 917f7d668c Ports: Add build_installed.sh script to rebuild installed ports 2021-02-14 16:46:40 +01:00
Linus Groh a38f5aa026 Ports: Tweak wording in build_all.sh error message 2021-02-14 16:46:40 +01:00
AnotherTest 48fbf6a88d LibCrypto: Don't copy the prime test candidates
This was copying a bunch of bigints for no reason.
2021-02-14 13:30:10 +01:00
AnotherTest 3fe7ac0924 LibCrypto: Make a better ASN.1 parser
And use it to parse RSA keys.
As a bonus, this one shouldn't be reading out of bounds or messing with
the stack (as much) anymore.
2021-02-14 13:30:10 +01:00
AnotherTest 4d40864b9d AK: Make the Bitmap::size_in_bytes() member function public
It's annoying to calculate it when it's already a member function.
2021-02-14 13:30:10 +01:00
Sahan Fernando ca731e2cdd SystemMonitor: Define graphs by ColorRole, not by Color
Currently, graphs are defined in terms of graph color. This means that
when the system palette is changed, the old colors are still used. We
switch to storing the color roles and looking up the palette colors on
paint events. We also define the graph line background color as the
graph color at half-transparency.
2021-02-14 13:27:36 +01:00
Andreas Kling 6ee499aeb0 Kernel: Round old address/size in sys$mremap() to page size multiples
Found by fuzz-syscalls. :^)
2021-02-14 13:15:05 +01:00
Andreas Kling 0e92a80434 Kernel: Add some bits of randomness to kernel stack pointers
Since kernel stacks are much smaller (64 KiB) than userspace stacks,
we only add a small bit of randomness here (0-256 bytes, 16b aligned.)

This makes the location of the task context switch buffer not be
100% predictable. Note that we still also add extra randomness upon
syscall entry, so this patch primarily affects context switching.
2021-02-14 12:30:07 +01:00
Andreas Kling e47bffdc8c Kernel: Add some bits of randomness to the userspace stack pointer
This patch adds a random offset between 0 and 4096 to the initial
stack pointer in new processes. Since the stack has to be 16-byte
aligned, the bottom bits can't be randomized.

Yet another thing to make things less predictable. :^)
2021-02-14 11:53:49 +01:00
Andreas Kling 4188373020 Kernel: Fix TOCTOU in syscall entry region validation
We were doing stack and syscall-origin region validations before
taking the big process lock. There was a window of time where those
regions could then be unmapped/remapped by another thread before we
proceed with our syscall.

This patch closes that window, and makes sys$get_stack_bounds() rely
on the fact that we now know the userspace stack pointer to be valid.

Thanks to @BenWiederhake for spotting this! :^)
2021-02-14 11:47:14 +01:00
Andreas Kling 10b7f6b77e Kernel: Mark handle_crash() as [[noreturn]] 2021-02-14 11:47:14 +01:00
Ben Wiederhake fcda9ee7f5 Utilities: Fix embarassing typo in syscall(1) 2021-02-14 10:57:33 +01:00
Ben Wiederhake c0692f1f95 Kernel: Avoid magic number in sys$poll 2021-02-14 10:57:33 +01:00
Andreas Kling cc341c95aa Kernel: Panic on sys$get_stack_bounds() in stack-less process 2021-02-14 10:51:18 +01:00
Andreas Kling 3131281747 Kernel: Panic on syscall from process with IOPL != 0
If this happens then the kernel is in an undefined state, so we should
rather panic than attempt to limp along.
2021-02-14 10:51:17 +01:00
Linus Groh 4e2a961a3d LibJS: Add BigInt equality tests for some large numbers 2021-02-14 10:51:00 +01:00
Linus Groh 1c6fd749dc LibCrypto: memcmp() all bytes in UnsignedBigInteger::operator==
`length` is only the (trimmed) size of the word vector, so we have to
multiply it with the size of each element to ensure all bytes are
compared.

Fixes #5335.
2021-02-14 10:51:00 +01:00
Andreas Kling 781d29a337 Kernel+Userland: Give sys$recvfd() an options argument for O_CLOEXEC
@bugaevc pointed out that we shouldn't be setting this flag in
userspace, and he's right of course.
2021-02-14 10:39:48 +01:00
Andreas Kling 09b1b09c19 Kernel: Assert if rounding-up-to-page-size would wrap around to 0
If we try to align a number above 0xfffff000 to the next multiple of
the page size (4 KiB), it would wrap around to 0. This is most likely
never what we want, so let's assert if that happens.
2021-02-14 10:01:50 +01:00
Andreas Kling 198d641808 Kernel: Panic on attempt to map mmap'ed page at a kernel address
If we somehow get tricked into mapping user-controlled mmap memory
at a kernel address, let's just panic the kernel.
2021-02-14 09:36:58 +01:00
Andreas Kling b712345c92 Kernel: Use PANIC() in a bunch of places :^) 2021-02-14 09:36:58 +01:00
Andreas Kling c598a95b1c Kernel: Add a PANIC() function
Let's be a little more expressive when inducing a kernel panic. :^)
PANIC(...) passes any arguments you give it to dmesgln(), then prints
a backtrace and hangs the machine.
2021-02-14 09:36:58 +01:00
joshua stein ca35776e78 Documentation: Update build dependencies on OpenBSD 2021-02-14 09:29:22 +01:00
joshua stein 4a2209d0e0 Toolchain: Explicitly enable LTO, fix build on OpenBSD 2021-02-14 09:29:22 +01:00
joshua stein 0d215b5548 Build: Sprinkle some portability, fix on OpenBSD
realpath(1) is specific to coreutils and its behavior can be had
with readlink -f

Create the Toolchain Build directory if it doesn't exist before
calling readlink, since realpath(3) on at least OpenBSD will error
on a non-existent path
2021-02-14 09:29:22 +01:00
Andreas Kling 4021264201 Kernel: Make the Region constructor private
We can use adopt_own(*new T) instead of make<T>().
2021-02-14 01:39:04 +01:00
Andreas Kling 8415866c03 Kernel: Remove user/kernel flags from Region
Now that we no longer need to support the signal trampolines being
user-accessible inside the kernel memory range, we can get rid of the
"kernel" and "user-accessible" flags on Region and simply use the
address of the region to determine whether it's kernel or user.

This also tightens the page table mapping code, since it can now set
user-accessibility based solely on the virtual address of a page.
2021-02-14 01:34:23 +01:00
Andreas Kling 1593219a41 Kernel: Map signal trampoline into each process's address space
The signal trampoline was previously in kernelspace memory, but with
a special exception to make it user-accessible.

This patch moves it into each process's regular address space so we
can stop supporting user-allowed memory above 0xc0000000.
2021-02-14 01:33:17 +01:00
Andreas Kling 3551198f99 Website: Add vakzz's exploit & writeup to the bounty page 2021-02-14 01:33:17 +01:00
Andreas Kling ffdfbf1dba Kernel: Fix wrong sizeof() type in sys$execve() argument overflow check 2021-02-14 00:15:01 +01:00
Andreas Kling 34a83aba71 Kernel: Convert klog() => dbgln()/dmesgln() in Arch/i386/CPU.cpp 2021-02-13 21:51:16 +01:00
Andreas Kling dc42b4565b LibIPC: Oops, fix busted dbgln() format string (thanks, checker!) 2021-02-13 20:37:05 +01:00
Andreas Kling 05bb11f482 LibIPC: Make received file descriptors close-on-exec by default
I noticed that programs running in the terminal had an open file
descriptor for the system theme buffer, inherited from the Terminal.

Let's be nice and always mark incoming fds with FD_CLOEXEC.
2021-02-13 20:13:51 +01:00
Linus Groh 2ed7f75e95 LibJS: Return empty value on exception in Date.parse(), not NaN
This is discarded anyway, so let's not confuse ourselves by returning a
NaN number value that's not going to be used.
2021-02-13 19:58:51 +01:00
Linus Groh db340ae7aa LibJS: Add missing exception check in Date() constructor 2021-02-13 19:58:51 +01:00
Tom ddbd88d5c6 LibGfx: Enable Painter::blit to apply opacity and mix alpha channels
This enables us to properly render windows that use both opacity and
alpha channels.
2021-02-13 19:57:31 +01:00