Commit graph

17046 commits

Author SHA1 Message Date
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
Linus Groh
13867600c3 LibWeb: Add constructor to XMLHttpRequest IDL interface 2021-02-17 23:45:07 +01:00
Linus Groh
8f8f7bfd0f LibWeb: Add constructor to Range IDL interface 2021-02-17 23:45:07 +01:00
Linus Groh
0ac07c7351 LibWeb: Add constructor to Event IDL interface 2021-02-17 23:45:07 +01:00
Linus Groh
0f1da7d40c LibWeb: Add constructor to Document IDL interface 2021-02-17 23:45:07 +01:00
Linus Groh
8c7d1986b8 LibWeb: Actually construct impl and wrapper in construct() :^)
FooConstructor::construct() is no longer a dummy but now generates
either code to throw an exception (for interfaces without constructor)
or code to construct the wrapper and its impl object.

Constructor overloads are not currenly handled, but that's not something
we need right now anyway. Instead of  regular create() this uses a new
static function create_with_global_object() and passes the WindowObject,
which may be needed - e.g. for XMLHttpRequest, which has an IDL and
JavaScript constructor with no arguments, but needs a DOM::Window in its
create().
2021-02-17 23:45:07 +01:00
Linus Groh
e3577f871b LibWeb: Parse IDL interface constructors
WrapperGenerator will now parse and store IDL interface constructors,
including parameters and overloads.
See https://heycam.github.io/webidl/#idl-constructors.
2021-02-17 23:45:07 +01:00
Linus Groh
ff324fe989 LibWeb: Fix .length of functions generated from IDL
Function::length() is computing the right function length based on its
parameters, but we never called it - instead the *function name length*
was being used, which is obviously wrong. How silly! :^)
2021-02-17 23:45:07 +01:00
Marcel Hernandez
b07799060f
Ports: Add tinyscheme 1.42 (#5387) 2021-02-17 23:07:34 +01:00
Nick Vella
bafb8b0be6 Run: Store and present recent Run command history in a ComboBox.
We now store the last 25 inputs ran in Run in a simple text file under
.config (~/.config/RunHistory.txt)
2021-02-17 23:06:19 +01:00
Nick Vella
05914d2e9a LibGUI: Correctly handle ComboBox list windows of less than three items (~50px) in height.
By default, a Window has a minimum size of 50x50 - ComboBox lists aren't
always this tall. We now set the minimum height of the ComboBox Window
according to the height of three items, or the total height of all the
items in the list, whichever is smaller.
This means there is no longer any unpainted space in the list window
due to the shortfall between the ListBox widget and Window heights,
and the ComboBox list window always remains a comfortable height for
viewing. :^)
2021-02-17 23:06:19 +01:00
jonno85uk
2d1cfa7d11
Ports: Add bison 1.25 (#5382)
bison -h works. Not tried with any grammar files
2021-02-17 22:54:37 +01:00
jonno85uk
6e1117a688
Ports: Add libtiff (#5383) 2021-02-17 22:54:04 +01:00
Linus Groh
fe266e03b6 PixelPaint: Open image file passed as argument
This is obviously a requirement for #5374, oops :^)

Also handle errors gracefully, opening a file that isn't PixelPaint JSON
would previously crash.

Closes #5388.
2021-02-17 19:39:37 +01:00
Andreas Kling
c4438d6fd4 WindowServer: Unbreak "pick new active window" algorithm
We lost the ability to pick a suitable new active window when I added
the support for tool windows.
2021-02-17 16:52:08 +01:00
Andreas Kling
6c2f0316d9 Kernel: Convert snprintf() => String::formatted()/number() 2021-02-17 16:37:11 +01:00