Commit graph

29437 commits

Author SHA1 Message Date
Idan Horowitz b41954182a PixelPaint: Move Mask::{get, set, to_index} to the header file
They were previously taking up 9% of samples in a profile of PixelPaint
while selecting a mask, and as a result of moving them to the header
they were inlined, which effectively eliminated them from the profile.
2021-10-24 17:02:44 +02:00
Brian Gianforcaro 3e592f5959 Base: Make /usr/Tests read-only since it's now suid capable
Commit cf0dbc906 recently added the ability for setuid binaries to be
located in /usr/Tests. This should really now be read only to mitigate
the potential misuse of any of the setuid binaries.
2021-10-24 11:33:34 +02:00
davidot 9c9aaf4d4f LibJS: Don't VERIFY that a function is Regular when executing in AST
By replacing this VERIFY with a thrown Error we no longer crash when
calling a generator function in the AST interpreter. This allows us to
more gracefully handle situation which have not been implemented yet.
In particular this helps the libjs-test262-runner since it can now
continue on to the next tests instead of having the entire process end.
2021-10-24 08:38:02 +01:00
Daniel Bertalan ff1b72c95c Ports: Remove obsolete bash locale patch
Now that we have a semi-decent support for wide characters and a stubbed
out locale API, this hack is not needed anymore.
2021-10-23 23:31:43 -07:00
Daniel Bertalan b3ac24a939 LibC: Use a sensible MB_CUR_MAX value
We always use UTF-8, meaning that a single `wchar_t` might be converted
into up to 4 `char`s. This would cause a buffer overflow if something
actually relied on this being the right value.
2021-10-23 23:31:43 -07:00
Daniel Bertalan ba975f4ba4 LibC: Define locale categories (LC_*) as macros
The C standard states that these symbols should be declared as macros,
not as emum variants as we were doing previously. This is used in some
ports (e.g. bash) to conditionally compile locale-dependent
functionality.

We now use the same trick here as with the errno constants. We keep the
enum, but also create macros that defer to the enum variants.
2021-10-23 23:31:43 -07:00
Andreas Kling fa753ff863 LibCore: Pop the main Core::EventLoop off the stack when destroyed
The main event loop pushes itself onto the event loop stack, and so it
should also pop itself when destroyed.

This will surface attempts to use the event loop stack after the main
event loop has been destroyed.
2021-10-24 01:01:01 +02:00
Andreas Kling 3bed7d5a5e LibIPC: Use a zero-delay timer for message processing
This lets us avoid using Core::deferred_invoke() which is not usable
during application teardown (as there is no event loop to push the
deferred invocation onto.)

(Not that there is an event loop to fire the processing timer during
teardown *either*, but at least we can exit gracefully with pending
timers, unlike deferred invocations, which hang the process. This is an
area where more improvements are definitely needed!)
2021-10-24 01:01:01 +02:00
Andreas Kling 24642861af LibIPC: Store local endpoint magic in a ConnectionBase member
This simplifies some of the code, since it's no longer necessary for the
templated code to pass LocalEndpoint::static_magic() everywhere.
2021-10-24 01:01:01 +02:00
Andreas Kling 9a8bdf84c8 LibIPC: Move waiting for synchronous responses to ConnectionBase 2021-10-24 01:01:01 +02:00
Andreas Kling 8728d36dd0 LibIPC: Move more of IPC::Connection to ConnectionBase
This patch moves the templated message parsing code to a virtual
try_parse_messages() helper. By doing that, we can move the rest of the
socket draining code up to ConnectionBase and keep it out of line.
2021-10-24 01:01:01 +02:00
Andreas Kling f3c4a357ea LibIPC: Move non-templated parts of IPC::Connection out of line
This patch splits IPC::Connection into Connection and ConnectionBase.
ConnectionBase moves into Connection.cpp so we don't have to inline it
for every single templated subclass.
2021-10-24 01:01:01 +02:00
Andreas Kling 561c18726f LibIPC: Add missing <signal.h> include 2021-10-24 01:01:01 +02:00
Andreas Kling 0221affb31 LibIPC: Add IPC::Stub to forwarding header 2021-10-24 01:01:01 +02:00
Ben Wiederhake 48e4fb239a Shell: Prevent exponential explosion around '$(('
When parse_expression looks at '$((', there are two ways it can end up
in parse_expression again, three consumed characters later. All these
ways fail, so what happened was that the parser tried all possible
combinations, hence taking potentially an exponential amount of time.

1. parse_evaluate swallows the '$(', a new invocation of
   parse_expression swallows the other '(', and through
   parse_list_expression we're at another parse_expression.
2. parse_evaluate swallows the '$(', but returns a SyntaxError.
   parse_expression used to not recognize the error, and treated it as a
   regular AST node, calling into read_concat, then a new invocation of
   parse_expression swallows the other '(', and through
   parse_list_expression we're at another parse_expression.

Fixes #10561.

Found by OSS Fuzz, long-standing issue
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28113
2021-10-23 19:29:59 +01:00
Ben Wiederhake fc519d43ba Fuzzing: Update build instructions
The project needs clang-12, which is not on all systems the default
(e.g. Debian Testing).
2021-10-23 19:29:59 +01:00
Timothy Flynn e503b60bdc LibJS: Convert a few TRYs to MUST in RegExp.prototype
These are marked with ! in the spec. This also adds assertions above
a couple of these operations to be extra sure (the spec also indicates
we should make these assertions).
2021-10-23 19:22:34 +01:00
Ben Wiederhake cb868cfa41 AK+Everywhere: Make Base64 decoding fallible 2021-10-23 19:16:40 +01:00
Ben Wiederhake 3bf1f7ae87 AK: Don't crash on invalid Base64 input
In the long-term, we should probably have a way to signal decoding
failure. For now, it should suffice to at least not crash. This is
particularly relevant because apparently this can be triggered while
parsing a PEM certificate, which happens during every TLS connection.

Found by OSS Fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38979
2021-10-23 19:16:40 +01:00
Timothy Flynn 20f73d2abc LibJS: Convert Atomics functions to ThrowCompletionOr 2021-10-23 19:16:03 +01:00
Timothy Flynn 3edf86462b LibJS: Convert typed_array_from to ThrowCompletionOr 2021-10-23 19:16:03 +01:00
Ben Wiederhake 50698a0db4 AK: Prevent accidental misuse of BumpAllocator
In particular, we implicitly required that the caller initializes the
returned instances themselves (solved by making
UniformBumpAllocator::allocate call the constructor), and BumpAllocator
itself cannot handle classes that are not trivially deconstructible
(solved by deleting the method).

Co-authored-by: Ali Mohammad Pur <ali.mpfard@gmail.com>
2021-10-23 19:02:54 +01:00
Ben Wiederhake 5d865d574a AK: Fix BumpAllocator iteration if last object doesn't align
This fixes two bugs:

1. `end_offset` was missing the alignment that might have been
   introduced while computing `base_ptr`.
2. Ignoring point 1, `end_offset` computed the offset of the first byte
   that is outside the current chunk. However, this might be in the
   middle of a (hypothetical) object! The loop treats `end_offset` as if
   it points to the first byte beyond the last (valid) object. So if the
   last few bytes of the chunk are unused, the loop iterates once too
   often.

Found by OSS Fuzz, long-standing issue (since 2021-07-31)
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38733
(This probably also resolves some other issues that go through
RegexMatcher.)

See also: 0f1425c895
2021-10-23 19:02:54 +01:00
Ben Wiederhake 885b69c877 AK: Check consistency during BumpAllocator allocation 2021-10-23 19:02:54 +01:00
Liav A 8e55c4bfaf Kernel/PCI: Remove InterruptDisabler usage
Instead, just ensure we pick the m_access_lock and then m_scan_lock when
doing a scan/re-scan of the PCI configuration space so we know nobody
can actually access the PCI configuration space during the scan.

The m_scan_lock is now a Spinlock, to ensure we cannot yield to other
process while we do the PCI configuration space scanning.
2021-10-23 19:17:44 +02:00
Liav A 72e831e9e9 Kernel/PCI: Ensure m_domains is not empty if scanning with memory access 2021-10-23 19:17:44 +02:00
Liav A 40b1e6376b Kernel/PCI: Split Access::rescan_hardware method
To ensure clarity, this method is essentially splitted to two methods to
be called according to the access type being determined beforehand.
2021-10-23 19:17:44 +02:00
Liav A d395ac8f59 Kernel/PCI: Rename Access::scan_pci_domains method
We rename it to scan_pci_domains_from_acpi_mcfg_table to ensure clarity,
because this method relies on the ACPI MCFG table to work.
2021-10-23 19:17:44 +02:00
Liav A ca32ee5714 Kernel/PCI: Simplify detect_optimal_access_type function
Instead of getting the kernel commandline argument as function parameter
we just take internally in the function.
2021-10-23 19:17:44 +02:00
Sam Atkins 79522db5d0 HackStudio: Add syntax-highlighting for CSS files 2021-10-23 19:07:44 +02:00
Sam Atkins d2690e551c TextEditor: Add syntax-highlighting for CSS files 2021-10-23 19:07:44 +02:00
Sam Atkins 6f71516409 LibWeb: Syntax-highlight CSS within HTML :^) 2021-10-23 19:07:44 +02:00
Sam Atkins 38f6140159 LibWeb: Implement first draft of CSS syntax highlighting :^)
This works at the Token level, which is quick and easy but has
drawbacks: We don't know when something is a property name or a value,
or if something is part of a selector. But, this works for now.
2021-10-23 19:07:44 +02:00
Sam Atkins ecf5368535 LibWeb: Record position information in CSS Tokens
This is a requirement to be able to use the Tokens for syntax
highlighting.
2021-10-23 19:07:44 +02:00
Sam Atkins 9a2eecaca4 LibWeb: Add CSS Tokenizer::consume_as_much_whitespace_as_possible()
This is a step in the spec in 3 places, and we had it implemented
differently in each one. This unifies them and makes it clearer what
we're doing.
2021-10-23 19:07:44 +02:00
Sam Atkins dfbdc20f87 LibWeb: Add spec links to CSS Tokenizer
Also renamed `starts_with_a_number()` -> `would_start_a_number()` to
better match spec terminology.
2021-10-23 19:07:44 +02:00
Sam Atkins 6edd7a4d73 LibWeb: Implement hashless hex color quirk
https://quirks.spec.whatwg.org/#the-hashless-hex-color-quirk

The CSS parser should now be completely quirky! :^)

The code is a bit awkward, especially the prepending-0s step, but at
least it won't be running too often.
2021-10-23 18:53:17 +02:00
Sam Atkins d1f489b847 LibWeb: Explicitly cast parameters to Color::from_hsl/hsla()
CLion was giving me the angry red underlines about this.
2021-10-23 18:53:17 +02:00
Sam Atkins 21b65de1ec LibGfx+LibWeb: Move "transparent" keyword into Color::from_string()
It seemed odd to have this one color handled separately, when
`Color::from_string()` implements all other CSS colors.
2021-10-23 18:53:17 +02:00
Idan Horowitz 2ab089fa21 LibJS: Convert RegExpStringIteratorPrototype to ThrowCompletionOr 2021-10-23 18:01:51 +02:00
Idan Horowitz 063ce946b7 LibJS: Convert RegExpPrototype functions to ThrowCompletionOr 2021-10-23 18:01:51 +02:00
Idan Horowitz 9b3c91aa65 LibJS: Convert the RegExpExec AO to ThrowCompletionOr 2021-10-23 18:01:51 +02:00
Idan Horowitz a89d9d2c6f LibJS: Convert the RegExpBuiltinExec AO to ThrowCompletionOr 2021-10-23 18:01:51 +02:00
Idan Horowitz a2fbf6a3d5 LibJS: Convert the MakeIndicesArray AO to ThrowCompletionOr 2021-10-23 18:01:51 +02:00
Idan Horowitz e3181a7ded LibJS: Convert RegExpConstructor functions to ThrowCompletionOr 2021-10-23 18:01:51 +02:00
Idan Horowitz 844be7a0a5 LibJS: Convert the RegExpCreate AO to ThrowCompletionOr 2021-10-23 18:01:51 +02:00
Idan Horowitz d9f5e2d461 LibJS: Convert the RegExpInitialize AO to ThrowCompletionOr 2021-10-23 18:01:51 +02:00
Idan Horowitz 35faf50941 LibJS: Convert PromisePrototype functions to ThrowCompletionOr 2021-10-23 18:01:51 +02:00
Idan Horowitz 5af8f72d54 LibJS: Convert PromiseConstructor functions to ThrowCompletionOr 2021-10-23 18:01:51 +02:00
Idan Horowitz 81bdb20c61 LibJS: Convert the PromiseResolve AO to ThrowCompletionOr 2021-10-23 18:01:51 +02:00