Browse documentation

Permissions (capabilities)

Every action needs an unforgeable token. There is no root account.

DurgX has no administrator and no all-powerful account. A program can only do something if it holds a capability: a token that names exactly one thing and exactly what may be done with it.

Capabilities cannot be forged. A program never sees the token itself. It holds a small number (a slot index) that points to the token inside the kernel.

What a capability contains

PartMeaning
ObjectWhat it points to: memory, a device interrupt, a thread, a message endpoint and so on.
RightsWhat you may do with it (see below).
GenerationA counter. Raising it cancels this capability and every copy made from it, instantly.
BadgeA label you choose, so a server can tell its callers apart.

Rights

RightLets you
READRead the object.
WRITEChange the object.
GRANTHand a weaker copy to another program.
MAPMap memory into your own address space.
INVOKECall it: send to an endpoint, wait on an interrupt.
REVOKECancel the copies you handed out.

Kinds of objects

ObjectWhat it is
UntypedRaw physical memory that has not been given a purpose yet.
FrameOne page of memory, including device memory a driver talks to.
PageTablePart of a program's memory map.
TcbA thread.
EndpointA place to send messages to, or a message ring.
IrqOne hardware interrupt line.
IoPortA specific range of device ports.
CNodeA table of capabilities, used to pass them around.

Memory comes from you

The kernel never allocates memory on its own. Whenever it needs room for a new thread or page table, that memory is carved out of an Untyped capability you supply. The result: the kernel cannot run out of memory in the middle of a job, and you can see exactly where all memory went.

When an action is refused

ReasonMeaning
Invalid slotThe slot you named is empty.
Insufficient rightsThe capability exists but does not allow this action.
RevokedThe capability was cancelled.
Wrong object typeThe capability points to a different kind of object.
Target faultedThe program you tried to reach has crashed.

Try it

Capability radix tree

A task's CSpace is a 2-level radix tree indexed by cptr. Dashed arcs show derivation.

CSpace rootCNode 0b0··CNode 0b1··Untyped0x00gen 1Frame0x01gen 1Endpoint0x02gen 1empty0x03Tcb0x04gen 1Irq0x05gen 1IoPort0x06gen 1empty0x07

Select a capability. Revoke an authority to watch every derived copy die in a single write.

slot 0x00

valid

Untyped

64 MiB physical memory

READWRITEGRANTREVOKE
generation
1
badge
0x0
struct Capability {
  object:     ObjectRef,
  rights:     Rights,
  generation: u32,  // bump = revoke
  badge:      u64,
}