Skip to content

Fd handoff

The nucleus host uses file-descriptor handoff when a monitor must map a kernel-owned memory object without receiving a filesystem path or recreating the object. The handoff is a bounded Unix-domain datagram carrying typed identity bytes and SCM_RIGHTS descriptors together. This page covers the handoff boundary, its checks, and its role in shared-memory channel setup.

The boundary

flowchart TB
  subgraph HOST["NUCLEUS HOST"]
    direction TB
    CMD["InstallChannel command<br/>authority, mapping plan, socket path"]
    BACK[("Call and completion backings")]
  end
  subgraph CTRL["AUTHENTICATED CONTROL CHANNEL"]
    direction TB
    LANE["Control lane"]
  end
  SOCK[("Private Unix socket<br/>mode 0700 directory")]
  subgraph CELL["CELL"]
    direction TB
    MON{{"Cell monitor<br/>identity, count, size,<br/>backing continuity"}}
  end
  CMD -->|"1. authoritative instruction"| LANE
  LANE --> MON
  MON -->|"2. binds the receiver"| SOCK
  BACK -->|"3. plan digest and two descriptors"| SOCK
  SOCK --> MON
  MON -->|"4. mapping-bound receipt"| LANE
  LANE -->|"5. effect-correlated completion"| CMD

InstallChannel command reaches the monitor over Control lane and stays the authoritative instruction. Private Unix socket carries only the operating system objects that instruction names. The receipt on edge 4 returns over the authenticated lane, and the channel activates only after the nucleus admits both endpoints' receipts.

Receiving descriptors leaves the ChannelGrant, its credit and the channel's activation state unchanged.

Admission checks

The generic handoff accepts a non-empty payload of at most 64 KiB and at most 16 descriptors. A shared-memory channel narrows that surface to exactly two descriptors: call backing first and completion backing second. Its payload must equal the mapping-plan digest in the authenticated command.

The monitor also checks that both files have the mapping plan's exact byte length and are distinct backing objects. On an exact retry, their operating-system file identities must match the already installed call and completion backings. A same-size substitute is refused.

Progress and cleanup

The monitor's receive and the host's connect loop each have a five-second deadline. The host creates a private mode-0700 directory for the socket and removes the socket and directory when the attempt ends. Received descriptors are owned values: refusal closes them automatically, revocation drops the live mapping, and cell-epoch invalidation prevents the backing identity from being reused.

If the endpoint installed the mapping but its reply was lost, the host keeps the original bounded backing pair. Retrying the same effect duplicates that pair and returns the same mapping-bound receipt. It never mints a new pair under the old channel identity. See Cell shared-memory channel and Channel authority.