Kernel: Fix stack pointer OOB check
i686 does not push the stack pointer on interrupt when no CPL change happens.
This commit is contained in:
parent
1ee37cb671
commit
9f90eeab05
|
@ -173,15 +173,17 @@ namespace Kernel
|
||||||
|
|
||||||
if (tid)
|
if (tid)
|
||||||
{
|
{
|
||||||
|
auto& thread = Thread::current();
|
||||||
#if __enable_sse
|
#if __enable_sse
|
||||||
Thread::current().save_sse();
|
thread.save_sse();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (isr == ISR::PageFault)
|
if (isr == ISR::PageFault && Thread::current().is_userspace())
|
||||||
{
|
{
|
||||||
// Check if stack is OOB
|
// Check if stack is OOB
|
||||||
auto& thread = Thread::current();
|
if (ARCH(i686) && !GDT::is_user_segment(interrupt_stack->cs))
|
||||||
if (thread.userspace_stack_bottom() < interrupt_stack->sp && interrupt_stack->sp <= thread.userspace_stack_top())
|
; // 32 bit does not push stack pointer when no CPL change happens
|
||||||
|
else if (thread.userspace_stack_bottom() < interrupt_stack->sp && interrupt_stack->sp <= thread.userspace_stack_top())
|
||||||
; // using userspace stack
|
; // using userspace stack
|
||||||
else if (thread.kernel_stack_bottom() < interrupt_stack->sp && interrupt_stack->sp <= thread.kernel_stack_top())
|
else if (thread.kernel_stack_bottom() < interrupt_stack->sp && interrupt_stack->sp <= thread.kernel_stack_top())
|
||||||
; // using kernel stack
|
; // using kernel stack
|
||||||
|
@ -198,13 +200,10 @@ namespace Kernel
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Demand paging is only supported in userspace
|
|
||||||
if (thread.is_userspace())
|
|
||||||
{
|
|
||||||
// Try demand paging on non present pages
|
// Try demand paging on non present pages
|
||||||
PageFaultError page_fault_error;
|
PageFaultError page_fault_error;
|
||||||
page_fault_error.raw = error;
|
page_fault_error.raw = error;
|
||||||
if (!page_fault_error.present)
|
if (pid && !page_fault_error.present)
|
||||||
{
|
{
|
||||||
Processor::set_interrupt_state(InterruptState::Enabled);
|
Processor::set_interrupt_state(InterruptState::Enabled);
|
||||||
auto result = Process::current().allocate_page_for_demand_paging(regs->cr2);
|
auto result = Process::current().allocate_page_for_demand_paging(regs->cr2);
|
||||||
|
@ -222,7 +221,6 @@ namespace Kernel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Debug::s_debug_lock.lock();
|
Debug::s_debug_lock.lock();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue