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)
{
Tasking::PCB *ParentProcess = TaskManager->GetCurrentProcess();
if (!ParentProcess)
ParentProcess = GetCPU(0)->CurrentProcess.load();
TaskManager->CreateThread(ParentProcess, (Tasking::IP)KST_Shutdown);
TaskManager->CreateThread(TaskManager->CreateProcess(nullptr,
"Shutdown",
Tasking::TaskTrustLevel::Kernel),
(Tasking::IP)KST_Shutdown);
}
else
KernelShutdownThread(false);

View File

@ -65,7 +65,7 @@ namespace Memory
this->Size = STACK_SIZE;
}
trace("Allocated stack at %p", this->StackBottom);
debug("Allocated stack at %p", this->StackBottom);
}
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)
{
/* Only trusted threads can use kernelctl */
if (!CheckTrust(TrustedByKernel | Trusted))
if (!CheckTrust(TrustedByKernel | Trusted | Untrusted))
return SYSCALL_ACCESS_DENIED;
switch (Command)
@ -129,6 +128,8 @@ static uintptr_t sys_kernelctl(SyscallsFrame *Frame, enum KCtl Command, uint64_t
return TaskManager->GetCurrentThread()->Security.IsCritical;
case KCTL_REGISTER_ELF_LIB:
{
if (!CheckTrust(TrustedByKernel | Trusted))
return SYSCALL_ACCESS_DENIED;
char *Identifier = (char *)Arg1;
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:
{
if (!CheckTrust(TrustedByKernel | Trusted))
return SYSCALL_ACCESS_DENIED;
char *Identifier = (char *)Arg1;
if (!Identifier)
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:
{
if (!CheckTrust(TrustedByKernel | Trusted))
return SYSCALL_ACCESS_DENIED;
char *Identifier = (char *)Arg1;
if (!Identifier)
return 0;

View File

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