mirror of
https://gitlab.os-k.eu/os-k-team/os-k.git
synced 2023-08-25 14:03:10 +02:00
Stack Overflow and Underflow detected !
This commit is contained in:
parent
a3716901ce
commit
3d21fff8d4
@ -299,12 +299,14 @@ static void EarlyExceptionHandler(ISRFrame_t *regs)
|
||||
KeHaltCPU();
|
||||
}
|
||||
|
||||
//
|
||||
// Double Fault handling and stack overflow detection
|
||||
//
|
||||
static void DoubleFaultHandler(ISRFrame_t *regs)
|
||||
{
|
||||
ulong StackGuardOne = (ulong)MmGetStackGuards(0);
|
||||
ulong StackGuardTwo = (ulong)MmGetStackGuards(1);
|
||||
|
||||
if (regs->rsp <= StackGuardTwo + 4*KB) {
|
||||
if (regs->rsp <= StackGuardTwo + 4*KB && (regs->rsp - 4*KB <= regs->cr2)) {
|
||||
bprintf(BStdOut,
|
||||
"\n\n%CPANIC\n[ISR 0x8] Irrecoverable Kernel Stack Overflow\n\n"
|
||||
" Double Fault Error code : %#x (%b)\n"
|
||||
@ -315,17 +317,6 @@ static void DoubleFaultHandler(ISRFrame_t *regs)
|
||||
regs->ErrorCode,
|
||||
StackGuardTwo
|
||||
);
|
||||
} else if (regs->rsp <= StackGuardOne) {
|
||||
bprintf(BStdOut,
|
||||
"\n\n%CPANIC\n[ISR 0x8] Irrecoverable Kernel Stack Underflow\n\n"
|
||||
" Double Fault Error code : %#x (%b)\n"
|
||||
" Stack Guard bypassed : %#x",
|
||||
|
||||
VGA_COLOR_LIGHT_RED,
|
||||
regs->ErrorCode,
|
||||
regs->ErrorCode,
|
||||
StackGuardOne
|
||||
);
|
||||
} else {
|
||||
bprintf(BStdOut,
|
||||
"\n\n%CPANIC\n[ISR 0x8] Irrecoverable Kernel Double Fault Abort\n\n"
|
||||
|
@ -178,6 +178,19 @@ void *MmTranslateKPageToAddr(void *rank)
|
||||
//
|
||||
static void PagingHandler(ISRFrame_t *regs)
|
||||
{
|
||||
ulong StackGuardOne = (ulong)MmGetStackGuards(0);
|
||||
if (regs->cr2 >= StackGuardOne && (regs->rsp + 4*KB >= regs->cr2)) {
|
||||
bprintf(BStdOut,
|
||||
"\n\n%CPANIC\n[ISR 0x8] Irrecoverable Kernel Stack Underflow\n\n"
|
||||
" Double Fault Error code : %#x (%b)\n"
|
||||
" Stack Guard bypassed : %#x",
|
||||
|
||||
VGA_COLOR_LIGHT_RED,
|
||||
regs->ErrorCode,
|
||||
regs->ErrorCode,
|
||||
StackGuardOne
|
||||
);
|
||||
} else {
|
||||
bprintf(BStdOut, "\n\n%CPANIC\n[ISR 0x%x] Irrecoverable Kernel Page Fault at %p\n\n"
|
||||
" Error code : 0x%x (%b)",
|
||||
|
||||
@ -187,6 +200,7 @@ static void PagingHandler(ISRFrame_t *regs)
|
||||
regs->ErrorCode,
|
||||
regs->ErrorCode
|
||||
);
|
||||
}
|
||||
|
||||
KeBrkDumpRegisters(regs);
|
||||
|
||||
|
@ -203,6 +203,17 @@ error_t CmdStackOverflow(int argc, char **argv, char *cmdline)
|
||||
return EOK;
|
||||
}
|
||||
|
||||
error_t CmdStackUnderflow(int argc, char **argv, char *cmdline)
|
||||
{
|
||||
KernLog("\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n"
|
||||
"\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n"
|
||||
"\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n"
|
||||
"\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n"
|
||||
"\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n"
|
||||
);
|
||||
return EOK;
|
||||
}
|
||||
|
||||
error_t CmdMemUsage(int argc, char **argv, char *cmdline);
|
||||
|
||||
error_t CmdVersion(int argc, char **argv, char *cmdline)
|
||||
@ -238,6 +249,7 @@ Command_t cmdtable[] =
|
||||
{ "quit", CmdQuit, "Alias for 'exit'" },
|
||||
{ "shell", CmdShell, "Start a new shell (nested)", },
|
||||
{ "stkov", CmdStackOverflow, "Provoke a stack overflow" },
|
||||
{ "stkun", CmdStackUnderflow, "Provoke a stack underflow" },
|
||||
{ "time", CmdTime, "Print time" },
|
||||
{ "ver", CmdVersion, "Version and legal infos" },
|
||||
{ NULL, NULL, NULL }
|
||||
|
Loading…
Reference in New Issue
Block a user