Commit graph

31595 commits

Author SHA1 Message Date
Michel Hermier 682f89d5bc LibC: Allow multiple includes of <assert.h>
ISO C requires in section 7.2:
The assert macro is redefined according to the current state of NDEBUG
each time that <assert.h> is included.

Also add tests for `assert` multiple inclusion accordingly.
2021-12-23 17:53:46 -08:00
Michel Hermier 7b8398ea0d Meta: Allow to skip #pragma once check
Some headers migth need to be reentered multiple times (eg. <assert.h>)
so a mecanism to skip that check is necessary.
2021-12-23 17:53:46 -08:00
Brian Gianforcaro a47f43d4cb LibGfx: Harden TTF parsing against fuzzers
Instead of asserting this edge case, bail out instead.

Found by OSS-Fuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=42653
2021-12-23 17:43:31 -08:00
Brian Gianforcaro 0a827eaa02 LibGfx: Fix incorrect error handling in ICOLoader
This was found by OSS Fuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=42188
2021-12-23 17:43:31 -08:00
Guilherme Gonçalves da6aef9fff Kernel: Make msync return EINVAL when regions are too large
As a small cleanup, this also makes `page_round_up` verify its
precondition with `page_round_up_would_wrap` (which callers are expected
to call), rather than having its own logic.

Fixes #11297.
2021-12-23 17:43:12 -08:00
creator1creeper1 615c2cbcce FlappyBug: Make bitmap() methods return NonnullRefPtrs
We are already storing these as NonnullRefPtrs, so we might
as well make the functions return them as such.
2021-12-23 17:42:05 -08:00
creator1creeper1 6f592a32cc FlappyBug: Propagate errors in Cloud class
Move-construct Cloud into the Game class to improve
error handling.
2021-12-23 17:42:05 -08:00
creator1creeper1 ff359c27e3 FlappyBug: Propagate errors in Bug class
Move-construct Bug into the Game class to improve
error handling.
2021-12-23 17:42:05 -08:00
creator1creeper1 a67afa735c FlappyBug: Reposition Game constructor in file
This will become important later on because
the constructor will depend on the helper structs
2021-12-23 17:42:05 -08:00
creator1creeper1 81eb450369 FlappyBug: Make helper structs public
They will need to be referenced by main later on.
2021-12-23 17:42:05 -08:00
Lady Gegga 05d91b5843 Base: Add Elbasan characters to font Katica Regular 10
10500-10527 https://www.unicode.org/charts/PDF/U10500.pdf
2021-12-23 17:39:24 -08:00
Linus Groh 3ab1c52e2b LibJS: Require 'T' prefix for ambiguous time-only strings
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/514ede3
2021-12-24 00:07:52 +01:00
Daniel Bertalan a73c71e877 strace: Fix out-of-bounds read when formatting realpath()
The actual length of the resulting string is encoded in the return
value; treating the entire buffer as a string leads to reading
uninitialized memory.
2021-12-23 23:08:10 +01:00
Daniel Bertalan 8e3d1a42e3 Kernel+UE+LibC: Store address as void* in SC_m{re,}map_params
Most other syscalls pass address arguments as `void*` instead of
`uintptr_t`, so let's do that here too. Besides improving consistency,
this commit makes `strace` correctly pretty-print these arguments in
hex.
2021-12-23 23:08:10 +01:00
Daniel Bertalan d1ef8e63f7 LibELF: Use MAP_FIXED_NOREPLACE for address space reservation
This ensures that we don't corrupt our address space if a non-PIE
program's requested address space happens to coincide with memory we
already use.
2021-12-23 23:08:10 +01:00
Daniel Bertalan 77f9272aaf Kernel+UE: Add MAP_FIXED_NOREPLACE mmap() flag
This feature was introduced in version 4.17 of the Linux kernel, and
while it's not specified by POSIX, I think it will be a nice addition to
our system.

MAP_FIXED_NOREPLACE provides a less error-prone alternative to
MAP_FIXED: while regular fixed mappings would cause any intersecting
ranges to be unmapped, MAP_FIXED_NOREPLACE returns EEXIST instead. This
ensures that we don't corrupt our process's address space if something
is already at the requested address.

Note that the more portable way to do this is to use regular
MAP_ANONYMOUS, and check afterwards whether the returned address matches
what we wanted. This, however, has a large performance impact on
programs like Wine which try to reserve large portions of the address
space at once, as the non-matching addresses have to be unmapped
separately.
2021-12-23 23:08:10 +01:00
Daniel Bertalan 4195a7ef4b Kernel: Return EEXIST in VirtualRangeAllocator::try_allocate_specific()
This error only ever gets propagated to the userspace if
MAP_FIXED_NOREPLACE is requested, as MAP_FIXED unmaps intersecting
ranges beforehand, and non-fixed mmap() calls will just fall back to
allocating anywhere.

Linux specifies MAP_FIXED_NOREPLACE to return EEXIST when it can't
allocate, we now match that behavior.
2021-12-23 23:08:10 +01:00
Daniel Bertalan 143dbba562 UserspaceEmulator: Replace intersecting ranges if MAP_FIXED is specified
This commit changes UserspaceEmulator to match the behavior that the
kernel has since ce1bf37.
2021-12-23 23:08:10 +01:00
Liav A 9eb08bdb0f Kernel: Make major and minor numbers to be DistinctNumerics
This helps avoid confusion in general, and make constructors, methods
and code patterns much more clean and understandable.
2021-12-23 23:02:39 +01:00
Hendiadyoin1 6d14940053 Profiler: Use AK::any_of for process filtration
Equivalent to std::ranges::any_of as clang-tidy suggests.
2021-12-23 12:45:36 -08:00
Hendiadyoin1 071d72b494 Profiler: Always use FlyString const&'s in ProfileNode construction
No need to copy and move them around, just to pass them as a
`String const&` to the constructor.

We still end up copying it to a normal String in the end though...
2021-12-23 12:45:36 -08:00
Hendiadyoin1 e3469391d3 Profiler: Remove one else-after-return 2021-12-23 12:45:36 -08:00
Hendiadyoin1 e727605007 Profiler: Don't return constant copies of GUI::ModelIndex 2021-12-23 12:45:36 -08:00
Hendiadyoin1 39a4c0e6ce Profiler: Add some implied auto qualifiers 2021-12-23 12:45:36 -08:00
Hendiadyoin1 d001f8ba70 LibX86: Mark two InstructionDescriptor functions as const
Thanks clang-tidy
2021-12-23 12:45:36 -08:00
Hendiadyoin1 584ba7da13 UserspaceEmulator: Return ValueAndShadowReference& on operator=
This is what normal assign operators do and what clang-tidy expects form
us.
2021-12-23 12:45:36 -08:00
Hendiadyoin1 c0d6afdc67 UserspaceEmulator: Avoid copies of non trivial types on invocations
These include AK::String and X86::Instruction
2021-12-23 12:45:36 -08:00
Hendiadyoin1 95d2feed33 UserspaceEmulator: Remove redundant private specifier in SoftCPU.h 2021-12-23 12:45:36 -08:00
Hendiadyoin1 6b9a35ac51 UserspaceEmulator: Remove some else-after-returns 2021-12-23 12:45:36 -08:00
Hendiadyoin1 15daae468b UserspaceEmulator: Add some implied auto qualifiers 2021-12-23 12:45:36 -08:00
James Puleo bf714efa41 LibMain: Make "Runtime error" warnln red
Stealing what Andreas did for the `dbgln` output, I think it also looks
nice inside of Terminal :^)
2021-12-23 12:41:13 -08:00
Andreas Kling 1d08b671ea Kernel: Enter new address space before destroying old in sys$execve()
Previously we were assigning to Process::m_space before actually
entering the new address space (assigning it to CR3.)

If a thread was preempted by the scheduler while destroying the old
address space, we'd then attempt to resume the thread with CR3 pointing
at a partially destroyed address space.

We could then crash immediately in write_cr3(), right after assigning
the new value to CR3. I am hopeful that this may have been the bug
haunting our CI for months. :^)
2021-12-23 01:18:26 +01:00
Andreas Kling 601a9321d9 Kernel: Don't honor userspace SIGSTOP requests in Thread::block()
Instead, wait until we transition back to userspace. This stops
userspace from being able to suspend a thread indefinitely while it's
running in kernelspace (potentially holding some blocking mutex.)
2021-12-23 00:57:36 +01:00
Lady Gegga cf7bbcc70e Base: Add remaining Geometric Shapes to font Katica Regular 10
25B2-25FF https://www.unicode.org/charts/PDF/U25A0.pdf
2021-12-22 23:29:26 +01:00
Lady Gegga db3bc58c16 Base: Add some General Punctuation glyphs to font Katica Regular 10
2038, 203F, 2040, 2045, 2046, 2054
https://www.unicode.org/charts/PDF/U2000.pdf
2021-12-22 23:29:26 +01:00
Lady Gegga 188baa8fba Base: Add some Katakana characters to font Katica Regular 10
30A0, 30B3, 30C3, 30C4, 30FB, 30FC, 30FF
https://www.unicode.org/charts/PDF/U30A0.pdf
2021-12-22 23:29:26 +01:00
Lady Gegga 58bc730880 Base: Add Half- and Fullwidth Forms glyphs to font Katica Regular 10
FF01-FF02, FF07-FF0F, FF3B-FF3D
https://www.unicode.org/charts/PDF/UFF00.pdf
2021-12-22 23:29:26 +01:00
Brian Gianforcaro 8afcf2441c Kernel: Initialize SupriousInterruptHandler::m_enabled on construction
Found by PVS Studio Static Analysis
2021-12-22 13:29:31 -08:00
Brian Gianforcaro 0348d9afbe Kernel: Always initialize ext2_inode and ext_super_block structs
Found by PVS Studio Static Analysis
2021-12-22 13:29:31 -08:00
Brian Gianforcaro b8e210deea Kernel: Initialize PhysicalRegion::m_large_zones, remove m_small_zones
Found by PVS Studio Static Analysis.
2021-12-22 13:29:31 -08:00
Brian Gianforcaro 39e5b42f36 IPCCompiler: Default initialize all parameter member variables
PVS Studio static analysis noticed we didn't initialize these in a
bunch of cases. This change fixes that so we will always initialize
these using universal initialization.
2021-12-22 13:29:31 -08:00
Brian Gianforcaro 4490668af2 Ports: Add fio port
fio allows you to test various different IO subsystems and patterns.
It can help us test and benchmark the I/O subsystems of Serenity.

This port gets the fio bootstrapped and working, using the included
.fio file, I have been able to test the file I/O performance already.
2021-12-22 13:28:13 -08:00
Brian Gianforcaro c724955d54 LibC: Add support for posix_madvise(..)
Add the `posix_madvise(..)` LibC implementation that just forwards
to the normal `madvise(..)` implementation.

Also define a few POSIX_MADV_DONTNEED and POSIX_MADV_NORMAL as they
are part of the POSIX API for `posix_madvise(..)`.

This is needed by the `fio` port.
2021-12-22 13:28:13 -08:00
Idan Horowitz ba9a525ba6 Ports: Remove obsolete siginfo_t::si_error Python3 patch 2021-12-22 22:53:56 +02:00
Idan Horowitz 7a662c2638 Kernel: Add the si_errno and si_band siginfo_t members
These 2 members are required by POSIX and are also used by some ports.
Zero is a valid value for both of these, so no further work to support
them is required.
2021-12-22 22:53:56 +02:00
Ali Mohammad Pur f20e0036bd Meta: Add a cmake flag for building for compiler explorer
We don't need to build tests/binaries for CE.
2021-12-22 20:49:28 +03:30
kleines Filmröllchen a06a5df297 Base: Add a stack of quotes I collected :^) 2021-12-22 17:33:32 +01:00
Timothy Flynn 9ce4ff4265 LibJS: Avoid crashing when the Unicode data generators are disabled
The general idea when ENABLE_UNICODE_DATABASE_DOWNLOAD is OFF has been
that the Intl APIs will provide obviously incorrect results, but should
not crash. This regressed a bit with NumberFormat and DateTimeFormat.
2021-12-22 17:30:43 +01:00
Tim Schumacher 48dc28996d Ports: Update Python patches for the recent signal changes
The old patch to define `HAVE_SIGSET_T` is no longer needed, as we now
have implementations for `sigwaitinfo` and `sigtimedwait`.

Instead, for the same reason, we now have to remove a reference to
`si_errno`, which we haven't implemented yet but is just assumed to be
there.
2021-12-22 11:28:20 +01:00
Linus Groh c56e5139f5 LibJS: Fix modulo in get_iso_parts_from_epoch() for negative epoch ns
This now matches the spec change from reminder() to modulo which was
done here: https://github.com/tc39/proposal-temporal/commit/bdf60f5
2021-12-22 11:27:31 +01:00