1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:07:35 +00:00

Kernel: Map signal trampoline into each process's address space

The signal trampoline was previously in kernelspace memory, but with
a special exception to make it user-accessible.

This patch moves it into each process's regular address space so we
can stop supporting user-allowed memory above 0xc0000000.
This commit is contained in:
Andreas Kling 2021-02-14 00:53:53 +01:00
parent 3551198f99
commit 1593219a41
4 changed files with 30 additions and 17 deletions

View file

@ -47,6 +47,8 @@
namespace Kernel {
extern Region* g_signal_trampoline_region;
struct LoadResult {
OwnPtr<Space> space;
FlatPtr load_base { 0 };
@ -481,6 +483,12 @@ int Process::do_exec(NonnullRefPtr<FileDescription> main_program_description, Ve
return load_result_or_error.error();
}
auto signal_trampoline_range = load_result_or_error.value().space->allocate_range({}, PAGE_SIZE);
if (!signal_trampoline_range.has_value()) {
dbgln("do_exec: Failed to allocate VM for signal trampoline");
return -ENOMEM;
}
// We commit to the new executable at this point. There is no turning back!
// Prevent other processes from attaching to us with ptrace while we're doing this.
@ -510,6 +518,14 @@ int Process::do_exec(NonnullRefPtr<FileDescription> main_program_description, Ve
m_space = load_result.space.release_nonnull();
MemoryManager::enter_space(*m_space);
auto signal_trampoline_region = m_space->allocate_region_with_vmobject(signal_trampoline_range.value(), g_signal_trampoline_region->vmobject(), 0, "Signal trampoline", PROT_READ | PROT_EXEC, true);
if (signal_trampoline_region.is_error()) {
ASSERT_NOT_REACHED();
}
signal_trampoline_region.value()->set_syscall_region(true);
m_signal_trampoline = signal_trampoline_region.value()->vaddr();
m_executable = main_program_description->custody();
m_arguments = arguments;
m_environment = environment;