update main #1

Merged
Sinipelto merged 240 commits from Bananymous/banan-os:main into main 2023-11-20 13:20:51 +02:00
2 changed files with 15 additions and 8 deletions
Showing only changes of commit 5d34cebeca - Show all commits

View File

@ -181,14 +181,20 @@ namespace Kernel::IDT
{
// Check if stack is OOB
auto& stack = Thread::current().stack();
if (interrupt_stack.rsp < stack.vaddr())
auto& istack = Thread::current().interrupt_stack();
if (stack.vaddr() < interrupt_stack.rsp && interrupt_stack.rsp <= stack.vaddr() + stack.size())
; // using normal stack
else if (istack.vaddr() < interrupt_stack.rsp && interrupt_stack.rsp <= istack.vaddr() + istack.size())
; // using interrupt stack
else
{
derrorln("Stack overflow");
goto done;
}
if (interrupt_stack.rsp >= stack.vaddr() + stack.size())
{
derrorln("Stack underflow");
derrorln("Stack pointer out of bounds!");
derrorln("rsp {H}, stack {H}->{H}, istack {H}->{H}",
interrupt_stack.rsp,
stack.vaddr(), stack.vaddr() + stack.size(),
istack.vaddr(), istack.vaddr() + istack.size()
);
Thread::current().handle_signal(SIGKILL);
goto done;
}
@ -207,7 +213,7 @@ namespace Kernel::IDT
if (result.is_error())
{
dwarnln("Demand paging: {}", result.error());
Thread::current().handle_signal(SIGTERM);
Thread::current().handle_signal(SIGKILL);
goto done;
}
}

View File

@ -71,6 +71,7 @@ namespace Kernel
vaddr_t stack_base() const { return m_stack->vaddr(); }
size_t stack_size() const { return m_stack->size(); }
VirtualRange& stack() { return *m_stack; }
VirtualRange& interrupt_stack() { return *m_interrupt_stack; }
vaddr_t interrupt_stack_base() const { return m_interrupt_stack ? m_interrupt_stack->vaddr() : 0; }
size_t interrupt_stack_size() const { return m_interrupt_stack ? m_interrupt_stack->size() : 0; }