Andreas Kling
9b9b05eabf
Kernel: Make sys$mmap() round requested VM size to page size multiple
...
This fixes an issue where File::mmap() overrides would fail because they
were expecting to be called with a size evenly divisible by PAGE_SIZE.
2022-04-05 22:26:37 +02:00
Andreas Kling
e3e1d79a7d
Kernel: Remove unused ShouldDeallocateVirtualRange parameters
...
Since there is no separate virtual range allocator anymore, this is
no longer used for anything.
2022-04-05 01:15:22 +02:00
Andreas Kling
63ddbaf68a
Kernel: Tweak broken dbgln_if() in sys$fork() after RegionTree changes
2022-04-04 11:05:49 +02:00
Andreas Kling
12b612ab14
Kernel: Mark sys$adjtime() as not needing the big lock
...
This syscall works on global kernel state and so doesn't need protection
from threads in the same process.
2022-04-04 00:42:18 +02:00
Andreas Kling
4306422f29
Kernel: Mark sys$clock_settime() as not needing the big log
...
This syscall ends up disabling interrupts while changing the time,
and the clock is a global resource anyway, so preventing threads in the
same process from running wouldn't solve anything.
2022-04-04 00:42:18 +02:00
Andreas Kling
55814f6e0e
Kernel: Mark sys$sched_{set,get}param() as not needing the big lock
...
Both of these syscalls take the scheduler lock while accessing the
thread priority, so there's no reliance on the process big lock.
2022-04-04 00:42:18 +02:00
Andreas Kling
9250ac0c24
Kernel: Randomize non-specific VM allocations done by sys$execve()
...
Stuff like TLS regions, main thread stacks, etc. All deserve to be
randomized unless the ELF requires specific placement. :^)
2022-04-04 00:42:18 +02:00
Andreas Kling
36d829b97c
Kernel: Mark sys$listen() as not needing the big lock
...
This syscall already performs the necessary locking and so doesn't
need to rely on the process big lock.
2022-04-03 22:22:22 +02:00
Andreas Kling
e103c5fe2d
Kernel: Don't hog file descriptor table lock in sys$bind()
...
We don't need to hold the lock across the entire syscall. Once we've
fetched the open file description we're interested in, we can let go.
2022-04-03 22:20:34 +02:00
Andreas Kling
85ceab1fec
Kernel: Don't hog file descriptor table lock in sys$listen()
...
We don't need to hold the lock across the entire syscall. Once we've
fetched the open file description we're interested in, we can let go.
2022-04-03 22:18:57 +02:00
Andreas Kling
bc4282c773
Kernel: Mark sys$sendfd() and sys$recvfd() as not needing the big lock
...
These syscalls already perform the necessary locking and don't rely on
the process big lock.
2022-04-03 22:06:03 +02:00
Andreas Kling
858b196c59
Kernel: Unbreak ASLR in the new RegionTree world
...
Functions that allocate and/or place a Region now take a parameter
that tells it whether to randomize unspecified addresses.
2022-04-03 21:51:58 +02:00
Andreas Kling
07f3d09c55
Kernel: Make VM allocation atomic for userspace regions
...
This patch move AddressSpace (the per-process memory manager) to using
the new atomic "place" APIs in RegionTree as well, just like we did for
MemoryManager in the previous commit.
This required updating quite a few places where VM allocation and
actually committing a Region object to the AddressSpace were separated
by other code.
All you have to do now is call into AddressSpace once and it'll take
care of everything for you.
2022-04-03 21:51:58 +02:00
Andreas Kling
ffe2e77eba
Kernel: Add Memory::RegionTree to share code between AddressSpace and MM
...
RegionTree holds an IntrusiveRedBlackTree of Region objects and vends a
set of APIs for allocating memory ranges.
It's used by AddressSpace at the moment, and will be used by MM soon.
2022-04-03 21:51:58 +02:00
Andreas Kling
02a95a196f
Kernel: Use AddressSpace region tree for range allocation
...
This patch stops using VirtualRangeAllocator in AddressSpace and instead
looks for holes in the region tree when allocating VM space.
There are many benefits:
- VirtualRangeAllocator is non-intrusive and would call kmalloc/kfree
when used. This new solution is allocation-free. This was a source
of unpleasant MM/kmalloc deadlocks.
- We consolidate authority on what the address space looks like in a
single place. Previously, we had both the range allocator *and* the
region tree both being used to determine if an address was valid.
Now there is only the region tree.
- Deallocation of VM when splitting regions is no longer complicated,
as we don't need to keep two separate trees in sync.
2022-04-03 21:51:58 +02:00
Andreas Kling
2617adac52
Kernel: Store AddressSpace memory regions in an IntrusiveRedBlackTree
...
This means we never need to allocate when inserting/removing regions
from the address space.
2022-04-03 21:51:58 +02:00
Tim Schumacher
4ba39c8d63
Kernel: Implement f_basetype
in statvfs
2022-04-03 19:15:14 +02:00
Idan Horowitz
086969277e
Everywhere: Run clang-format
2022-04-01 21:24:45 +01:00
Ali Mohammad Pur
d6ce3e63e2
Kernel: Disallow elevating pledge promises with no_error set
...
8233da3398
introduced a not-so-subtle bug
where an application with an existing pledge set containing `no_error`
could elevate its pledge set by pledging _anything_, this commit makes
sure that no new promise is accepted.
2022-03-29 12:11:56 +02:00
Ali Mohammad Pur
8233da3398
Kernel: Add a 'no_error' pledge promise
...
This makes pledge() ignore promises that would otherwise cause it to
fail with EPERM, which is very useful for allowing programs to run under
a "jail" so to speak, without having them termiate early due to a
failing pledge() call.
2022-03-26 21:34:56 +04:30
Liav A
b5ef900ccd
Kernel: Don't assume paths of TTYs and pseudo terminals anymore
...
The obsolete ttyname and ptsname syscalls are removed.
LibC doesn't rely on these anymore, and it helps simplifying the Kernel
in many places, so it's an overall an improvement.
In addition to that, /proc/PID/tty node is removed too as it is not
needed anymore by userspace to get the attached TTY of a process, as
/dev/tty (which is already a character device) represents that as well.
2022-03-22 20:26:05 +01:00
int16
256744ebdf
Kernel: Make mmap validation functions return ErrorOr<void>
2022-03-22 12:20:19 +01:00
int16
4b96d9c813
Kernel: Move mmap validation functions to Process
2022-03-22 12:20:19 +01:00
int16
479929b06c
Kernel: Check wxallowed mount flag when validating mmap call
2022-03-22 12:20:19 +01:00
Brian Gianforcaro
03342876b8
Revert "Kernel: Use an ArmedScopeGuard to revert changes after failed mmap"
...
This reverts commit 790d620b39
.
2022-03-12 21:45:57 -08:00
Andreas Kling
7b3642d08c
Kernel: Mark sys$lseek() as not needing the big lock
...
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-09 16:43:00 +01:00
Andreas Kling
09e644f0ba
Kernel: Mark sys$emuctl() as not needing the big lock
...
This syscall doesn't do anything at all, and definitely doesn't need the
big lock. :^)
2022-03-09 16:43:00 +01:00
Andreas Kling
b4fefedd1d
Kernel: Mark sys$chmod() as not needing the big lock
...
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-09 16:43:00 +01:00
Andreas Kling
aa381c4a67
Kernel: Mark sys$fchmod() as not needing the big lock
...
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-09 16:43:00 +01:00
Andreas Kling
d074aae422
Kernel: Mark sys$dup2() as not needing the big lock
...
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-09 16:43:00 +01:00
Andreas Kling
8aad9e7448
Kernel: Mark sys$ftruncate() as not needing the big lock
...
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-09 16:43:00 +01:00
Andreas Kling
69a6a4d927
Kernel: Mark sys$fstatvfs() as not needing the big lock
...
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-09 16:43:00 +01:00
Hendiadyoin1
790d620b39
Kernel: Use an ArmedScopeGuard to revert changes after failed mmap
2022-03-08 15:58:51 -08:00
Andreas Kling
6354a9a030
Kernel: Mark sys$fsync() as not needing the big lock
...
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling
ef45ff4703
Kernel: Mark sys$readlink() as not needing the big lock
...
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling
2688ee28ff
Kernel: Mark sys$stat() as not needing the big lock
...
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling
be7ec52ed0
Kernel: Mark sys$fstat() as not needing the big lock
...
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling
23822febd2
Kernel: Mark sys$fchdir() as not needing the big lock
...
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling
156ab0c47d
Kernel: Mark sys$chdir() as not needing the big lock
...
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling
7597bef771
Kernel: Mark sys$getcwd() as not needing the big lock
...
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling
f630d0f095
Kernel: Mark sys$realpath() as not needing the big lock
...
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling
580d89f093
Kernel: Put Process unveil state in a SpinlockProtected container
...
This makes path resolution safe to perform without holding the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling
24f02bd421
Kernel: Put Process's current directory in a SpinlockProtected
...
Also let's call it "current_directory" instead of "cwd" everywhere.
2022-03-08 00:19:49 +01:00
Andreas Kling
7543c34d07
Kernel: Mark sys$anon_create() as not needing the big lock
...
This syscall is already safe for no-big-lock since it doesn't access any
unprotected data.
2022-03-08 00:19:49 +01:00
Andreas Kling
baa6ff5649
Kernel: Wrap HIDManagement keymap data in SpinlockProtected
...
This serializes access to the current keymap data everywhere in the
kernel, allowing to mark sys$setkeymap() as not needing the big lock.
2022-03-07 16:35:23 +01:00
Ali Mohammad Pur
6608812e4b
Kernel: Over-align the FPUState on the stack in sigreturn
...
The stack is misaligned at this point for some reason, this is a hack
that makes the resulting object "correctly" aligned, thus avoiding a
KUBSAN error.
2022-03-04 20:07:05 +01:00
Ali Mohammad Pur
88d7bf7362
Kernel: Save and restore FPU state on signal dispatch on i386/x86_64
2022-03-04 20:07:05 +01:00
Ali Mohammad Pur
4bd01b7fe9
Kernel: Add support for SA_SIGINFO
...
We currently don't really populate most of the fields, but that can
wait :^)
2022-03-04 20:07:05 +01:00
Ali Mohammad Pur
585054d68b
Kernel: Comment the living daylights out of signal trampoline/sigreturn
...
Mere mortals like myself cannot understand more than two lines of
assembly without a million comments explaining what's happening, so do
that and make sure no one has to go on a wild stack state chase when
hacking on these.
2022-03-04 20:07:05 +01:00
Ali Mohammad Pur
848eaf2220
Kernel: Reject sigaction() with SA_SIGINFO
...
We can't handle this, so let sigaction() fail instead of PANIC()'ing
later when we try to dispatch a signal with SA_SIGINFO set.
2022-03-04 20:07:05 +01:00