mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:07:34 +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:
parent
3551198f99
commit
1593219a41
4 changed files with 30 additions and 17 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue