Bug fixes

This commit is contained in:
Alex 2023-04-25 05:14:12 +03:00
parent 299c919d1d
commit c1eaabf97b
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
4 changed files with 13 additions and 7 deletions

View File

@ -80,10 +80,10 @@ namespace ACPI
{ {
if (TaskManager) if (TaskManager)
{ {
Tasking::PCB *ParentProcess = TaskManager->GetCurrentProcess(); TaskManager->CreateThread(TaskManager->CreateProcess(nullptr,
if (!ParentProcess) "Shutdown",
ParentProcess = GetCPU(0)->CurrentProcess.load(); Tasking::TaskTrustLevel::Kernel),
TaskManager->CreateThread(ParentProcess, (Tasking::IP)KST_Shutdown); (Tasking::IP)KST_Shutdown);
} }
else else
KernelShutdownThread(false); KernelShutdownThread(false);

View File

@ -65,7 +65,7 @@ namespace Memory
this->Size = STACK_SIZE; this->Size = STACK_SIZE;
} }
trace("Allocated stack at %p", this->StackBottom); debug("Allocated stack at %p", this->StackBottom);
} }
StackGuard::~StackGuard() StackGuard::~StackGuard()

View File

@ -113,8 +113,7 @@ static int sys_detach_address(SyscallsFrame *Frame, uintptr_t Address)
static uintptr_t sys_kernelctl(SyscallsFrame *Frame, enum KCtl Command, uint64_t Arg1, uint64_t Arg2, uint64_t Arg3, uint64_t Arg4) static uintptr_t sys_kernelctl(SyscallsFrame *Frame, enum KCtl Command, uint64_t Arg1, uint64_t Arg2, uint64_t Arg3, uint64_t Arg4)
{ {
/* Only trusted threads can use kernelctl */ if (!CheckTrust(TrustedByKernel | Trusted | Untrusted))
if (!CheckTrust(TrustedByKernel | Trusted))
return SYSCALL_ACCESS_DENIED; return SYSCALL_ACCESS_DENIED;
switch (Command) switch (Command)
@ -129,6 +128,8 @@ static uintptr_t sys_kernelctl(SyscallsFrame *Frame, enum KCtl Command, uint64_t
return TaskManager->GetCurrentThread()->Security.IsCritical; return TaskManager->GetCurrentThread()->Security.IsCritical;
case KCTL_REGISTER_ELF_LIB: case KCTL_REGISTER_ELF_LIB:
{ {
if (!CheckTrust(TrustedByKernel | Trusted))
return SYSCALL_ACCESS_DENIED;
char *Identifier = (char *)Arg1; char *Identifier = (char *)Arg1;
const char *Path = (const char *)Arg2; const char *Path = (const char *)Arg2;
@ -180,6 +181,8 @@ static uintptr_t sys_kernelctl(SyscallsFrame *Frame, enum KCtl Command, uint64_t
} }
case KCTL_GET_ELF_LIB_FILE: case KCTL_GET_ELF_LIB_FILE:
{ {
if (!CheckTrust(TrustedByKernel | Trusted))
return SYSCALL_ACCESS_DENIED;
char *Identifier = (char *)Arg1; char *Identifier = (char *)Arg1;
if (!Identifier) if (!Identifier)
return 0; return 0;
@ -195,6 +198,8 @@ static uintptr_t sys_kernelctl(SyscallsFrame *Frame, enum KCtl Command, uint64_t
} }
case KCTL_GET_ELF_LIB_MEMORY_IMAGE: case KCTL_GET_ELF_LIB_MEMORY_IMAGE:
{ {
if (!CheckTrust(TrustedByKernel | Trusted))
return SYSCALL_ACCESS_DENIED;
char *Identifier = (char *)Arg1; char *Identifier = (char *)Arg1;
if (!Identifier) if (!Identifier)
return 0; return 0;

View File

@ -61,4 +61,5 @@ extern "C" uintptr_t SystemCallsHandler(SyscallsFrame *Frame)
} }
} }
assert(false); /* Should never reach here. */ assert(false); /* Should never reach here. */
return 0;
} }