Commit graph

31838 commits

Author SHA1 Message Date
Brian Gianforcaro
737a11389c Kernel: Fix info leak from sockaddr_un in socket syscalls
In `sys$accept4()` and `get_sock_or_peer_name()` we were not
initializing the padding of the `sockaddr_un` struct, leading to
an kernel information leak if the
caller looked back at it's contents.

Before Fix:

    37.766 Clipboard(11:11): accept4 Bytes:
    2f746d702f706f7274616c2f636c6970626f61726440eac130e7fbc1e8abbfc
    19c10ffc18440eac15485bcc130e7fbc1549feaca6c9deaca549feaca1bb0bc
    03efdf62c0e056eac1b402d7acd010ffc14602000001b0bc030100000050bf0
    5c24602000001e7fbc1b402d7ac6bdc

After Fix:

    0.603 Clipboard(11:11): accept4 Bytes:
    2f746d702f706f7274616c2f636c6970626f617264000000000000000000000
    000000000000000000000000000000000000000000000000000000000000000
    000000000000000000000000000000000000000000000000000000000000000
    0000000000000000000000000000000
2021-12-29 03:41:32 -08:00
Brian Gianforcaro
98990dce53 Kernel: Fix info leak from padding in GenericFramebufferDevice::ioctl
In FB_IOCTL_GET_PROPERTIES we were not initializing the padding of the
struct, leading to the potential of an kernel information leak if the
caller looked back at it's contents.

Lets just be extra paranoid and zero initialize all these structs
in we store on the stack while handling ioctls(..).
2021-12-29 03:41:32 -08:00
Brian Gianforcaro
e308536005 Ports/gdb: Add basic ptrace based native target for SerenityOS/i386
This patch adds a ptrace based gdb backend, which is then enlightended
to known how to read the serenity i386 registers via ptrace.

This is just a basic implementation to get the port bootstrapped.
2021-12-29 03:17:41 -08:00
Brian Gianforcaro
6137b9f272 Ports/gdb: Fix compiler -fpermissive warnings from using latest GCC
These are compilation errors coming form upstream gdb.
2021-12-29 03:17:41 -08:00
Brian Gianforcaro
1210ee9ba9 LibC: Make regs.h work with compilers without concepts
This allows the gdb port to compile with our `regs.h`.
2021-12-29 03:17:41 -08:00
Daniel Bertalan
9f2e8683de Ports/gdb: Use mmap instead of malloc for sigaltstack()
Stack regions can't be made volatile, which makes it impossible for
malloc to manage memory that's used for `sigaltstack()`. Let's use mmap
instead.

Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-12-29 03:17:41 -08:00
Brian Gianforcaro
bd3bbd0329 Ports: Add initial GDB 11.1 port
This builds and runs, but crashes when you attempt to try to debug
something at the moment.
2021-12-29 03:17:41 -08:00
Daniel Bertalan
fcdd202741 Kernel: Return the actual number of CPU cores that we have
... instead of returning the maximum number of Processor objects that we
can allocate.

Some ports (e.g. gdb) rely on this information to determine the number
of worker threads to spawn. When gdb spawned 64 threads, the kernel
could not cope with generating backtraces for it, which prevented us
from debugging it properly.

This commit also removes the confusingly named
`Processor::processor_count` function so that this mistake can't happen
again.
2021-12-29 03:17:41 -08:00
Brian Gianforcaro
7828d4254e LibC: Stub out tcsendbreak(..) and tcdrain(..)
They are required for gdb to build.
2021-12-29 03:17:41 -08:00
Idan Horowitz
6e2a82df13 Kernel: Port File to RefCounted
Since RefCounted automatically calls a method named `will_be_destoyed`
on classes that have one, so there's no need to have a custom
implementation of unref in File.
2021-12-29 12:04:15 +01:00
Idan Horowitz
4a3a947df3 Kernel: Rename File::{before_removing => will_be_destroyed}
This will allow File and it's descendants to use RefCounted instead of
having a custom implementation of unref. (Since RefCounted calls
will_be_destroyed automatically)

This commit also removes an erroneous call to `before_removing` in
AHCIPort, this is a duplicate call, as the only reference to the device
is immediately dropped following the call, which in turns calls
`before_removing` via File::unref.
2021-12-29 12:04:15 +01:00
Idan Horowitz
d7ec5d042f Kernel: Port Process to ListedRefCounted 2021-12-29 12:04:15 +01:00
Idan Horowitz
3d0b5efcfc Kernel: Remove Process::all_processes()
This was only used in ProcFS, which can use the `processes()` list just
as well, so let's remove it.
2021-12-29 12:04:15 +01:00
Idan Horowitz
81e23617d6 Kernel: Port Custody to ListedRefCounted
Custody's unref is one of many implementions of ListedRefCounted's
behaviour in the Kernel, which results in avoidable bugs caused by
the fragmentation of the implementations. This commit starts the work
of replacing all custom implementations with ListedRefCounted by
porting Custody to it.
2021-12-29 12:04:15 +01:00
Idan Horowitz
be91b4fe3e Kernel: Support Mutex Protected lists in ListedRefCounted
This will allow us to support Mutex Protected lists like the custodies
list as well.
2021-12-29 12:04:15 +01:00
Linus Groh
7204b292c5 LibJS: Implement and use the MakeMethod AO
Two direct uses of the set_home_object() setter remain, we should fix
those up and remove it eventually.
2021-12-29 10:34:34 +01:00
Linus Groh
df931e6a83 LibJS: Implement and use the InitializeBoundName AO 2021-12-29 10:34:28 +01:00
Linus Groh
ca48151147 LibJS: Add spec comments to VM::binding_initialization() 2021-12-29 10:34:23 +01:00
Linus Groh
3626a7fd6d LibJS: Remove unused FunctionEnvironment this value getter/setter
The this value is only supposed to be set via the BindThisValue and
accessed via the GetThisBinding AOs, so exposing a direct getter/setter
would only lead to potentially non-spec-compliant behavior down the
line.
2021-12-29 00:16:51 +01:00
Linus Groh
451149df0b LibJS: Ensure get_new_target() never returns an empty value
Also add spec comments and remove a redundant exception check while
we're here :^)
2021-12-29 00:16:51 +01:00
Linus Groh
8d70a50aed LibJS: Remove unused MemberExpression::computed_property_name() 2021-12-29 00:16:51 +01:00
Peter Elliott
23e09eb7f4 less: Handle tabs in line wrapping
Before tabs were treated as a width of 1, which would cause issues with
man page headers.
2021-12-29 00:00:02 +01:00
Peter Elliott
20a0572de8 Userland: Port less(1) to LibMain 2021-12-29 00:00:02 +01:00
Peter Elliott
6312742257 less: Remove all formatting before printing status line 2021-12-29 00:00:02 +01:00
Peter Elliott
3677e88fb1 less: Dynamically re-wrap lines on resize
This change moves from wrapping lines at the start to operating on whole
lines and wrapping them as needed.

This has a few added benefits:
- line numbers are now always accurate.
- going to a line actually works
2021-12-29 00:00:02 +01:00
TheGrizzlyDev
2905642550 Magnifier: Add colorblind preview options
Add the same preview options as the theme editor so you can test the
accessibility of anything on your desktop. Both tools share the same
shortcuts.
2021-12-28 23:59:56 +01:00
Lady Gegga
7f61d430e6 Base: Add Tifinagh characters to font Katica Regular 10
2D30-2D7F https://www.unicode.org/charts/PDF/U2D30.pdf
2021-12-28 23:40:35 +01:00
Kenneth Myhra
7772309169 LibCore+chown: Return ErrorOr<Optional<...>> for getgrnam and getpwnam
This patch returns an empty Optional<...> instead of an Error for
Core::System::getgrname and Core::System::getpwnam if we can't find a
matching group or user entry.

It also updates the 'chown' utility to support this new behavior.
2021-12-28 23:23:54 +01:00
Maciej
ab324c1dae ImageViewer: Change how scaling works
- Store scale as a (float) factor (not as %)
- Make scaling exponential so that matches PixelPaint and another
image viewers/editors/etc
2021-12-28 23:23:09 +01:00
Stephan Unverwerth
1c3a82d59e Profiler: Extract percentage gradient calculation into its own file 2021-12-28 23:17:24 +01:00
Stephan Unverwerth
ddccf451a9 Profiler: Make everything east-const :^) 2021-12-28 23:17:24 +01:00
Stephan Unverwerth
cf8427b7b4 Profiler: Add source code view
This adds a new view mode to profiler which displays source lines and
samples that occured at those lines. This view can be opened via the
menu or by pressing CTRL-S.

It does this by mapping file names from DWARF to "/usr/src/serenity/..."
i.e. source code should be copied to /usr/src/serenity/Userland and
/usr/src/serenity/Kernel to be visible in this mode.

Currently *all* files contributing to the selected function are loaded
completely which could be a lot of data when dealing with lots of
inlined code.
2021-12-28 23:17:24 +01:00
Owen Smith
e6df1c9988 Kernel: Implement and use the syscall/sysret instruction pair on x86_64 2021-12-28 23:15:38 +01:00
Owen Smith
d36c84c331 Kernel: Reorder the 64-bit GDT a bit
Add a kernel data segment and make the user code segment come after
the data segment. We need the GDT to be in a certain order to support
the syscall and sysret instruction pair.
2021-12-28 23:15:38 +01:00
Guilherme Goncalves
33b78915d3 Kernel: Propagate overflow errors from Memory::page_round_up
Fixes #11402.
2021-12-28 23:08:50 +01:00
Idan Horowitz
11599a3342 pls: Stop on first non option when parsing arguments
This allows using pls on a program with arguments more ergonomically,
e.g. `pls -- echo "hello friends"` can now simply be done as:
`pls echo "hello friends"`.
2021-12-28 22:03:33 +02:00
Andreas Kling
987b5adf2a Kernel: Remove old comment about kmalloc() being Q&D :^)
We've finally gotten kmalloc to a point where it feels decent enough
to drop this comment.

There's still a lot of room for improvement, and we'll continue working
on it.
2021-12-28 21:02:38 +01:00
Andreas Kling
9dffcc9752 Kernel: VERIFY that addresses passed to kfree_sized() look valid
Let's do some simple pointer arithmetic to verify that the address being
freed is at least within one of the two valid kmalloc VM ranges.
2021-12-28 21:02:38 +01:00
Andreas Kling
9111376d70 Kernel: Rename kmalloc_pool_heap => initial_kmalloc_memory 2021-12-28 21:02:38 +01:00
Andreas Kling
ac7ce12123 Kernel: Remove the kmalloc_eternal heap :^)
This was a premature optimization from the early days of SerenityOS.
The eternal heap was a simple bump pointer allocator over a static
byte array. My original idea was to avoid heap fragmentation and improve
data locality, but both ideas were rooted in cargo culting, not data.

We would reserve 4 MiB at boot and only ended up using ~256 KiB, wasting
the rest.

This patch replaces all kmalloc_eternal() usage by regular kmalloc().
2021-12-28 21:02:38 +01:00
Andreas Kling
a1be135891 Kernel: Lock socket mutex across {get,set}sockopt() and SO_ERROR updates
Since a socket can be accessed by multiple threads concurrently, we need
to protect shared data behind the socket mutex.

There's very likely more places where we need to fix this, the purpose
of this patch is to fix a VERIFY() failure in getsockopt() seen on CI.
2021-12-28 18:52:38 +01:00
Daniel Bertalan
4e1898df99 UserspaceEmulator: Exclude special ranges from RangeAllocator
If we do not mark these ranges as reserved, RangeAllocator might later
give us addresses that overlap these, which then causes an assertion
failure in the SoftMMU.  This behavior led to recurring CI failures, and
sometimes made programs as simple as `/bin/true` fail.

Fixes "Crash 1" reported in #9104
2021-12-28 19:28:13 +02:00
ryanb-dev
979f300337 LibVT: Handle window resize after history overflow
Addresses an issue in which a window resize event after history
overflow would cause the Terminal to crash due to a failed assertion.

The problematic assertion was removed and the logic updated to
support inserting lines even when the start of the history is at an
offset (due to an overflow).

Resolves #10987
2021-12-28 20:28:58 +03:30
TheGrizzlyDev
ebaf211260 ThemeEditor: Implement a way to simulate color blindness in preview
Implement a mechanism that allows us to alter colors so that they
mimic those a colorblind person would see. From the color we can then
alter the colors for the whole preview so we can simulate everything
in the theme including icons/decorations.

This filter is also available as a Filter in LibGfx so it can be
reused in multiple other places.

The color simulation algorithm is based on this one
https://github.com/MaPePeR/jsColorblindSimulator publicly available.
2021-12-28 17:10:44 +01:00
Linus Groh
1c05d39abc LibJS: Also throw exception when returning throw completion from await
...for now - the reason being that the AST breaks 'completion bubbling'
and returns a plain Value, and code at the call site relies on the VM
having an exception set when converting the plain value back into a
completion.

Fixes #11301.
2021-12-28 14:48:32 +01:00
Andreas Kling
416b0374fb Kernel: Fix race condition in TmpFSInode::notify_watchers()
We were doing this dance in notify_watchers():

    set_metadata_dirty(true);
    set_metadata_dirty(false);

This was done in order to force out inode watcher events immediately.
Unfortunately, this was racy, as if SyncTask got scheduled at the wrong
moment, it would try to flush metadata for a clean inode. This then got
trapped by the VERIFY() statement in Inode::sync_all():

    VERIFY(inode.is_metadata_dirty());

This patch fixes the issue by replacing notify_watchers() with lazy
metadata notifications like all other filesystems.
2021-12-28 13:00:28 +01:00
Andreas Kling
b24dc84ad9 Meta: Add SSE3, SMAP and SMEP to our bochsrc
- SSE3 makes LibM's trunc() not SIGILL (due to FISTTP).
- SMAP and SMEP allow us to exercise more kernel security mechanisms.
2021-12-28 11:51:50 +01:00
Maciej
6cfa58c7f3 HackStudio: Highlight AF files as INI 2021-12-28 11:36:12 +01:00
Maciej
00d1dbb95b TextEditor: Highlight AF files as INI 2021-12-28 11:36:12 +01:00
Brian Gianforcaro
ec21edb602 Ports: Update stress-ng port to 0.13.09
This change updates the port to the latest version, as part of that work
I basically reported the application, as we have added a lot of LibC
functionality which we were missing before. I've also updated the port
to mark stressor's we don't support as nops, instead of trying to avoid
compiling them at all. This will make the port much easier to maintain
in the future.
2021-12-28 11:00:51 +01:00