Commit graph

16545 commits

Author SHA1 Message Date
Andreas Kling
d44be96893 Kernel: KUBSAN! (Kernel Undefined Behavior SANitizer) :^)
We now build the kernel with partial UBSAN support.
The following -fsanitize sub-options are enabled:

* nonnull-attribute
* bool

If the kernel detects UB at runtime, it will now print a debug message
with a stack trace. This is very cool! I'm leaving it on by default for
now, but we'll probably have to re-evaluate this as more options are
enabled and slowdown increases.
2021-02-05 21:23:11 +01:00
Andreas Kling
7df3b95126 LibJS: GlobalObject must mark builtin prototypes
Failing to mark them leads to use-after-free since the GlobalObject
cached prototypes are used for new NumberObject, StringObject, etc.

Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=30319
2021-02-05 14:53:16 +01:00
Andreas Kling
0269578d3e LibM: Implement nextafter() and nexttoward()
Patch from Anonymous.
2021-02-05 12:27:23 +01:00
Andreas Kling
e87eac9273 Userland: Add LibSystem and funnel all syscalls through it
This achieves two things:

- Programs can now intentionally perform arbitrary syscalls by calling
  syscall(). This allows us to work on things like syscall fuzzing.

- It restricts the ability of userspace to make syscalls to a single
  4KB page of code. In order to call the kernel directly, an attacker
  must now locate this page and call through it.
2021-02-05 12:23:39 +01:00
Andreas Kling
4df3a34bc2 LibELF: Only set up PLT trampoline for objects with a PLT 2021-02-05 12:10:45 +01:00
Andreas Kling
9d471ea923 LibM: Build and install the LibM test
This test seems to be full of wrong, but at least now we build it and
place it in /usr/Tests/LibM/ so that we can fix it.
2021-02-05 09:50:08 +01:00
Andreas Kling
16a0e7a66d LibJS: Improve correctness of rounding and bitwise operations
Patch from Anonymous
2021-02-05 09:38:45 +01:00
Andreas Kling
6622ad8895 LibM: Improve accuracy of rounding related functions
Patch from Anonymous.
2021-02-05 09:38:45 +01:00
Jean-Baptiste Boric
edd2362f39 Kernel: Add NE2000 network card driver
Remember, friends don't let friends use NE2000 network cards :^)
2021-02-05 09:35:02 +01:00
Liav A
865aade42b Kernel: Clear pending interrupts before enabling IRQs of IDE Channel
Calling detect_disks() can generate interrupts, so we must clear it to
allow proper function when booting with kernel argument smp=on.
2021-02-05 09:10:37 +01:00
Liav A
f2faf11d61 Kernel: Try to detect Sound Blaster 16 before creating an instance
We shouldn't create a SB16 instance without checking if the Sound
Blaster 16 card is actually installed in the system.
2021-02-05 08:54:02 +01:00
Andreas Kling
5bb35da784 bt: Hyperlink filenames in backtraces if available :^)
If we can find a matching filename in /usr/src/serenity, let's make the
filenames in backtraces clickable to open that file.
2021-02-05 00:56:00 +01:00
Andreas Kling
a883784376 bt: Show filenames and line numbers when available :^) 2021-02-05 00:25:05 +01:00
Andreas Kling
a4e087e685 SymbolServer: Resolve filenames and line numbers from debug info :^)
This makes symbolication take a little longer the first time we load a
shared library, but then the cache keeps it warm.
2021-02-05 00:23:58 +01:00
Andreas Kling
72f96941f2 SymbolServer: Cache failed ELF loads as well
Remember which paths we've already tried to load. This stops it from
whining about /boot/Kernel not being mappable.
2021-02-04 23:44:01 +01:00
Andreas Kling
acabc37c24 SymbolServer+LibSymbolClient: Just do one symbol per IPC message
I originally wanted to batch the symbolication requests but that just
makes the client logic significantly more complicated with no real
benefit other than architectural feelgood points.
2021-02-04 23:35:10 +01:00
Andreas Kling
5dd555fe2f SystemMonitor: Use SymbolServer to symbolicate thread stacks 2021-02-04 23:20:39 +01:00
Andreas Kling
b7d16e3496 LibSymbolClient+bt: Move bt logic to SymbolClient::symbolicate_thread()
Since this is useful in many places, let's have a common implementation
of walking the stack of a given thread via /proc and symbolicating each
of the frames.
2021-02-04 23:20:39 +01:00
Andreas Kling
a5d89ca5df SymbolServer+bt: Symbolicate kernel addresses if /boot/Kernel available
The /boot directory is only accessible to root by default, but anyone
wanting access to kernel symbols for development can get them by making
/boot/Kernel accessible to the "symbol" user.
2021-02-04 23:20:39 +01:00
Andreas Kling
3ff7b0ebfe bt: Add a little backtrace program that uses SymbolServer
Usage: bt <PID>

This program will print a symbolicated backtrace for the main thread of
the process with the given PID. It uses SymbolServer for the
symbolication.

There's a lot of room for improvement in this command, but it is pretty
neat already. :^)
2021-02-04 23:20:39 +01:00
Andreas Kling
5249aa2ba5 LibSymbolClient: Add helper library for interfacing with SymbolServer 2021-02-04 23:20:39 +01:00
Andreas Kling
aefd206038 SymbolServer: Add symbolication service for out-of-process ELF parsing
This patch adds SymbolServer, a service daemon that provides
symbolication of ELF binaries. It has a very simple IPC API at the
moment that only turns addresses into symbol names.

This can be used to implement symbolication without having to do
in-process ELF parsing yourself. :^)
2021-02-04 23:19:08 +01:00
Andreas Kling
54d28df97d Kernel: Make /proc/PID/stacks/TID a JSON array
The contents of these files are now raw JSON arrays. We no longer
symbolicate the addresses. That's up to userspace from now on.
2021-02-04 22:55:39 +01:00
asynts
6a00e338a8 Make it possible to overwrite debug macros locally.
Leaking macros across headers is a terrible thing, but I can't think of
a better way of achieving this.

  - We need some way of modifying debug macros from CMake to implement
    ENABLE_ALL_THE_DEBUG_MACROS.

  - We need some way of modifying debug macros in specific source files
    because otherwise we need to rebuild too many files.

This was done using the following script:

    sed -i -E 's/#cmakedefine01 ([A-Z0-9_]+)/#ifndef \1\n\0\n#endif\n/' AK/Debug.h.in
    sed -i -E 's/#cmakedefine01 ([A-Z0-9_]+)/#ifndef \1\n\0\n#endif\n/' Kernel/Debug.h.in
2021-02-04 18:26:22 +01:00
Andreas Kling
91db36064f LibJS: Fix obviously wrong \uXXXX serialization in JSONObject 2021-02-04 00:09:04 +01:00
Andreas Kling
349cf6ad67 LibELF: Randomize the VM reservation (so we don't break ASLR) 2021-02-04 00:04:26 +01:00
Andreas Kling
3a3270eb68 LibELF: Make a dummy VM reservation before mapping dynamic objects
Using the text segment for the VM reservation ran into trouble when
there was a discrepancy between the p_filesz and p_memsz.

Simplify this mechanism and avoid trouble by making the reservation
as a MAP_PRIVATE | MAP_NORESERVE throwaway mapping instead.

Fixes #5225.
2021-02-03 23:42:18 +01:00
Andreas Kling
c9cd5ff6bb LibELF: Remove dynamic loader syscall exception for libkeyboard.so
LibKeyboard no longer needs to make syscalls so remove the exception
we were making for it. :^)
2021-02-03 23:15:53 +01:00
Andreas Kling
d32ed28df4 LibC+LibKeyboard: Move getkeymap()+setkeymap() syscall wrappers to LibC 2021-02-03 23:15:13 +01:00
Andreas Kling
a59b1825ce LibWeb: Basic implementation of global event handlers :^)
Document and HTMLElement now inherit from HTML::GlobalEventHandlers
which allows them to support "onfoo" event handler attributes.

These are assignable both via IDL attributes and content attributes.

Event listeners constructed this way get a special "attribute" flag
on them so we know which one to replace if you reassign them.
This also allows them to coexist with EventTarget.addEventListener().

This is all a bit sloppy, but it works decently for a first cut.
The Window object should also inherit GlobalEventHandlers, but since
we don't generate it from IDL, I haven't taken that step here.

Also this would be a lot nicer if we supported IDL mixins.
2021-02-03 23:03:05 +01:00
Andreas Kling
b43db4cc50 LibWeb: Add enumerator macro for all the "global event handlers" 2021-02-03 23:03:05 +01:00
Andreas Kling
14a6ec6fc9 LibWeb: Add a whole bunch of onfooevent names to HTML::AttributeNames 2021-02-03 23:03:05 +01:00
Ben Wiederhake
d24e287f8c Base: Make /www read-write by default
Since it is owned by root anyway, there is no need for 'additional security' to prevent
modification of that directory. This makes it easier to quickly export files from
Serenity. Fixes #5152.
2021-02-03 21:23:15 +01:00
Andreas Kling
6503b4b3c1 Revert "Meta: Enable CodeQL static analysis for Serenity"
This reverts commit f0bf723424.

CodeQL never finds anything and regularly crashes, failing the build.
2021-02-03 18:42:02 +01:00
Andreas Kling
c10e0adaca Kernel: Move perf event backtrace capture out of Thread class
There's no need for this to be generic and support running from an
arbitrary thread context. Perf events are always generated from within
the thread being profiled, so take advantage of that to simplify the
code. Also use Vector capacity to avoid heap allocations.
2021-02-03 11:53:05 +01:00
Andreas Kling
9c77980965 Everywhere: Remove some bitrotted "#if 0" blocks 2021-02-03 11:17:47 +01:00
Andreas Kling
ac59903c89 Kernel: Don't try to symbolicate user addresses with ksyms
That's just not gonna work. :^)
2021-02-03 11:08:23 +01:00
Andreas Kling
e1236dac3e Kernel: Check for off_t overflow in FileDescription::read/write
We were checking for size_t (unsigned) overflow but the current offset
is actually stored as off_t (signed). Fix this, and also fail with
EOVERFLOW correctly.
2021-02-03 10:54:35 +01:00
Andreas Kling
9f05044c50 Kernel: Check for off_t overflow before reading/writing InodeFile
Let's double-check before calling the Inode. This way we don't have to
trust every Inode subclass to validate user-supplied inputs.
2021-02-03 10:51:37 +01:00
Andreas Kling
342b787d1c LibWeb: Move main thread JavaScript VM to its own file
Instead of being a weird little global function in DOM/Document.cpp,
you can now get the main thread JS VM via Bindings::main_thread_vm().
2021-02-03 10:45:39 +01:00
Zac
cc2f35badd TextEditor: Implement word wrapping
Add a new wrapping mode to the TextEditor that will wrap lines at the
spaces between words.

Replace the previous menubar checkbox 'Wrapping Mode' in HackStudio and
the TextEditor with an exclusive submenu which allows switching between
'No wrapping', 'Wrap anywhere' and 'Wrap at words'. 'Wrap anywhere' (the
new 'Wrap lines') is still the default mode.

Setting the wrapping mode in the constructors of the TextEditorWidget
and HackStudio has been removed, it is now set when constructing the
menubar actions.
2021-02-03 10:33:23 +01:00
Andreas Kling
db1c6cf9cf LibC+LibELF: Run clang-format 2021-02-03 10:21:04 +01:00
Andreas Kling
c94392a1cc Applications: Remove "Welcome" application
This was a cute application for its time, but it's far too jokey and
non-serious for how I'd like this project to treat itself.
2021-02-03 10:20:17 +01:00
Liav A
36f6351edc Kernel: Restore IDE PIO functionality
This change can be actually seen as two logical changes, the first
change is about to ensure we only read the ATA Status register only
once, because if we read it multiple times, we acknowledge interrupts
unintentionally. To solve this issue, we always use the alternate Status
register and only read the original status register in the IRQ handler.

The second change is how we handle interrupts - if we use DMA, we can
just complete the request and return from the IRQ handler. For PIO mode,
it's more complicated. For PIO write operation, after setting the ATA
registers, we send out the data to IO port, and wait for an interrupt.
For PIO read operation, we set the ATA registers, and wait for an
interrupt to fire, then we just read from the data IO port.
2021-02-03 10:18:16 +01:00
EvilHowl
a0c773da9e DisplaySettings: Show a confirmation message when applying changes
The changes will be reverted after 10 seconds of no user input.
2021-02-03 10:17:19 +01:00
Matteo Sozzi
2031baebce HackStudio: do not open empty directories as file
When _double clicking_ or _right click > Open_ in the tree view, the
selected directory, if empty, was open in the editor section as file.
2021-02-03 10:15:09 +01:00
Matteo Sozzi
a8dfba6348 HackStudio: tree_view on_activiation changes
When opening a file in the tree view with _double click_, the file name
was not the same as opening the same file with _right click > Open_.

This caused the opne_files_view to have the same file in it, but with
two different names.
2021-02-03 10:15:09 +01:00
AnotherTest
e3ec759f97 Shell: Make history range values larger than u32 a syntax error
Found by oss-fuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29792&sort=reported&q=serenity
2021-02-03 10:14:32 +01:00
Andreas Kling
d4dd4a82bb Kernel: Don't allow sys$msyscall() on non-mmap regions 2021-02-02 20:16:13 +01:00
Andreas Kling
603d36c599 LibELF: Make syscall region exceptions for UE and libkeyboard.so
These two are currently making some syscalls so we'll have to make
exceptions for them until we can clean them up.
2021-02-02 20:13:44 +01:00