Commit Graph

31693 Commits

Author SHA1 Message Date
Idan Horowitz
7757d874ad Kernel: Assert that a KmallocSubheap fits inside a page
Since we allocate the subheap in the first page of the given storage
let's assert that the subheap can actually fit in a single page, to
prevent the possible future headache of trying to debug the cause of
random kernel memory corruption :^)
2021-12-26 11:26:39 +01:00
Andreas Kling
1c99f99e99 Kernel: Make kmalloc expansions scale to incoming allocation request
This allows kmalloc() to satisfy arbitrary allocation requests instead
of being limited to a static subheap expansion size.
2021-12-26 10:43:07 +01:00
Andreas Kling
f49649645c Kernel: Allocate page tables for the entire kmalloc VM range up front
This avoids getting caught with our pants down when heap expansion fails
due to missing page tables. It also avoids a circular dependency on
kmalloc() by way of HashMap::set() in MemoryManager::ensure_pte().
2021-12-26 02:42:49 +01:00
Andreas Kling
8a51f64503 AK: Increase StringBuilder's inline buffer size from 128 to 256 bytes 2021-12-26 01:42:58 +01:00
Andreas Kling
d58880b5b0 Kernel: Write to debug log when creating new kmalloc subheaps 2021-12-26 01:25:02 +01:00
Andreas Kling
16850423cf Kernel: Fix deadlock caused by page faults while holding disk cache lock
If the data passed to sys$write() is backed by a not-yet-paged-in inode
mapping, we could end up in a situation where we get a page fault when
trying to copy data from userspace.

If that page fault handler tried reading from an inode that someone else
had locked while waiting for the disk cache lock, we'd deadlock.

This patch fixes the issue by copying the userspace data into a local
buffer before acquiring the disk cache lock. This is not ideal since it
incurs an extra copy, and I'm sure we can think of a better solution
eventually.

This was a frequent cause of startup deadlocks on x86_64 for me. :^)
2021-12-26 00:42:51 +01:00
Andreas Kling
4d585cdb82 Kernel: Set NX bit on expanded kmalloc memory mappings if supported
We never want to execute kmalloc memory.
2021-12-25 22:07:59 +01:00
Andreas Kling
da5c257e2e Kernel: Remove unused function declaration for kmalloc_impl() 2021-12-25 22:07:59 +01:00
Andreas Kling
f7a4c34929 Kernel: Make kmalloc heap expansion kmalloc-free
Previously, the heap expansion logic could end up calling kmalloc
recursively, which was quite messy and hard to reason about.

This patch redesigns heap expansion so that it's kmalloc-free:

- We make a single large virtual range allocation at startup
- When expanding, we bump allocate VM from that region
- When expanding, we populate page tables directly ourselves,
  instead of going via MemoryManager.

This makes heap expansion a great deal simpler. However, do note that it
introduces two new flaws that we'll need to deal with eventually:

- The single virtual range allocation is limited to 64 MiB and once
  exhausted, kmalloc() will fail. (Actually, it will PANIC for now..)

- The kmalloc heap can no longer shrink once expanded. Subheaps stay
  in place once constructed.
2021-12-25 22:07:59 +01:00
Ali Mohammad Pur
1a35e27490 LibRegex: Make FailForks fail all forks up to the last save point
This makes negative lookarounds with more than one fork behave
correctly.
Fixes #11350.
2021-12-25 18:41:10 +01:00
Liav A
105d558922 Meta: Remove kernel modules remains
Apparently Andreas found remains for that in the build system.
Let's remove them for completeness of that process of removing support
for kernel modules, which didn't work for many months before being
removed.
2021-12-25 18:42:41 +02:00
Ali Mohammad Pur
986d63466e AK: Remove Variant<Ts...>::operator Variant<NewTs...>()
This is an interface to downcast(), which degrades errors into runtime
errors, and allows seemingly-correct-but-not-quite constructs like the
following to appear to compile, but fail at runtime:

    Variant<NonnullRefPtr<T>, U> foo = ...;
    Variant<RefPtr<T>, U> bar = foo;

The expectation here is that `foo` is converted to a RefPtr<T> if it
contains one, and remains a U otherwise, but in reality, the
NonnullRefPtr<T> variant is simply dropped on the floor, and the
resulting variant becomes invalid, failing the assertion in downcast().

This commit adds a Variant<Ts...>(Variant<NewTs...>) constructor that
ensures that no alternative can be left out at compiletime, for the
users that were using this interface for merely increasing the number of
alternatives (for instance, LibSQL's Value class).
2021-12-25 18:24:43 +03:30
Andreas Kling
7d7950b322 LibVT: Don't leave 50ms auto-scroll timer running at all times
This timer was causing wake-ups every 50ms in all terminals, just to
right back to sleep unless we were in the middle of an auto-scroll.
2021-12-25 14:20:13 +01:00
Andreas Kling
d0df249666 LibCore: Add Core::Timer::set_active(bool)
This calls either start() or stop() depending on the boolean argument.
2021-12-25 14:20:13 +01:00
Andreas Kling
ae07660587 LibC: Buffer randomness to avoid syscall in every arc4random_buf()
Keep a page-sized buffer of random bytes cached and work through it
before calling the kernel again.
2021-12-25 14:20:13 +01:00
Andreas Kling
9965e59ad8 Kernel: Remove unnecessary SocketHandle<T> class
This was used to return a pre-locked UDPSocket in one place, but there
was really no need for that mechanism in the first place since the
caller ends up locking the socket anyway.
2021-12-25 11:23:57 +01:00
Andreas Kling
e923cf6624 strace: Port to LibMain :^) 2021-12-25 11:12:03 +01:00
Andreas Kling
2bd1a62ce1 LibCore: Add syscall wrapper for ptrace() 2021-12-25 11:05:30 +01:00
Andreas Kling
e815bf5d1f PDFViewer: Add a basic set of pledges 2021-12-25 10:58:30 +01:00
Andreas Kling
50e090071c WindowServer: Skip over destroyed windows in WindowSwitcher::draw()
I encountered a WindowServer crash due to null-pointer dereference in
this function, so let's protect against it by simply skipping over
nulled-out WeakPtrs.

I added a FIXME about how we ideally wouldn't be in this situation in
the first place, but that will require some more investigation.
2021-12-25 10:41:06 +01:00
Lady Gegga
68061f999a Base: Add Unified Canadian Aboriginal Syllabics to Katica Regular 10
1400-1488 https://www.unicode.org/charts/PDF/U1400.pdf
2021-12-24 19:54:20 -08:00
Lady Gegga
4570c98592 Base: Add Common Indic Number Forms to font Katica Regular 10
A830-A839 https://www.unicode.org/charts/PDF/UA830.pdf
2021-12-24 19:54:20 -08:00
Daniel Bertalan
a2aae6a582 LibCrypto: Remove redundant __builtin_memset() call
This call caused GCC 12's static analyzer to think that we perform an
out-of-bounds write to the v_key Vector. This is obviously incorrect,
and comes from the fact that GCC doesn't properly track whether we use
the inline storage, or the Vector is allocated on the heap.

While searching for a workaround, Sam pointed out that this call is
redundant as `Vector::resize()` already zeroes out the elements, so we
can completely remove it.

Co-authored-by: Sam Atkins <atkinssj@serenityos.org>
2021-12-24 14:35:33 -08:00
Daniel Bertalan
2b1864c53a AK: Add missing Array.h include to CheckedFormatString.h
GCC 12 complains that iota_array is used before it's declared. GCC 11
works fine without it though.
2021-12-24 14:35:33 -08:00
Brian Gianforcaro
d6f1d11aa0 pro: Convert to serenity_main(..) 2021-12-24 14:29:52 -08:00
Brian Gianforcaro
74948950bb ini: Convert to serenity_main(..) 2021-12-24 14:29:52 -08:00
Brian Gianforcaro
831242f32a env: Convert to serenity_main(..) 2021-12-24 14:29:52 -08:00
Brian Gianforcaro
81c98502f3 pwd: Convert to serenity_main(..) 2021-12-24 14:29:52 -08:00
Brian Gianforcaro
a62669ebcf LibCore: Add Core::System::getcwd() wrapper 2021-12-24 14:29:52 -08:00
Brian Gianforcaro
1c950773fb Kernel: Make MemoryManager::protect_ksyms_after_init UNMAP_AFTER_INIT
The function to protect ksyms after initialization, is only used during
boot of the system, so it can be UNMAP_AFTER_INIT as well.

This requires we switch the order of the init sequence, so we now call
`MM.protect_ksyms_after_init()` before `MM.unmap_text_after_init()`.
2021-12-24 14:28:59 -08:00
Brian Gianforcaro
e88e4967d1 Kernel: Mark PTYMultiplexer init & parse_hex_digit as UNMAP_AFTER_INIT
Noticed these boot only functions are not currently UNMAP_AFTER_INIT.
Lets fix that :^)
2021-12-24 14:28:59 -08:00
Michel Hermier
4758dac218 AK: Make Disjoint*::is_empty() not call size
This is a raffinement of 49cbd4dcca.

Previously, the container was scanned to compute the size in the unhappy
path. Now, using `all_of` happy and unhappy path should be fast.
2021-12-24 05:55:34 -08:00
Michel Hermier
44a6d7968a Tests: Benchmark DisjointChunck::is_empty 2021-12-24 05:55:34 -08:00
Michel Hermier
3a177b9209 AK: Add DisjointChunkc::ensure_capacity 2021-12-24 05:55:34 -08:00
Nihal Jere
4574a58f6f Spider: Add animation when drawing cards 2021-12-24 05:49:52 -08:00
Daniel Bertalan
d70595c09e Ports/tr: Remove obsolete getopt.h patch 2021-12-24 17:02:40 +03:30
Daniel Bertalan
05ce5d82fe Ports/stress-ng: Remove obsolete patches
The following features are now available in the system, making these
patches unnecessary:
- isblank() function
- SIGSTKSZ constant
- MS_SYNC and MS_ASYNC msync() flags
- EDQUOT errno constant
2021-12-24 17:02:40 +03:30
Daniel Bertalan
1c054ac56e Ports/mrsh: Remove obsolete PIPE_BUF patch
We now have this macro in LibC.
2021-12-24 17:02:40 +03:30
Daniel Bertalan
7893ae4233 Ports/mandoc: Remove obsolete patches
Since the creation of the port, we gained support for nanosleep(),
WSTOPSIG(), and the getopt family of functions is now available in
unistd.h.
2021-12-24 17:02:40 +03:30
Daniel Bertalan
29960faf20 Ports/m4: Remove obsolete wint_t patch 2021-12-24 17:02:40 +03:30
Daniel Bertalan
de5937b45e Ports/m4: Fix build error
The addition of the siginfo() function to LibC caused this port to
enable its stack overflow detection feature which, however, depends on
more features that we don't have.
2021-12-24 17:02:40 +03:30
Daniel Bertalan
5b8098497e Ports/libxml2: Remove obsolete ESHUTDOWN errno patch 2021-12-24 17:02:40 +03:30
Daniel Bertalan
43c27e891b Ports/libuv: Remove obsolete statfs/pwrite patch 2021-12-24 17:02:40 +03:30
Daniel Bertalan
a28ad600f2 Ports/libicu: Remove obsolete <cmath> header patch
All issues with `cmath` have been resolved quite some time ago, and
ICU seems to build without issues.
2021-12-24 17:02:40 +03:30
Daniel Bertalan
f35b6ee3fc Ports/emu2: Remove obsolete scandir patch 2021-12-24 17:02:40 +03:30
Daniel Bertalan
ff4787ad2d Ports/chester: Enable -Werror
We no longer emit compiler warnings on deprecated/unsafe functions like
strcpy, so building more ports with -Werror is possible.
2021-12-24 17:02:40 +03:30
Daniel Bertalan
9418d4bf25 Ports/byacc: Remove obsolete getopt.h patch
We (correctly) declare getopt() and the related variables in unistd.h,
so this patch is unnecessary.
2021-12-24 17:02:40 +03:30
Daniel Bertalan
55a42906a7 Ports: Remove obsolete /dev/tty patches 2021-12-24 17:02:40 +03:30
Ali Mohammad Pur
39b5bb4162 Ports: Upgrade CMake to 3.22.1
That's the latest release, and includes one of the patches we had - so
we can drop that patch :^)
2021-12-24 17:01:10 +03:30
Daniel Bertalan
e539a1d077 Ports/cmake: Remove obsolete conflicting declaration patches
I'm not quite sure why, but CMake compiles fine without these.
2021-12-24 17:01:10 +03:30