[zion] Enfore Duplication permissions on capabilities.
This commit is contained in:
parent
1364fbed9f
commit
f0a27d30be
|
@ -22,7 +22,7 @@ class Channel : public IpcObject {
|
|||
public:
|
||||
uint64_t TypeTag() override { return KernelObject::CHANNEL; }
|
||||
static uint64_t DefaultPermissions() {
|
||||
return kZionPerm_Read | kZionPerm_Write;
|
||||
return kZionPerm_Read | kZionPerm_Write | kZionPerm_Duplicate;
|
||||
}
|
||||
|
||||
static glcr::Pair<glcr::RefPtr<Channel>, glcr::RefPtr<Channel>>
|
||||
|
|
|
@ -21,7 +21,7 @@ class Endpoint : public IpcObject {
|
|||
public:
|
||||
uint64_t TypeTag() override { return KernelObject::ENDPOINT; }
|
||||
static uint64_t DefaultPermissions() {
|
||||
return kZionPerm_Read | kZionPerm_Write;
|
||||
return kZionPerm_Read | kZionPerm_Write | kZionPerm_Duplicate;
|
||||
}
|
||||
|
||||
static glcr::RefPtr<Endpoint> Create();
|
||||
|
|
|
@ -23,7 +23,7 @@ class MemoryObject : public KernelObject {
|
|||
public:
|
||||
uint64_t TypeTag() override { return KernelObject::MEMORY_OBJECT; }
|
||||
static uint64_t DefaultPermissions() {
|
||||
return kZionPerm_Write | kZionPerm_Read;
|
||||
return kZionPerm_Write | kZionPerm_Read | kZionPerm_Duplicate;
|
||||
}
|
||||
|
||||
MemoryObject(uint64_t size);
|
||||
|
|
|
@ -22,7 +22,7 @@ class Port : public IpcObject {
|
|||
public:
|
||||
uint64_t TypeTag() override { return KernelObject::PORT; }
|
||||
static uint64_t DefaultPermissions() {
|
||||
return kZionPerm_Write | kZionPerm_Read;
|
||||
return kZionPerm_Write | kZionPerm_Read | kZionPerm_Duplicate;
|
||||
}
|
||||
|
||||
Port() = default;
|
||||
|
|
|
@ -24,7 +24,7 @@ class Process : public KernelObject {
|
|||
uint64_t TypeTag() override { return KernelObject::PROCESS; }
|
||||
static uint64_t DefaultPermissions() {
|
||||
return kZionPerm_Write | kZionPerm_Read | kZionPerm_SpawnThread |
|
||||
kZionPerm_SpawnProcess;
|
||||
kZionPerm_SpawnProcess | kZionPerm_Duplicate;
|
||||
}
|
||||
|
||||
enum State {
|
||||
|
|
|
@ -10,6 +10,9 @@ z_err_t CapDuplicate(ZCapDuplicateReq* req) {
|
|||
if (!cap) {
|
||||
return glcr::CAP_NOT_FOUND;
|
||||
}
|
||||
if (!(cap->permissions() & kZionPerm_Duplicate)) {
|
||||
return glcr::CAP_PERMISSION_DENIED;
|
||||
}
|
||||
*req->cap_out = proc.AddExistingCapability(cap);
|
||||
return glcr::OK;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ z_err_t MemoryObjectDuplicate(ZMemoryObjectDuplicateReq* req) {
|
|||
auto& curr_proc = gScheduler->CurrentProcess();
|
||||
auto vmmo_cap = curr_proc.GetCapability(req->vmmo_cap);
|
||||
// FIXME: Check a duplication permission here.
|
||||
RET_ERR(ValidateCapability<MemoryObject>(vmmo_cap, kZionPerm_Write));
|
||||
RET_ERR(ValidateCapability<MemoryObject>(vmmo_cap, kZionPerm_Duplicate));
|
||||
|
||||
ASSIGN_OR_RETURN(
|
||||
glcr::RefPtr<MemoryObject> new_vmmo,
|
||||
|
|
Loading…
Reference in New Issue