Commit Graph

20252 Commits

Author SHA1 Message Date
Brian Gianforcaro
a324d4d6a3 Kernel: Make AnonymousVMObject physical page APIs OOM safe
AnonymousVMObject::create_with_physical_page(s) can't be NonnullRefPtr
as it allocates internally. Fixing the API then surfaced an issue in
ScatterGatherList, where the code was attempting to create an
AnonymousVMObject in the constructor which will not be observable
during OOM.

Fix all of these issues and start propagating errors at the callers
of the AnonymousVMObject and ScatterGatherList APis.
2021-05-15 09:01:32 +02:00
Brian Gianforcaro
d45db06826 Kernel: Make AnonymousVMObject::clone/create APIs OOM safe 2021-05-15 09:01:32 +02:00
Brian Gianforcaro
ede1483e48 Kernel: Make Process creation APIs OOM safe
This change looks more involved than it actually is. This simply
reshuffles the previous Process constructor and splits out the
parts which can fail (resource allocation) into separate methods
which can be called from a factory method. The factory is then
used everywhere instead of the constructor.
2021-05-15 09:01:32 +02:00
Brian Gianforcaro
77868abe6a Kernel: Make PTYMultiplexer::open API OOM safe 2021-05-15 09:01:32 +02:00
Brian Gianforcaro
f3f5a225b9 Kernel: Fix lock state corruption in AHCIPORT::start_request
This code was unlocking the lock directly, but the Locker is still
attached, causing the lock to be unlocked an extra time, hence
corrupting the internal lock state.

This is extra confusing though, as complete_current_request() runs
without a lock which also looks like a bug. But that's a task for
another day.
2021-05-15 09:01:13 +02:00
Brian Gianforcaro
f982ef0ef0 Kernel: Halt CPU on deadly UBSAN instead of calling PANIC
The separate backtrace that the PANIC emits isn't useful and just adds
more data to visually filter from the output when debugging an issue.
Instead of calling PANIC, just emit the message with dbgln() and
manually halt the system.
2021-05-15 09:00:29 +02:00
Brian Gianforcaro
db78331741 Kernel: Don't crash in page_fault_handler if current_thread is null
If we are attempting to emit debugging information about an unhandleable
page fault, don't crash trying to kill threads or dump processes if the
current_thread isn't set in TLS. Attempt to keep proceeding in order to
dump as much useful information as possible.

Related: #6948
2021-05-15 09:00:29 +02:00
Daniel Bertalan
00498e0405
Documentation: Document CMake build options
Closes #7107.
2021-05-15 00:55:36 +01:00
Jelle Raaijmakers
5864aab87a LibGfx/Vector*: Implement Formatters 2021-05-15 00:41:30 +01:00
Linus Groh
9459f3728c Meta: Check that copyright headers are followed by a blank line 2021-05-15 00:28:30 +01:00
Linus Groh
d8a3609aa9 Everywhere: Add a blank line after copyright header where missing 2021-05-15 00:27:09 +01:00
Linus Groh
64c0deb1f1 SpaceAnalyzer: Add separator before quit menu action 2021-05-15 00:24:07 +01:00
Linus Groh
067b880459 SystemMonitor: Make ProcessModel icon column non-sortable
Sorting by icon is neither intuitive nor useful, so let's disable it
(like in GUI::FileSystemModel).
2021-05-15 00:15:09 +01:00
Linus Groh
5ee9aab7e1 Meta: Bump BIOS/MBR boot partition size of grub disk image to 1MiB
As of ~April 2021 the Meta/build-image-grub.sh script no longer works
for me (on Fedora 34) and fails with the following error:

    /usr/sbin/grub2-install: warning: ../grub-core/partmap/msdos.c:403:
    your core.img is unusually large. It won't fit in the embedding
    area.

    /usr/sbin/grub2-install: warning: Embedding is not possible. GRUB
    can only be installed in this setup by using blocklists. However,
    blocklists are UNRELIABLE and their use is discouraged..

    /usr/sbin/grub2-install: error: will not proceed with blocklists.

Changing the size of the boot partition from 32 kiB to 1 MiB (2048
sectors) fixes the issue. This is also described in the following Ubuntu
grub2 bug (as well as 40 duplicates!) from 2012, which suggests the same
fix: https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1059827

The Arch Linux wiki also uses 1 MiB in their BIOS/MBR examples for
parted: https://wiki.archlinux.org/title/Parted

I'm not sure why this suddenly stopped working, however I was able to
boot with an image created with this change applied.
2021-05-15 00:57:35 +02:00
Andreas Kling
b31602367e LibELF: Use binary search when looking up symbols :^)
For whatever reason, symbolication was doing an O(n) walk of all the
symbols, despite having sorted them beforehand.

Changing this to a binary_search() makes symbolication noticeably
faster and improves Profiler startup time.
2021-05-15 00:51:23 +02:00
Andreas Kling
ef09f9c825 SystemMonitor: Make sure we set a model before changing column sizes
Changing a view's column metadata requires that a model is set.
2021-05-15 00:50:51 +02:00
Andreas Kling
16221305ad LibELF: Remove sketchy use of "undefined" ELF::Image::Section
We were using ELF::Image::section(0) to indicate the "undefined"
section, when what we really wanted was just Optional<Section>.

So let's use Optional instead. :^)
2021-05-15 00:17:55 +02:00
Mart G
f70d0f03de SpaceAnalyzer: Use fstatat instead of lstat
By using fstatat during file system analyzation instead of lstat, we
reduce the amount of work the kernel has to do for each stat call.

During profiling it came up that the kernel was spending a lot of time
resolving paths. Because each call to stat passed an absolute path the
kernel had to do the same work over and over again.

When using relative paths the kernel only has to resolve the relative
part as it can reuse the already resolved path of the base directory.
2021-05-14 23:32:10 +02:00
Mart G
758085571f LibCore: Expose DirIterator's underlying file descriptor 2021-05-14 23:32:10 +02:00
Mart G
e7310ba45a Kernel+LibC: Add fstatat
The function fstatat can do the same thing as the stat and lstat
functions. However, it can be passed the file descriptor of a directory
which will be used when as the starting point for relative paths. This
is contrary to stat and lstat which use the current working directory as
the starting for relative paths.
2021-05-14 23:32:10 +02:00
Jean-Baptiste Boric
875116c3e5 Utilities: Fix const-correctness inside seq 2021-05-14 22:24:02 +02:00
Jean-Baptiste Boric
d76987be96 LibC: Move makedev(), major(), minor(), to sys/types.h
It's technically not specified by POSIX, but it appears most Unix-like
systems worth mentioning put those definitions there. Also, it's more
logical since the dev_t type is defined there.
2021-05-14 22:24:02 +02:00
Jean-Baptiste Boric
eecf7a2097 LibC: Move mman.h to sys/mman.h
POSIX mandates that it is placed there.
2021-05-14 22:24:02 +02:00
Jean-Baptiste Boric
e16894af5a LibC: Do not include errno.h inside unistd.h
POSIX does not mandate this, therefore let's not do it.
2021-05-14 22:24:02 +02:00
Jean-Baptiste Boric
7f498769ac LibThread: Port Lock to foreign environments 2021-05-14 22:24:02 +02:00
Jean-Baptiste Boric
9853a4393c IPCCompiler: Fix declaration of static functions 2021-05-14 22:24:02 +02:00
Jean-Baptiste Boric
090936e424 Userland: Replace arc4random() with get_random<u32>() 2021-05-14 22:24:02 +02:00
Jean-Baptiste Boric
5a0468c21f Userland: Migrate from arc4random_uniform() to get_random_uniform() 2021-05-14 22:24:02 +02:00
Jean-Baptiste Boric
069bf988ed AK: Introduce get_random_uniform()
This is arc4random_uniform(), but inside AK.
2021-05-14 22:24:02 +02:00
Jean-Baptiste Boric
ad7cd05fc1 AK: Fix redefinition of macro inside AK/Platform.h 2021-05-14 22:24:02 +02:00
Stephan Unverwerth
2b9ad11bd8 LibGL: Implement glFlush() and glFinish() 2021-05-14 22:15:50 +02:00
Andreas Kling
3429b44161 LibCore: Never connect to InspectorServer if getuid() == 0
Let's just stay on the safe side with this.
2021-05-14 22:12:52 +02:00
Linus Groh
5c05dfecb5 Meta: Remove accidentally committed 'js.js' file 2021-05-14 20:19:59 +01:00
Linus Groh
f512b24b21 AnalogClock: Use YYYY-MM-DD format for window title 2021-05-14 20:17:09 +01:00
Andreas Kling
212e1ba0d4 ImageViewer: Sandbox image decoding using the ImageDecoder service :^)
Instead of parsing untrusted and potentially malicious image files in
the ImageViewer GUI process, take advantage of the ImageDecoder service
that we already have on the system to sandbox the decode.

This prevents bugs in our image decoding libraries from being used as
an exploitation vector when viewing files in ImageViewer.
2021-05-14 21:02:18 +02:00
Andreas Kling
fa0e23009a LibImageDecoderClient: Decoded images with 0 frames are not successful
Previously you could pass anything (e.g a text file) to ImageDecoder and
it would "succeed" in decoding it and give you back a 0-frame result.

Let's consider that state a failure instead.
2021-05-14 21:02:14 +02:00
Andreas Kling
3168a4afe8 ImageViewer: Rename QSWidget => ImageViewer::ViewWidget 2021-05-14 18:37:08 +02:00
Andreas Kling
58d73ea36c Userland: Rename QuickShow => Image Viewer
The old name was a bit too ambiguous. This one is crystal clear. :^)
2021-05-14 18:34:44 +02:00
Andreas Kling
d039542c7c AK: Remove unused STRINGIMPL_DEBUG instrumentation 2021-05-14 17:17:32 +02:00
Andreas Kling
5fd65adb19 Browser: Don't spawn RequestServer and WebSocket in multi-process mode
Single-process Browser forces a connection to these services early on,
to avoid having to unveil their paths. I'm suspicious of the benefits
of this (and the comment about it wasn't even accurate) but let's keep
it for now.

In multi-process mode, there's no need to do this, and in fact it was
causing us to spawn two extra totally unused processes.
2021-05-14 17:17:30 +02:00
Andreas Kling
3ed5a73ede Profiler: Mark model columns as non-sortable
This removes the ability to click on the column headers to resort.
Resorting didn't do anything anyway.
2021-05-14 17:17:17 +02:00
Gunnar Beutner
c22296505c Kernel: Merge do_retransmit_packets() into retransmit_packets() 2021-05-14 16:50:00 +02:00
Gunnar Beutner
08aa3a91e3 Kernel: Try to retransmit lost TCP packets
Previously we didn't retransmit lost TCP packets which would cause
connections to hang if packets were lost. Also we now time out
TCP connections after a number of retransmission attempts.
2021-05-14 16:50:00 +02:00
Gunnar Beutner
9daec809b7 Kernel: Wake up NetworkTask every 500 milliseconds
This wakes up NetworkTask every 500 milliseconds so that it can send
pending delayed TCP ACKs and isn't forced to send all of them early
when it goes to sleep like it did before.
2021-05-14 16:50:00 +02:00
Gunnar Beutner
990b2d0989 Kernel: Don't use delayed ACKs when establishing the connection
When establishing the connection we should send ACKs right away so
as to not delay the connection process. This didn't previously
matter because we'd flush all delayed ACKs when NetworkTask waits
for incoming packets.
2021-05-14 16:50:00 +02:00
Andreas Kling
aea709de31 Meta: Add note about writing commit subjects in the imperative mood 2021-05-14 16:45:27 +02:00
Andreas Kling
3e603b2f32 AK: Make StringView::hash() constexpr
This required moving string_hash() to its own header so that everyone
can see it.
2021-05-14 15:24:32 +02:00
Brian Gianforcaro
9c38475608 Kernel: Add the ability to verify we don't kmalloc under spinlock.
Ideally we would never allocate under a spinlock, as it has many
performance and potentially functionality (deadlock) pitfalls.

We violate that rule in many places today, but we need a tool to track
them all down and fix them. This change introduces a new macro option
named `KMALLOC_VERIFY_NO_SPINLOCK_HELD` which can catch these
situations at runtime via an assert.
2021-05-14 13:28:21 +02:00
Itamar
6329e9fce6 LanguageServer/Cpp: Add tests
The Cpp LanguageServer tests can be run with: CppLanguageServer -t

The tests now only cover some very simple autocomplete and
"find declaration" use cases, but it's a start :)
2021-05-14 13:27:47 +02:00
Itamar
e9fc5d6cc3 LanguageServers: Allow set_declarations_of_document callback to be null 2021-05-14 13:27:47 +02:00