Commit Graph

16513 Commits

Author SHA1 Message Date
Andreas Kling
ce1c8e0bde LibWeb: Anonymous table cells should have colspan=1
Otherwise the column widths calculation algorithm will assert.

Fixes #5078.
2021-02-06 23:27:03 +01:00
Andreas Kling
89483a9408 UserspaceEmulator: Implement a proper VM allocator
This patch brings Kernel::RangeAllocator to UserspaceEmulator in a
slightly simplified form.

It supports the basic three allocation types needed by virt$mmap():
allocate_anywhere, allocate_specific, and allocate_randomized.

Porting virt$mmap() and virt$munmap() to use the allocator makes
UE work correctly once again. :^)
2021-02-06 23:15:44 +01:00
Andreas Kling
9dacd7c0ec UserspaceEmulator: Stub out virt$msyscall()
This is a no-op inside UE for now.
2021-02-06 23:15:44 +01:00
William Bowling
b97d23a71f
Kernel: Use the resolved parent path when testing create veil (#5231) 2021-02-06 19:11:44 +01:00
Sergey Bugaev
1dad63824b LookupServer: Unify DNSRequest & DNSResponse
They're really the same thing: a DNS packet can contain both questions and
answers, and there's a single bit in the header that determines whether the
packet represents a query or a response. It'll be simpler for us to represent
both types of packets using the same class.

This class can be both serialized and deserialized to/from a raw DNS packet.
2021-02-06 17:52:47 +01:00
Sergey Bugaev
e3135e7ca5 LookupServer: Rename DNSPacket -> DNSPacketHeader
This is a more appropriate name for what the class represents, and we'll be
reusing the name DNSPacket for something different soon.
2021-02-06 17:52:47 +01:00
Sergey Bugaev
d8967e4dff LookupServer+LibC: Pass IP addresses in binary
Now that we no longer depend on the textual IPC format, we can pass IP addresses
in the format most code actually has and needs it: in binary. The only places we
actually have to deal with textual address representation is:

* When reading /etc/hosts, we have to parse textual addresses & convert them to
  binary;
* When doing reverse lookups, we have to form a pseudo-hostname of the form
  x.x.x.x.in-addr.arpa.

So we do the conversion in those two cases.

This also increases uniformity between how we handle A (IPv4 address) and other
resource record types. Namely, we now store the raw binary data as received from
a DNS server.
2021-02-06 17:52:47 +01:00
Andreas Kling
04ff46bff4 Kernel: And some more KUBSAN checks :^)
Here comes a few more:

* enum
* object-size
* vptr
2021-02-06 17:39:49 +01:00
Andreas Kling
fad0332898 Kernel: Implement some more KUBSAN checks :^)
This patch enables the following -fsanitize sub-options:

* bounds
* bounds-strict
* integer-divide-by-zero
* return
* shift
* shift-base
* shift-exponent
2021-02-06 17:39:49 +01:00
Sergey Bugaev
547130584c LookupServer: Switch to LibIPC :^)
The ad-hoc IPC we were doing with LookupServer was kinda gross. With this,
LookupServer is a regular IPC server. In the future, we want to add more APIs
for LookupServer to talk to its clients (such as DHCPClient telling LookupServer
about the DNS server discovered via DHCP, and DNS-SD client browsing for
services), which calls for a more expressive IPC format; this is what LibIPC is
perfect for.

While the LookupServer side is using the regular LibIPC mechanics and patterns,
the LibC side has to hand-roll LibIPC format serialization without actually
using LibIPC. We might be able to get rid of this in the future, but for now it
has to be like that. The good news is the format is not that bad at all.
2021-02-06 16:12:18 +01:00
Sergey Bugaev
314f966745 LookupServer: Move into LookupServer namespace 2021-02-06 16:12:18 +01:00
Sahan Fernando
7e9122950e Profiler: Display timing information in ProfileTimelineWidget
Currently, there is no way to know when in a profile's duration a
sample was taken. This commit adds a basic timestamp to the timeline
widget, and a black bar to show where the cursor is hovering over.
2021-02-06 08:55:34 +01:00
jarhill0
ff3ae331f7 Documentation: Clarify macOS build instructions
I just ran through successfully building and running SerenityOS under
macOS. I ran into two main things that I struggled with, which were
- properly enabling osxfuse (through System Preferences)
- running the suggested command about compiler versions in such a way
  that would be compatible with Ninja (as it turns out, I just needed
  to add `-G Ninja` to the command)
This commit clarifies those things for anyone who may follow
2021-02-06 08:51:45 +01:00
Andreas Kling
930e3ce00d Kernel: Don't left-shift 1 (signed) 31 times
Found by KUBSAN :^)
2021-02-05 21:28:06 +01:00
Andreas Kling
4c0707e56c Kernel: Don't create a zero-length VLA in Ext2FS block list walk
Found by KUBSAN :^)
2021-02-05 21:23:11 +01:00
Andreas Kling
d164f89ada Kenrel: Implement two more KUBSAN checks
This patch adds the following UndefinedBehaviorSanitizer sub-options:

* signed-integer-overflow
* vla-bound
2021-02-05 21:23:11 +01:00
Andreas Kling
8e7ad28a33 AK: Avoid UB in TypedTransfer
Don't be calling __builtin_memfoo() with null pointer arguments.

Found by KUBSAN :^)
2021-02-05 21:23:11 +01:00
Andreas Kling
f4eb1f261f Kernel: Add missing initializer for SharedIRQHandler::m_enabled
Found by KUBSAN :^)
2021-02-05 21:23:11 +01:00
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