Commit graph

52350 commits

Author SHA1 Message Date
kleines Filmröllchen 2fd23745a9 Kernel: Allow relaxing cleanup task rules during system shutdown
Once we move to a more proper shutdown procedure, processes other than
the finalizer task must be able to perform cleanup and finalization
duties, not only because the finalizer task itself needs to be cleaned
up by someone. This global variable, mirroring the early boot flags,
allows a future shutdown process to perform cleanup on its own.

Note that while this *could* be considered a weakening in security, the
attack surface is minimal and the results are not dramatic. To exploit
this, an attacker would have to gain a Kernel write primitive to this
global variable (bypassing KASLR among other things) and then gain some
way of calling the relevant functions, all of this only to destroy some
other running process. The same effect can be achieved with LPE which
can often be gained with significantly simpler userspace exploits (e.g.
of setuid binaries).
2023-07-15 00:12:01 +02:00
kleines Filmröllchen 021fb3ea05 Kernel/Tasks: Allow Kernel processes to be shut down
Since we never check a kernel process's state like a userland process,
it's possible for a kernel process to ignore the fact that someone is
trying to kill it, and continue running. This is not desireable if we
want to properly shutdown all processes, including Kernel ones.
2023-07-15 00:12:01 +02:00
kleines Filmröllchen 8940552d1d Kernel/VirtualFileSystem: Allow unmounting via inode and mount path
This pair of information uniquely identifies any mount point, and it can
be used in situations where mount point custodies are not available.
2023-07-15 00:12:01 +02:00
kleines Filmröllchen abc1eaff36 Kernel/VirtualFileSystem: Count bind mounts towards normal FS mountcount
This is correct since unmount doesn't treat bind mounts specially. If we
don't do this, unmounting bind mounts will call
prepare_for_last_unmount() on the guest FS much too early, which will
most likely fail due to a busy file system.
2023-07-15 00:12:01 +02:00
kleines Filmröllchen 251b17085b Kernel/Ext2: Check and set file system state
This is supposed to detect whether a file system was unmounted
cleanly or not.
2023-07-15 00:12:01 +02:00
kleines Filmröllchen 8fb126bec6 Kernel/FileSystem: Pass last mount point guest inode to unmount prepare
This will be important later on when we check file system busyness.
2023-07-15 00:12:01 +02:00
kleines Filmröllchen 2fe5ece449 Kernel: Add accessor for mount host custody
There's no reason this information needs to be secret.
2023-07-15 00:12:01 +02:00
networkException 103913305b README+Meta: Update the screenshot :^)
Recreating the previous screenshot in a current build of the system will
show many, usually subtle, changes in comparison.

This patch adds a new screenshot of the SerenityOS desktop with
Terminal, File Manager, System Monitor and Ladybird visible.
2023-07-14 23:40:58 +02:00
Xexxa c03b788892 Base: Add more emoji
🧑‍🎓 - U+1F9D1 U+200D U+1F393 STUDENT
🏯 - U+1F3EF JAPANESE CASTLE
🏙️ - U+1F3D9 CITYSCAPE
🚓 - U+1F693 POLICE CAR
🚙 - U+1F699 SPORT UTILITY VEHICLE
2023-07-14 15:42:48 -04:00
Lucas CHOLLET 15bd708cfd file: Use the mime-type description provided by LibCore
This allows us to get rid of another mime-type list in the codebase.

To do so, the `get_description_from_mime_type` function is introduced in
this patch.
2023-07-14 17:33:06 +01:00
Lucas CHOLLET c543a13835 LibCore: Share the mime-type list between the two detection methods
We used to have two separate lists for mime-type detection, one for
detection based on the file extension, and the other one for detection
based on byte sniffing.

This list also contains a general description that will be of use in
`file.cpp`.

To create this list, I had to fill in some gaps as the two lists started
to diverge.
2023-07-14 17:33:06 +01:00
Daniel Bertalan e3f65f215d LibJS/Bytecode: Do not rethrow caught exception from finally
If the exception from the `try` block has already been caught by
`catch`, we need to clear the saved exception before entering `finally`
so that ContinuePendingUnwind will not re-throw it.

9 new passes on test262 :^)
2023-07-14 17:05:29 +02:00
Nico Weber 93b3f12680 LibPDF: Fix quadratic runtime in stream dumping
DeprecatedString::substring() makes a copy of the substring.
Instead, use a StringView, which can make substring views in constant
time.

Reduces time for `pdf --dump-contents image-based-pdf-sample.pdf` to
2.2s (from not completing for 1+ minutes).

That file contains a 221 kB jpeg.

Find it on the internet here:
https://nlsblog.org/wp-content/uploads/2020/06/image-based-pdf-sample.pdf
2023-07-14 09:50:30 -04:00
Nico Weber d18f01d7d7 LibPDF: Simplify a loop
No behavior change.
2023-07-14 09:50:30 -04:00
Aliaksandr Kalenik e4e1208050 LibWeb: Respect justify-self property of grid items 2023-07-14 15:48:58 +02:00
Aliaksandr Kalenik fedbb39e9e LibWeb: Add support for justify-self property in CSS parser 2023-07-14 15:48:58 +02:00
Ali Mohammad Pur fbab9bc330 LibRegex: Avoid pointlessly slicing a UTF-16 string for one code unit
This simple change is a nice 9% speedup on the regex test suite :^)
2023-07-14 11:22:21 +02:00
Andreas Kling 17bff999c8 LibRegex: Remove redundant VERIFY in OpCode::argument()
The bounds check here is already performed by the at() we're calling,
and removing it appears to have non-trivial performance impact.
2023-07-14 09:09:11 +02:00
Ali Mohammad Pur 4bff4219ff LibRegex: Replace the checkpoint backing store with a Vector
This makes repeated lookups and insertions much faster, yielding a
general performance improvement of about 10% in the regex test suite.
2023-07-14 08:59:19 +02:00
Ali Mohammad Pur 2d6f50932b LibRegex: Assign unique serial IDs to checkpoints
This makes the compiler assign a serial ID to each checkpoint instead of
using the IP as the identifier.
This will be used in a future commit to replace the backing store of
checkpoints with a vector.
2023-07-14 08:59:19 +02:00
Ali Mohammad Pur 06573cd46d LibRegex: Enable the atomic rewrite optimisation for unicode properties 2023-07-14 08:59:19 +02:00
Lucas CHOLLET c5a6f0fb4d FileManager: Exit the properties window on escape 2023-07-14 06:52:38 +02:00
Lucas CHOLLET 3e6e75bb5e FileManager: Return a StringView from PropertiesWindow::get_description 2023-07-14 06:52:38 +02:00
Lucas CHOLLET ea2ffdfd0e LibGUI: Bubble up Key_Escape if no hook is plugged in TextEditor
The TextEditor widget was always accepting the Key_Escape event even if
the `on_escape_pressed` was empty. In other words, it was discarding the
event.

This behavior prevented shortcuts to be activated at a higher level.
2023-07-14 06:52:38 +02:00
Lucas CHOLLET 201890e109 LibGUI: Don't call on_escape_pressed from EditingEngines
The call will be handled in `TextEditor::keydown_event`, just after that
`EditingEngine::on_key()` is called.
2023-07-14 06:52:38 +02:00
MacDue 4aa0ef9f98 ImageViewer: Support displaying vector graphics (at arbitrary scales)
With this, you can scale, flip, and rotate vector graphics in the image
viewer like any other image, but with no pixelation :^)

With this change, vector graphics are decoded in-process (since there's
no standard way to encode them over IPC, a new encoding would be needed
for each format, which would be pretty much just be recreating that
format).

Raster images are still decoded out of process, so the surface area for
attack is still kept to a minimum.
2023-07-14 06:51:05 +02:00
MacDue 57c81c1719 LibGfx: Lazily load TinyVG image data
This matches the behavior of other decoders, and ensures just getting
the size (e.g. for the `file` command) does not read the whole file.
2023-07-14 06:51:05 +02:00
MacDue 753cf04be8 LibGfx: Allow requesting vector graphic frames from ImageDecoder
Only supported for plugins that set is_vector() to true. This returns
the frames as Gfx::VectorGraphics, which allows painting/rasterizing
them with arbitrary transforms and scales.
2023-07-14 06:51:05 +02:00
MacDue 8784568a36 LibGUI: Pass ideal size when requesting thumbnail bitmaps
This makes thumbnails for vector graphics look much nicer :^)
2023-07-14 06:51:05 +02:00
MacDue 90e836deae LibGfx: Fix elliptical arcs after non orientation preserving transform
That is flipping/reflecting the arc.
2023-07-14 06:51:05 +02:00
MacDue 9ecc78db1b LibGfx: Add AffineTransform::determinant() 2023-07-14 06:51:05 +02:00
MacDue 16b487c270 LibGfx: Add simple VectorGraphic abstract base class
This is currently very bare-bones with just the size and a few methods
to rasterize/draw the graphic.
2023-07-14 06:51:05 +02:00
Daniel Bertalan aaf1b762ea AK: Remove redundant information from TypeErasedFormatParams
The array which contains the actual parameters is always located
immediately after the base `TypeErasedFormatParams` object of
`VariadicFormatParams`. Hence, storing a pointer to it inside a `Span`
is redundant. Changing it to a zero-length array saves 8 bytes.

Secondly, we limit the number of parameters to 256, so `m_size` and
`m_next_index` can be stored in a smaller data type than `size_t`,
saving us another 8 bytes.

This decreases the size of a single-element `VariadicFormatParams` from
48 to 32 bytes, thus reducing the code size overhead of setting up
parameters for `dbgln()`.

Note that [arrays of length zero][1] are a GNU extension, but it's used
elsewhere in the codebase already and is explicitly supported by Clang
and GCC.

[1]: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
2023-07-14 06:37:11 +02:00
Nico Weber 281e3158c0 LibPDF: Some preparatory work for AESV3
This detects AESV3, and copies over the spec comments explaining what
needs to be done, but doesn't actually do it yet.

AESV3 is technically PDF 2.0-only, but
https://cipa.jp/std/documents/download_e.html?CIPA_DC-007-2021_E has a
1.7 PDF that uses it.

Previously we'd claim that we need a password to decrypt it.
Now, we cleanly crash with a TODO() \o/
2023-07-14 06:34:03 +02:00
Lucas CHOLLET b14d51ba1b LibGfx/QOI: Decode the header in create() and remove initialize()
This is done as a part of #19893.
2023-07-14 06:17:12 +02:00
Lucas CHOLLET 5fd1ee0365 LibGfx/QOI: Remove useless parameters from member functions
Both `decode_[header,image]_and_update_context()` used to take a
`Stream&` as parameter, but they are always called with the field
`m_context.stream` so no need to take it as a parameter.
2023-07-14 06:17:12 +02:00
Lucas CHOLLET 1ae772c7d3 LibGfx/JPEG: Decode the header in create()
This is done as a part of #19893.
2023-07-14 06:16:56 +02:00
Lucas CHOLLET 2f125b86aa LibGfx/JPEG: Remove the unused method initialize() 2023-07-14 06:16:56 +02:00
Gabriel Dinner-David d29bd55b48 LibJS: Implement import.meta for bytecode 2023-07-14 06:06:04 +02:00
Aliaksandr Kalenik a1692931af LibJS/Bytecode: Skip CreateVariable for locals in "for" loop head
CreateVariable is not needed for locals because they are not stored in
environment and created binding will not be used. Also if all variables
in loop initialization sections are local then CreateLexicalEnvironment
and LeaveLexicalEnvironment can also be ommitted.
2023-07-14 05:58:30 +02:00
Aliaksandr Kalenik 6b191ab73d LibJS+LibWeb: Add fast_is<DOM::Node> for JS::Object
Solves problem that is<DOM::Node, JS::Object>() is quite hot in
profiles while loading https://www.postgresql.org/about/featurematrix/.
2023-07-14 05:55:41 +02:00
Andreas Kling 1470e60800 LibWeb: Add logical CSS properties for insets
This patch adds the following properties:

- inset-inline
- inset-inline-start
- inset-inline-end
- inset-block
- inset-block-start
- inset-block-end
2023-07-14 05:55:32 +02:00
Pierre Delagrave fc065ee560 LibCore: Add Traits<Core::SocketAddress>::hash() 2023-07-14 05:54:17 +02:00
Andrew Kaster d185217599 Meta: Add gn linter
This just calls ``gn format`` on any .gn or .gni files, but it matches
the pattern of the other linters.
2023-07-13 14:07:25 -06:00
Andrew Kaster a21a08cc9d Meta: Format LibWeb gn files
This was missed when merging the initial set. Linter should be next :^)
2023-07-13 14:07:25 -06:00
Andrew Kaster 9061ea4e90 Meta: Add a macOS bundle to gn build for ladybird
This allows opening the ladybird.app app bundle on macOS, using Xcode
tools like Instruments on the applications in the app bundle, and even
installing the app bundle into /Applications :^)
2023-07-13 14:07:25 -06:00
Andrew Kaster 18a4e882dc Meta: Setup rpath/install_name for macOS libraries and binaries in gn 2023-07-13 14:07:25 -06:00
Andrew Kaster 8475ccc232 Meta: Port c0f985ffcf to gn build 2023-07-13 14:07:25 -06:00
Andrew Kaster 2f16aa45b7 Meta: Port dd073b2711 to gn build 2023-07-13 14:07:25 -06:00
Andreas Kling a3e4535f34 LibJS: Resolve rope strings directly to UTF-16 when preferable
When someone calls PrimitiveString::utf16_string() on a rope string,
we know for sure that the client wants a UTF-16 string and may not
be interested in a UTF-8 version at all.

To avoid round-tripping through UTF-8 in this scenario, callers can
now inform resolve_rope_if_needed() about their preferred encoding,
should rope resolution take place. The UTF-16 case is actually a lot
simpler than the UTF-8 case, since we can simply ask for UTF-16 data
for each fiber of the rope, and then concatenate all the fibers.

Since LibJS always uses UTF-16 for regular expression matching, this
avoids round-tripping through UTF-8 whenever the input to a regex test
is already UTF-16. :^)
2023-07-13 20:53:54 +02:00