[Zion] Validate that started threads are in user space.
This commit is contained in:
parent
f8f839d8e7
commit
c63a54d6b1
|
@ -4,6 +4,12 @@
|
||||||
#include "debug/debug.h"
|
#include "debug/debug.h"
|
||||||
#include "scheduler/scheduler.h"
|
#include "scheduler/scheduler.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
bool IsKernel(uint64_t addr) { return (addr & 0xFFFF'FF80'0000'0000); }
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
glcr::ErrorCode ThreadCreate(ZThreadCreateReq* req) {
|
glcr::ErrorCode ThreadCreate(ZThreadCreateReq* req) {
|
||||||
auto& curr_proc = gScheduler->CurrentProcess();
|
auto& curr_proc = gScheduler->CurrentProcess();
|
||||||
auto cap = curr_proc.GetCapability(req->proc_cap);
|
auto cap = curr_proc.GetCapability(req->proc_cap);
|
||||||
|
@ -21,7 +27,11 @@ glcr::ErrorCode ThreadStart(ZThreadStartReq* req) {
|
||||||
RET_ERR(ValidateCapability<Thread>(cap, kZionPerm_Write));
|
RET_ERR(ValidateCapability<Thread>(cap, kZionPerm_Write));
|
||||||
|
|
||||||
auto thread = cap->obj<Thread>();
|
auto thread = cap->obj<Thread>();
|
||||||
// FIXME: validate entry point is in user space.
|
|
||||||
|
if (IsKernel(req->entry) || IsKernel(req->arg1) || IsKernel(req->arg2)) {
|
||||||
|
return glcr::INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
|
||||||
thread->Start(req->entry, req->arg1, req->arg2);
|
thread->Start(req->entry, req->arg1, req->arg2);
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue