Section 19.5.5

Interprocess communication and authority transfer

Definition

Interprocess communication (IPC) is any mechanism by which processes, programs that run in separate protected memory, exchange data: messages passed through the operating system, shared memory, pipes or sockets. Authority transfer is passing a right over such a channel, usually a capability, an unforgeable reference that names an object and grants rights over it, so that the receiver can afterwards act on that object. The difference that matters: plain IPC moves bytes, which the receiver must check before relying on them; authority transfer changes what the receiver can do.

Where it fits

Main entry: Capability security (§1.40).

The Capability security entry explains capabilities themselves; here one request crosses the boundary between two isolated components. In a microkernel §19.5.4, an operating-system kernel (the privileged core of the system) that runs most services as separate programs, a program sends a message by invoking a capability for an endpoint, a kernel object that works as a mailbox; only holders of that capability can send to it. The kernel copies the message, switches to the receiver’s address space, the memory the receiver can see, and runs the receiver; the reply takes the same path back. In the seL4 microkernel, each client’s endpoint capability can carry a badge, a number that the kernel delivers with every message sent through that capability, so the server learns which client is asking from the kernel, not from a claim inside the message.

A message can also carry authority. Unix-like systems pass an open file descriptor §15.21, a process’s numbered reference to an open file, to another process over a Unix-domain socket, a local communication channel; seL4 passes capabilities inside messages when the sender’s endpoint capability permits it. Each transfer must settle which rights the receiver gets, possibly fewer than the sender holds; whether the sender keeps its copy; how the authority is withdrawn later; and what happens when the object is destroyed. Only the kernel’s transfer mechanism transfers authority. If a sender writes the number 3 into a message because its own file descriptor 3 is open, the number transfers nothing: in the receiver, 3 names the receiver’s own entry 3 or nothing, and it is untrusted data.

Isolation does not settle whose authority a service uses. A storage service holds rights over the whole disk, and a client holds a read-only capability for one file. If the client sends a file name and the service opens that file with the service’s own rights, the client can make the service write a file the client could not touch: the confused deputy problem §1.25. The service must act with the client’s authority, for example by receiving the client’s capability for the file and writing through it, so that the kernel refuses what the client could not do. Three questions stay separate: who sent the request (authentication §1.6), whether that sender may ask for this operation (authorization §1.7), and whether the operation was carried out.

The time cost can be estimated. Take, as illustrative figures, 1 microsecond for one IPC round trip, a request and its reply, and a copy speed of 1 byte per nanosecond. A service handles 20,000 requests per second, each carrying 4,096 bytes. Copying 4,096 bytes takes 4,096 nanoseconds, which is 4.096 microseconds, so each request costs 1+4.096=5.0961 + 4.096 = 5.096 microseconds, and each second costs 20,000×5.096=101,92020{,}000 \times 5.096 = 101{,}920 of its 1,000,000 microseconds, about 10.2% of one processor. Sharing one memory region between client and server removes the copy and leaves 20,000×1=20,00020{,}000 \times 1 = 20{,}000 microseconds, 2%. The client can then change the bytes after the server has checked them, a time-of-check to time-of-use §9.26 (TOCTOU) error, unless the server copies what it checks.

Limits and common mistakes

Isolation costs more than time per message. Each component needs its own stack and memory regions, every request must be encoded and decoded (serialization §4.28), and a server that crashes or never replies becomes a failure its clients must handle, with a timeout §9.34 or a restart. Two servers that each wait for a reply from the other wait forever: a deadlock §9.14.

A component boundary is a trust boundary §1.3. The receiver must check every message, however well the channel is isolated: isolation confines a fault in the sender; it does not make the sender’s input correct.

Questions answered

What is the cost of stronger component isolation?

Stronger component isolation costs processor time on every request that crosses a component boundary, memory for each component, and design work on the interfaces between components. The time goes to interprocess communication (IPC): each request enters the kernel, switches to the receiver’s address space (the memory the receiver can see), may wait for the scheduler, and copies or maps the data, and the reply repeats the path; a function call inside one program pays none of this. The memory goes to a separate stack and separate protected regions for each component. The design work is a message format, checks on every received message, rules for which rights a message transfers and how they are withdrawn, and handling of a component that fails or never replies.

In return, a fault or compromise in one component reaches only what that component’s rights allow. The size of the cost depends on the processor, the kernel and the amount of data, so it must be measured on the actual request path. A boundary alone proves neither cheap communication nor isolation of effects: a component can still misuse the rights it holds or send wrong data.

Related entries: Confused deputy (§1.25), Authorization (§1.7), D-Bus (§12.22), Microkernel, monolithic kernel, and service isolation (§19.5.4), Time-of-check to time-of-use (TOCTOU) (§9.26), File descriptor versus pathname (§15.21). Further reading: [156].