Commit Graph

16322 Commits

Author SHA1 Message Date
Linus Groh
8fa8dda97c Base: Add missing umlauts to DE keymap 2021-01-29 23:21:07 +01:00
Linus Groh
b1b015c052 Base: Fix missing "£" in GB keymap
Shift+3 is "£", not "#".
2021-01-29 23:21:07 +01:00
Linus Groh
f70a364a83 Base: Reformat some keymaps
This is in line with all the other ones, and makes finding the same keys
in each map array a little easier.
2021-01-29 23:21:07 +01:00
Andreas Kling
4ab2ff95ce ls: Lazily align the number of hard links in ls output :^)
Fixes #5155
2021-01-29 23:05:02 +01:00
Ben Wiederhake
0558c74e30 WindowServer: Constrain geometry label on move/resize to desktop
Fixes #5063.
2021-01-29 22:49:12 +01:00
Ben Wiederhake
cf586311a6 WindowServer: Split double-duty Window::normalize_rect()
This commit:
- merges the two(!) places that defined independently the minimum size of a window.
- splits Window::normalize_rect(), which was originally just a function to apply
  the minimum size requirement, and has taken on the additional job of nudging
  windows back onto the desktop.

This inadvertantly fixes a crash that happens when a malicious program creates a
window of size (0, 0). Now, a window at [0,0 50x50] is created instead.
2021-01-29 22:49:12 +01:00
Ben Wiederhake
79f534ef12 WindowServer: Allow superdrags to hide the titlebar
Fixes #5105.
2021-01-29 22:49:12 +01:00
Ben Wiederhake
e200824125 WindowServer: Count titlebar towards visible/grabbable area
This had lead to some surprising asymmetry at the bottom of the screen.
2021-01-29 22:49:12 +01:00
Ben Wiederhake
3fd5aec187 WindowServer: Properly determine where a window may be
This also fixes weird behavior of WindowManager::desktop_rect().
None of the callers seem to ever expect an empty Rect, so return a non-empty Rect.
2021-01-29 22:49:12 +01:00
Linus Groh
af605afb27 Ports: Update neofetch to 7.1.0 2021-01-29 22:48:58 +01:00
Linus Groh
34902f18ce Ports: Revert neofetch shebang patch change
Looks like this was a search & replace from 0bf5669, but it doesn't
actually work in Serenity.
2021-01-29 22:48:58 +01:00
Andreas Kling
7449c1b27f ImageDecoder+LibImageDecoder+LibWeb: Support animations in ImageDecoder
The ImageDecoder service now returns a list of image frames, each with
a duration value.

The code for in-process image decoding is removed from LibWeb, an all
image decode requests are sent out-of-process to ImageDecoder. :^)

This won't scale super well to very long and/or large animations, but
we can work on improving that separately. The main goal here is simply
to stop doing any image decoding inside LibWeb.

Fixes #5165.
2021-01-29 22:38:22 +01:00
Andreas Kling
449d56ef74 LibGfx: Don't use Gfx::Painter in GIF decoder
Painter currently tries to load fonts, which won't work if we're in a
tightly pledged process.

It was only used to fill a rect with transparent pixels, so just do
that manually instead.
2021-01-29 22:30:12 +01:00
Andreas Kling
a8c823f242 Kernel: Bump the number of fd's that can be queued on a local socket 2021-01-29 22:11:59 +01:00
Andreas Kling
0324144e2a LibWeb: Update the ICB's idea of the viewport rect after Frame resize
This makes animations start if they are uncovered by a resize.
2021-01-29 22:03:04 +01:00
Luke
40de84ba67 Kernel/Storage: Rewrite IDE disk detection and disk access
This replaces the current disk detection and disk access code with
code based on https://wiki.osdev.org/IDE

This allows the system to boot on VirtualBox with serial debugging
enabled and VMWare Player.

I believe there were several issues with the current code:
- It didn't utilise the last 8 bits of the LBA in 24-bit mode.
- {read,write}_sectors_with_dma was not setting the obsolete bits,
  which according to OSdev wiki aren't used but should be set.
- The PIO and DMA methods were using slightly different copy
  and pasted access code, which is now put into a single
  function called "ata_access"
- PIO mode doesn't work. This doesn't fix that and should
  be looked into in the future.
- The detection code was not checking for ATA/ATAPI.
- The detection code accidentally had cyls/heads/spt as 8-bit,
  when they're 16-bit.
- The capabilities of the device were not considered. This is now
  brought in and is currently used to check if the device supports
  LBA. If not, use CHS.
2021-01-29 21:20:38 +01:00
Linus Groh
f9b1a9e60c LibJS: Let RegExp.string get RegExp.prototype from the global object directly
We can't assume that RegExp on the global object is still the original
constructor, or an object at all.

This makes '--RegExp<</<</</,/</x/' work. :^)

Found by OSS-Fuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29740
2021-01-29 20:50:22 +01:00
Andreas Kling
d0c5979d96 Kernel: Add "prot_exec" pledge promise and require it for PROT_EXEC
This prevents sys$mmap() and sys$mprotect() from creating executable
memory mappings in pledged programs that don't have this promise.

Note that the dynamic loader runs before pledging happens, so it's
unaffected by this.
2021-01-29 18:56:34 +01:00
Jorropo
df30b3e54c
Kernel: RangeAllocator randomized correctly check if size is in bound. (#5164)
The random address proposals were not checked with the size so it was
increasely likely to try to allocate outside of available space with
larger and larger sizes.

Now they will be ignored instead of triggering a Kernel assertion
failure.

This is a continuation of: c8e7baf4b8
2021-01-29 17:18:23 +01:00
Andreas Kling
51df44534b Kernel: Disallow mapping anonymous memory as executable
This adds another layer of defense against introducing new code into a
running process. The only permitted way of doing so is by mmapping an
open file with PROT_READ | PROT_EXEC.

This does make any future JIT implementations slightly more complicated
but I think it's a worthwhile trade-off at this point. :^)
2021-01-29 14:52:34 +01:00
Andreas Kling
af3d3c5c4a Kernel: Enforce W^X more strictly (like PaX MPROTECT)
This patch adds enforcement of two new rules:

- Memory that was previously writable cannot become executable
- Memory that was previously executable cannot become writable

Unfortunately we have to make an exception for text relocations in the
dynamic loader. Since those necessitate writing into a private copy
of library code, we allow programs to transition from RW to RX under
very specific conditions. See the implementation of sys$mprotect()'s
should_make_executable_exception_for_dynamic_loader() for details.
2021-01-29 14:52:27 +01:00
Andreas Kling
d988bd86e4 LibELF: Map text segments read-only at first
To support upcoming W^X changes in the kernel, the dynamic loader needs
to be careful about the order in which permissions are added to shared
library text segments.

We now start by mapping text segments read-only (no-write, no-exec).
If relocations are needed, we make them writable, and then finally,
for all text segments, we finish by making them read+exec.
2021-01-29 14:52:22 +01:00
Andreas Kling
3438b77aa4 LibELF: Tidy up DynamicLoader::load_program_headers() a bit
Remove a confusing temporary, rename some things and add assertions.
2021-01-29 13:45:41 +01:00
Andreas Kling
c8e7baf4b8 Kernel: Check for alignment size overflow when allocating VM ranges
Also add some sanity check assertions that we're generating and
returning ranges contained within the RangeAllocator's total range.

Fixes #5162.
2021-01-29 12:11:42 +01:00
Andreas Kling
e2abf615b7 pmap: Trim "VMObject" suffix from VMObject types to save space 2021-01-29 11:06:35 +01:00
Andreas Kling
0682a35148 SystemMonitor: Show VM region addresses as zero-padded hex ({:p})
0x1000000 and 0x10000000 looked way too similar without a leading zero.
2021-01-29 11:00:46 +01:00
Andreas Kling
3c7f5392a9 SystemMonitor: Trim "VMObject" suffix from VMObject types
Every VMObject type ends in "VMObject" and it's just taking up space.
2021-01-29 11:00:46 +01:00
Brendan Coles
ef06215e7a pmap: Add shared flag to access column and align-right numeric columns 2021-01-29 09:53:50 +01:00
Andreas Kling
a061bd2ab9 js: Handle exceptions thrown during value printing
If an exception was thrown while printing the last computed value in
the REPL, it would always assert on next input.

Something like this would always assert:

> a=[];Object.defineProperty(a,"0",{get:()=>{throw ""}})
> 1 + 2
2021-01-29 09:16:06 +01:00
Jorropo
c33d50872e
LibELF: perror on failed mmap in load_program_headers (#5159) 2021-01-29 08:50:43 +01:00
Luke
3f5532d43e LibWeb: Flesh out prepare_script and execute_script
This fills in a bunch of the FIXMEs that was in prepare_script.

execute_script is almost finished, it's just missing the module side.

As an aside, let's not assert when inserting a script element with
innerHTML.
2021-01-29 08:49:50 +01:00
Linus Groh
dbbc378fb2 Kernel: Return -ENOTBLK for non-block device Ext2FS mount source
When mounting an Ext2FS, a block device source is required. All other
filesystem types are unaffected, as most of them ignore the source file
descriptor anyway.

Fixes #5153.
2021-01-29 08:45:56 +01:00
Linus Groh
b7b09470ca Kernel: Return -ENOTDIR for non-directory mount target
The absence of this check allowed silly things like this:

    # touch file
    # mount /dev/hda file
2021-01-29 08:45:56 +01:00
Sahan Fernando
6876b9a514 Kernel: Prevent mmap-ing as both fixed and randomized 2021-01-29 07:45:00 +01:00
Jorropo
22b0ff05d4
Kernel: sys$mmap PAGE_ROUND_UP size before calling allocate_randomized (#5154)
`allocate_randomized` assert an already sanitized size but `mmap` were
just forwarding whatever the process asked so it was possible to
trigger a kernel panic from an unpriviliged process just by asking some
randomly placed memory and a size non alligned with the page size.
This fixes this issue by rounding up to the next page size before
calling `allocate_randomized`.

Fixes #5149
2021-01-28 22:36:20 +01:00
Jorropo
eafe4f942d
Ports (jq): Add .patch extension to the diff to fit the wildcard (#5148)
This fixes the build of `jq`.

`diff` were not matched by `patches/*.patch`, this seems to have gone
unnoticed in a refactor.
2021-01-28 22:20:03 +01:00
Luke
449c6c5604 LibWeb: Add simple implementation of Document.createElementNS 2021-01-28 22:18:46 +01:00
Tom
affb4ef01b Kernel: Allow specifying a physical alignment when allocating
Some drivers may require allocating contiguous physical pages with
a specific alignment for the physical address.
2021-01-28 18:52:59 +01:00
Tom
d5472426ec Kernel: Retire SchedulerData and add Thread lookup table
This allows us to get rid of the thread lists in SchedulerData.
Also, instead of iterating over all threads to find a thread by id,
just use a lookup table. In the rare case of having to iterate over
all threads, just iterate the lookup table.
2021-01-28 17:35:41 +01:00
AnotherTest
e55d227f93 AK: Provide traits for DistinctNumeric<T> 2021-01-28 17:35:41 +01:00
Andreas Kling
80837d43a2 Kernel: Remove outdated debug logging from RangeAllocator
If someone wants to debug this code, it's better that they rewrite the
logging code to take randomization and guard pages into account.
2021-01-28 16:23:38 +01:00
Andreas Kling
322c161ee4 LibELF: Implement ASLR for shared libraries :^)
Use mmap() with the new MAP_RANDOMIZED flag to load shared libraries at
random addresses in each process.

To avoid address space collisions, we start by doing a large chunk mmap
that covers enough VM for both text and data, then we unmap and remap
the data segment separately, once we know everything will fit.

This is pretty cool! :^)
2021-01-28 16:23:38 +01:00
Andreas Kling
b6937e2560 Kernel+LibC: Add MAP_RANDOMIZED flag for sys$mmap()
This can be used to request random VM placement instead of the highly
predictable regular mmap(nullptr, ...) VM allocation strategy.

It will soon be used to implement ASLR in the dynamic loader. :^)
2021-01-28 16:23:38 +01:00
Andreas Kling
d3de138d64 Kernel: Add sanity check assertion in RangeAllocator::allocate_specific
The specific virtual address should always be page aligned.
2021-01-28 16:23:38 +01:00
Andreas Kling
27d07796b4 Kernel: Add sanity check assertion in RangeAllocator::allocate_anywhere
The requested alignment should always be a multiple of the page size.
2021-01-28 16:23:38 +01:00
Linus Groh
509e5a3045 LibJS: Fix crash when printing error for missing class extends value prototype
If it's missing we get an empty value, but we can't use that with
to_string_without_side_effects() so we have to use undefined as the
default.

Fixes #5142.
2021-01-28 10:24:18 +01:00
Andreas Kling
803a20fa86 LibJS: Call the correct base class in LexicalEnvironment::visit_edges()
We were calling directly up to Cell, skipping over ScopeObject.
This made us not mark the scope chain parent for lexical environments,
sometimes causing them to get GC'd and use-after-free'd.

Found by Fuzzilli.

Fixes #5140.
2021-01-28 10:15:24 +01:00
Andreas Kling
7ec8f83a7f Lagom+AK: Remove remains of clang -Wconsumed usage
We stopped using that warning ages ago since it confused the compiler.
2021-01-28 09:14:49 +01:00
Andreas Kling
a0bcfa30bf LibWeb: Add simple implementation of Node.removeChild() 2021-01-28 08:58:22 +01:00
Andreas Kling
5a58f42e3c LibWeb: Remove accidentally committed changes from b72f067f0d 2021-01-28 08:57:12 +01:00