mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:38:11 +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
|
@ -58,15 +58,15 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
static void create_signal_trampolines();
|
||||
static void create_signal_trampoline();
|
||||
|
||||
RecursiveSpinLock g_processes_lock;
|
||||
static Atomic<pid_t> next_pid;
|
||||
InlineLinkedList<Process>* g_processes;
|
||||
String* g_hostname;
|
||||
Lock* g_hostname_lock;
|
||||
VirtualAddress g_return_to_ring3_from_signal_trampoline;
|
||||
HashMap<String, OwnPtr<Module>>* g_modules;
|
||||
Region* g_signal_trampoline_region;
|
||||
|
||||
ProcessID Process::allocate_pid()
|
||||
{
|
||||
|
@ -88,7 +88,7 @@ void Process::initialize()
|
|||
g_hostname = new String("courage");
|
||||
g_hostname_lock = new Lock;
|
||||
|
||||
create_signal_trampolines();
|
||||
create_signal_trampoline();
|
||||
}
|
||||
|
||||
Vector<ProcessID> Process::all_pids()
|
||||
|
@ -285,25 +285,21 @@ void signal_trampoline_dummy()
|
|||
extern "C" void asm_signal_trampoline(void);
|
||||
extern "C" void asm_signal_trampoline_end(void);
|
||||
|
||||
void create_signal_trampolines()
|
||||
void create_signal_trampoline()
|
||||
{
|
||||
// NOTE: We leak this region.
|
||||
auto* trampoline_region = MM.allocate_user_accessible_kernel_region(PAGE_SIZE, "Signal trampolines", Region::Access::Read | Region::Access::Write | Region::Access::Execute, false).leak_ptr();
|
||||
trampoline_region->set_syscall_region(true);
|
||||
g_return_to_ring3_from_signal_trampoline = trampoline_region->vaddr();
|
||||
g_signal_trampoline_region = MM.allocate_kernel_region(PAGE_SIZE, "Signal trampolines", Region::Access::Read | Region::Access::Write, false).leak_ptr();
|
||||
g_signal_trampoline_region->set_syscall_region(true);
|
||||
|
||||
u8* trampoline = (u8*)asm_signal_trampoline;
|
||||
u8* trampoline_end = (u8*)asm_signal_trampoline_end;
|
||||
size_t trampoline_size = trampoline_end - trampoline;
|
||||
|
||||
{
|
||||
SmapDisabler disabler;
|
||||
u8* code_ptr = (u8*)trampoline_region->vaddr().as_ptr();
|
||||
memcpy(code_ptr, trampoline, trampoline_size);
|
||||
}
|
||||
u8* code_ptr = (u8*)g_signal_trampoline_region->vaddr().as_ptr();
|
||||
memcpy(code_ptr, trampoline, trampoline_size);
|
||||
|
||||
trampoline_region->set_writable(false);
|
||||
trampoline_region->remap();
|
||||
g_signal_trampoline_region->set_writable(false);
|
||||
g_signal_trampoline_region->remap();
|
||||
}
|
||||
|
||||
void Process::crash(int signal, u32 eip, bool out_of_memory)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue