From 58f4ed22c4fb820c97c1c6d5c58a5ee12fc4a7f5 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 28 Sep 2023 21:58:24 +0300 Subject: [PATCH] Kernel: Don't map interrupt stack as userspace accessable --- kernel/kernel/Thread.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/kernel/kernel/Thread.cpp b/kernel/kernel/Thread.cpp index e0437b5804..7ef49f916c 100644 --- a/kernel/kernel/Thread.cpp +++ b/kernel/kernel/Thread.cpp @@ -122,8 +122,21 @@ namespace Kernel thread->m_is_userspace = true; - thread->m_stack = TRY(VirtualRange::create_to_vaddr_range(process->page_table(), 0x300000, KERNEL_OFFSET, m_userspace_stack_size, PageTable::Flags::UserSupervisor | PageTable::Flags::ReadWrite | PageTable::Flags::Present, true)); - thread->m_interrupt_stack = TRY(VirtualRange::create_to_vaddr_range(process->page_table(), 0x300000, KERNEL_OFFSET, m_interrupt_stack_size, PageTable::Flags::UserSupervisor | PageTable::Flags::ReadWrite | PageTable::Flags::Present, true)); + thread->m_stack = TRY(VirtualRange::create_to_vaddr_range( + process->page_table(), + 0x300000, KERNEL_OFFSET, + m_userspace_stack_size, + PageTable::Flags::UserSupervisor | PageTable::Flags::ReadWrite | PageTable::Flags::Present, + true + )); + + thread->m_interrupt_stack = TRY(VirtualRange::create_to_vaddr_range( + process->page_table(), + 0x300000, KERNEL_OFFSET, + m_interrupt_stack_size, + PageTable::Flags::ReadWrite | PageTable::Flags::Present, + true + )); thread->setup_exec();