Commit Graph

17161 Commits

Author SHA1 Message Date
Andreas Kling
8fd86fe6c9 Base: Do a little copy-editing in Mitigations(7) 2021-02-20 11:37:55 +01:00
Luke
0304f7bbbe test-web: Create execution scope for new interpreter instead of the old one
It was accidentally creating a scope for the old interpreter
instead of the new one.

Fixes #5415
2021-02-20 10:48:34 +01:00
Andreas Kling
7e959d7430 Base: Fix a broken commit link in Mitigations(7) 2021-02-20 09:32:40 +01:00
Bui Quang Minh
ff67340d81 Userland: Support moving files between different mounted filesystems
In case we cannot use rename() because of cross-device error, copy file to the
destination then unlink the old source file.
2021-02-20 09:30:11 +01:00
Linus Groh
14058b6858 LibWeb: Use DOMException in XMLHttpRequest::send() 2021-02-20 09:14:19 +01:00
Linus Groh
70878290b9 LibWeb: Use DOMException in XMLHttpRequest::open() 2021-02-20 09:14:19 +01:00
Linus Groh
c4d8cce9a2 LibWeb: Use DOMException in XMLHttpRequest::set_request_header() 2021-02-20 09:14:19 +01:00
Linus Groh
4e1de09340 LibWeb: Use DOMException in HTMLElement::set_content_editable() 2021-02-20 09:14:19 +01:00
Linus Groh
dd621cc650 LibWeb: Use DOMException in Document::set_body() 2021-02-20 09:14:19 +01:00
Brian Gianforcaro
0d196d14d2 Base: Document more the mitigations in man7/Mitigations.md
Document:
* Unmap After Init
* RELRO
* -fstack-clash-protection
* -fstack-protector / -fstack-protector-strong
2021-02-20 09:01:02 +01:00
Linus Groh
8b78ed6308 Browser: Wrap DOMException values in regular JS::Error for console printing
Small hack to effortlessly make JS::MarkupGenerator output DOMExceptions
formatted like regular errors.
2021-02-20 00:09:11 +01:00
Linus Groh
e064194061 LibWeb: Return InvalidCharacterError from Element::set_attribute() for empty attr
This is the first user of the new DOMException, using ExceptionOr. :^)
2021-02-20 00:09:11 +01:00
Linus Groh
3da2b51d74 LibWeb: Generate code for throwing DOMExceptions based on ExceptionOr<T>
There's a little bit of template magic involved here to make it work,
but this seems alright. Very cool! :^)

Co-authored-by: AnotherTest <ali.mpfard@gmail.com>
2021-02-20 00:09:11 +01:00
Linus Groh
e708f1c3a2 LibWeb: Add DOM::ExceptionOr<T> container
Much like AK::Result this carries either a DOM::DOMException or regular
return value and will be used by DOM functions for exceptions that
should be thrown.
2021-02-20 00:09:11 +01:00
Linus Groh
ada71dc71b LibWeb: Add DOM::DOMException class and bindings 2021-02-20 00:09:11 +01:00
Andreas Kling
cc0f5917d3 Kernel: Slap a handful more things with UNMAP_AFTER_INIT 2021-02-20 00:00:19 +01:00
Andreas Kling
4f0be55770 LibGUI: Remove GUI::FilePicker::file_exists()
I have no idea why this existed but everyone should just use
Core::File::exists() instead. :^)
2021-02-19 23:46:54 +01:00
Andreas Kling
a8e0671344 LibGUI: Port GUI::FilePicker to GML and improve the layout
Also remove the image preview feature as it was rather ugly.
If we bring it back we should it should look good.
2021-02-19 23:03:47 +01:00
Andreas Kling
cda3c5df59 LibGUI: Register GUI::MultiView 2021-02-19 23:03:47 +01:00
Andreas Kling
2b2828ae52 Kernel: Slap UNMAP_AFTER_INIT on a bunch more functions
We're now able to unmap 100 KiB of kernel text after init. :^)
2021-02-19 21:42:18 +01:00
Sahan Fernando
e920c74cae WindowServer: Restore cursor when marking window as responsive 2021-02-19 20:30:25 +01:00
Andreas Kling
fdf03852c9 Kernel: Slap UNMAP_AFTER_INIT on a whole bunch of functions
There's no real system here, I just added it to various functions
that I don't believe we ever want to call after initialization
has finished.

With these changes, we're able to unmap 60 KiB of kernel text
after init. :^)
2021-02-19 20:23:05 +01:00
Andreas Kling
32e93c8808 Kernel: Mark write_cr0() and write_cr4() as UNMAP_AFTER_INIT
This removes a very useful tool for attackers trying to disable
SMAP/SMEP/etc. :^)
2021-02-19 20:23:05 +01:00
Andreas Kling
6136faa4eb Kernel: Add .unmap_after_init section for code we don't need after init
You can now declare functions with UNMAP_AFTER_INIT and they'll get
segregated into a separate kernel section that gets completely
unmapped at the end of initialization.

This can be used for anything we don't need to call once we've booted
into userspace.

There are two nice things about this mechanism:

- It allows us to free up entire pages of memory for other use.
  (Note that this patch does not actually make use of the freed
  pages yet, but in the future we totally could!)

- It allows us to get rid of obviously dangerous gadgets like
  write-to-CR0 and write-to-CR4 which are very useful for an attacker
  trying to disable SMAP/SMEP/etc.

I've also made sure to include a helpful panic message in case you
hit a kernel crash because of this protection. :^)
2021-02-19 20:23:05 +01:00
Andreas Kling
da100f12a6 Kernel: Add helpers for manipulating x86 control registers
Use read_cr{0,2,3,4} and write_cr{0,3,4} helpers instead of inline asm.
2021-02-19 20:23:05 +01:00
Linus Groh
8d0b744ebb CrashReporter: Fix showing assertion info in backtrace
This was needlessly expecting the first backtrace entry function name to
start with '__assertion_failed', which is no longer the case - it's now
something from libsystem.so. Let's just check whether we have an
'assertion' key in the coredump's metadata, just like we do for pledge
violations.
2021-02-19 18:53:00 +01:00
Itamar
7df61e2c9b Toolchain: Use -ftls-model=initial-exec by default
Our TLS implementation relies on the TLS model being "initial-exec".
We previously enforced this by adding the '-ftls-model=initial-exec'
flag in the root CmakeLists file, but that did not affect ports - So
now we put that flag in the gcc spec files.

Closes #5366
2021-02-19 15:21:24 +01:00
belginul
4f80bb6ce3 DisplaySettings: Show revert dialog only for resolution/dpi changes. 2021-02-19 12:19:03 +01:00
jonno85uk
a4d4571522 Ports: Add libjpeg 9d 2021-02-19 12:18:46 +01:00
Andreas Kling
6e83be67b8 Kernel: Release ptrace lock in exec before stopping due to PT_TRACE_ME
If we have a tracer process waiting for us to exec, we need to release
the ptrace lock before stopping ourselves, since otherwise the tracer
will block forever on the lock.

Fixes #5409.
2021-02-19 12:13:54 +01:00
Andreas Kling
37d8faf1b4 ProcFS: Fix /proc/PID/* hardening bypass
This enabled trivial ASLR bypass for non-dumpable programs by simply
opening /proc/PID/vm before exec'ing.

We now hold the target process's ptrace lock across the refresh/write
operations, and deny access if the process is non-dumpable. The lock
is necessary to prevent a TOCTOU race on Process::is_dumpable() while
the target is exec'ing.

Fixes #5270.
2021-02-19 09:46:36 +01:00
Andreas Kling
7142562310 Everywhere: Build with -fstack-clash-protection
This option causes GCC to generate code to prevent "stack clash" style
attacks where a very large stack allocation is used in to jump over the
stack guard page and into whatever's next to it.
2021-02-19 09:12:30 +01:00
Andreas Kling
1e6d04c746 LibC: Remove text relocation
Tweak the PLT trampoline to avoid generating textrels in LibC.
This allows us to share all the LibC mappings, reducing per-process
memory consumption by ~200 KB. :^)

Patch originally by @nico.
2021-02-19 09:04:05 +01:00
Andreas Kling
713b3b36be DynamicLoader+Userland: Enable RELRO for shared libraries as well :^)
To support this, I had to reorganize the "load_elf" function into two
passes. First we map all the dynamic objects, to get their symbols
into the global lookup table. Then we link all the dynamic objects.

So many read-only GOT's! :^)
2021-02-19 00:03:03 +01:00
Andreas Kling
fa4c249425 LibELF+Userland: Enable RELRO for all userland executables :^)
The dynamic loader will now mark RELRO segments read-only after
performing relocations. This is pretty cool!

Note that this only applies to main executables so far,.
RELRO support for shared libraries will require some reorganizing
of the dynamic loader.
2021-02-18 18:55:19 +01:00
Andreas Kling
0d3866e84c DynamicLoader: Some ELF data segments were allocated too small
For a data segment that starts at a non-zero offset into a 4KB page and
crosses a 4KB page boundary, we were failing to pad the VM allocation,
which would cause the memcpy() to fail.

Make sure we round the segment bases down, and segment ends up, and the
issue goes away.
2021-02-18 18:14:59 +01:00
Andreas Kling
eb92ec3149 Kernel: Factor out mmap & friends range expansion to a helper function
sys$mmap() and related syscalls must pad to the nearest page boundary
below the base address *and* above the end address of the specified
range. Since we have to do this in many places, let's make a helper.
2021-02-18 18:04:58 +01:00
Brendan Coles
44aeab43a0 Chess: Allow right click to cancel drag move while dragging a piece 2021-02-18 12:52:11 +01:00
Andreas Kling
c2c7c7368b Website: Add @cees-elzinga's ptrace race + ASLR bypass to bounty page 2021-02-18 12:51:13 +01:00
Brendan Coles
a11c065e82 Chess: pledge thread
`thread` is required by the file browse dialog
when importing or exporting PGN files.
2021-02-18 10:23:08 +01:00
Andreas Kling
55a9a4f57a Kernel: Use KResult a bit more in sys$execve() 2021-02-18 09:37:33 +01:00
Linus Groh
edec5e29a3 LibC: Remove serenity.h.rej 2021-02-18 09:23:11 +01:00
Brendan Coles
0f084e0531 LibChess: SetOptionCommand: Set provided option name and value 2021-02-18 08:00:02 +01:00
Tom
06ee8c5aa8 WindowServer: Ignore other button presses while moving/resizing windows
Fixes #5334
2021-02-18 07:45:44 +01:00
Tom
6af4d35e8e WindowServer: Apply the backing bitmap's scale when alpha hit-testing
Fixes #5390
2021-02-18 07:45:22 +01:00
Linus Groh
b55c9f6bba Conway: Set minumum window size to game columns x rows
The game renders no cells when the game widget height is < rows or width
is < columns, so let's set a minimum window size here.
2021-02-18 07:34:47 +01:00
Breno Silva
cfb0f3309d LibJS: Implement tests for Array.prototype.flat 2021-02-18 00:22:45 +01:00
Kesse Jones
3940635ed3 LibJS: Implement Array.prototype.flat 2021-02-18 00:22:45 +01:00
jonno85uk
83d880180e
LibC: Use "static inline" for inline functions in arpa/inet.h (#5392)
This makes it work when compiling as C.
2021-02-18 00:02:47 +01:00
Andreas Kling
8aec1cd232 LibTTF: ScaledFont should have a NonnullRefPtr<TTF::Font>
A ScaledFont without an underlying TTF::Font would not be valid.
2021-02-17 23:45:21 +01:00