Commit graph

16975 commits

Author SHA1 Message Date
Itamar
50f887c9d5 HackStudio: Display identifiers as clickable
This extends the "navigate to include" feature to also display
identifiers as clickable when they're hovered over while left control
is pressed.
2021-02-20 15:53:37 +01:00
Andreas Kling
adb6db9774 FileManager: Set tooltips on the path breadcrumb bar
Each segment of the breadcrumb bar now shows the path it represents.
2021-02-20 14:23:41 +01:00
Andreas Kling
85271a4dd8 LibGUI: Allow setting a tooltip on BreadcrumbBar segments 2021-02-20 14:23:21 +01:00
Andreas Kling
4853576db7 LibGUI: Ignore keydown events with Alt modifier in AbstractView
AbstractView doesn't actually do anything with them anyway, but they
would get swallowed by the cursor logic and not bubble up the widget
parent chain.
2021-02-20 13:27:21 +01:00
Andreas Kling
d9212bb2f4 LibGUI: Parent FilePicker toolbar buttons to the window
This makes the shortcuts actually work since unparented actions are
considered application-global, and we disable application-global
shortcuts while a modal dialog (like FilePicker) is up. This is pretty
counter-intuitive so I think there's room for API improvement here
but let's at least make Alt+Up work in FilePicker for now. :^)
2021-02-20 13:27:21 +01:00
Andreas Kling
716dc5bec9 LibGUI: Use delegating constructors in GUI::Action 2021-02-20 13:25:04 +01:00
Andreas Kling
1bc17d2870 LibGUI: Tidy up Action constructors and factory functions a bit 2021-02-20 13:25:04 +01:00
Linus Groh
a1a625b565 LibWeb: Move ExceptionOr bindings utils into own header 2021-02-20 13:10:55 +01:00
Linus Groh
5e07c27e25 LibWeb: Implement Window.prompt() 2021-02-20 12:19:46 +01:00
Linus Groh
f10967e364 LibGUI: Set InputBox initial value to text_value string 2021-02-20 12:19:46 +01:00
Linus Groh
3583b62ad3 LibGUI: Swap order of InputBox value and parent window args
This is now consistent with the other dialog classes.
2021-02-20 12:19:46 +01:00
Andreas Kling
3b9f110161 LibWeb+LibImageDecoderClient: Reuse ImageDecoder service process
The overhead from spawning a new ImageDecoder for every decoding job is
way too large and causing other problems as well (#5421)

Let's keep the same decoder open and reuse it as long as it's working.
2021-02-20 11:37:55 +01:00
Andreas Kling
8fb9d1fd1d LibImageDecoderClient: Gracefully recover from decoder crashes :^)
If the ImageDecoder service crashes while decoding an image for us,
we now recover gracefully and simply return null.

This shields the browser from bugs in our image decoders.
2021-02-20 11:37:55 +01:00
Andreas Kling
a446cea759 LibIPC: Add Connection::send_sync_but_allow_failure()
Instead of asserting that the peer responds successfully, this API
allows for the peer to die/crash/whatever happens on the other side
while handling a synchronous request.

This will be useful when using process separation to parse untrusted
data from the web.
2021-02-20 11:37:55 +01:00
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