Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/heimdall

docs/PLAN-BIND-FD.md

Bind by open descriptor: plan

Holger's H40-LIST 77. The coordinator accepted this plan on 2026-11-16 (walk plus proof, fail closed; the choices of section 8) and ordered the additions marked A1 to A4. An independent audit of the plan followed (AUDIT-BIND-FD-2026-11-16.md, eight findings); the coordinator's decisions on it are marked D-F1 to D-R4 below and listed in section 9. The build goes in the order of section 5.

1. What a caller gets

A service's read binds, its socket directory and a function service's data directory can be given as an open descriptor instead of a path. Heimdall then gives the service the object the descriptor names, whatever stands at its old path by then, or it refuses the start. It never gives the service something else. A service that uses only paths behaves, serialises and is configured exactly as today.

The guarantee, in the words docs/API.md gets (A4): a bind by descriptor gives the service the object the descriptor names, or a refused start. A racing rename can make a start fail; it can never give the service another directory. A directory removed after the open cannot be bound. The same holds for a regular file given as a read bind.

The escape guard (A1): a descriptor of a host directory inside the service would be a way out (openat(fd, "..")). So no bind descriptor is ever open in the service's program or in the function, and no program that the shim, the intermediate process or the init executes inherits one. Section 3.5 says where each one is closed.

2. What the kernel and libcontainer allow (measured)

Measured 2026-11-16 in a KVM guest on the dwarf host (kernel 7.0.0-43-generic), as root, with and without a new user namespace, with plain system calls. "The descriptor" was opened with O_PATH before the new mount namespace existed, as a runner's descriptor always is.

# What was tried inside the new mount namespace Result
M1 mount(MS_BIND) from /proc/self/fd/<n> EINVAL
M2 open_tree(<n>, "", OPEN_TREE_CLONE), and open_tree("/proc/self/fd/<n>", OPEN_TREE_CLONE) EINVAL
M3 What libcontainer 0.7.0 does with the source /proc/self/fd/<n>: canonicalize, then open_tree on that path. The directory had been renamed away and another directory, or a symlink, put at its old path mounts the ORIGINAL (the kernel reports the descriptor's current path)
M4 M3 in a process that is not dumpable, as libcontainer's init is as M3
M5 M3, with another directory swapped in between the two walks mounts the IMPOSTOR
M6 M3, after the directory was removed and a directory named <name> (deleted) was made mounts the IMPOSTOR
M7 fstat of the descriptor against stat of the mounted place equal in M3 and M4, different in M5 and M6
M8 No path at all: a process does fchdir(<n>), then unshare of a user and mount namespace. Its working directory is carried into the new namespace; open_tree(".") there, and move_mount of that tree in another namespace works for a directory; a regular file cannot be a working directory (ENOTDIR)
M9 A directory that was removed after the descriptor was opened cannot be mounted in either way (M3: ENOENT; M8: move_mount gives ENOENT)
M10 A regular file: another file renamed OVER its path after the open (plain VFS, measured on the dwarf kernel without a namespace) the original has no name any more: st_nlink 0, the kernel reports <path> (deleted); it is M9 for a file. Renamed AWAY first and another file put at the old path: st_nlink 1, the kernel reports the new path

Why M1 and M2 fail: the kernel copies a mount only from a mount of the caller's own mount namespace. A descriptor opened on the host still points into the host's namespace, also when the mounting process holds it.

libcontainer 0.7.0 (=0.7.0 in crates/heimdall-container/Cargo.toml:61), src/rootfs/mount.rs:591-652: for a bind it calls canonicalize(source) (:594), then src.is_dir() (:599), then open_tree(AT_FDCWD, <that path>, OPEN_TREE_CLONE | AT_EMPTY_PATH | AT_RECURSIVE), mount_setattr and move_mount. That is three walks of a path string, and none is checked against anything.

What this means for the decision "/proc/self/fd/<n> as the OCI source where it is proven that the mounting process holds <n>". The mounting process does hold <n> (section 3.4). But the source is still a walk of the name the kernel reports for the descriptor at that moment, and M5 and M6 show the walk can be made to end elsewhere. So this source is safe only together with a proof (M7) that Heimdall makes itself, in the same process, before any code of the service runs. This plan adds that proof. It is the one place where the plan cannot follow "Heimdall never walks a path for it again" to the letter: Heimdall's own code never walks one, libcontainer walks the kernel's current name for the descriptor, and Heimdall proves the result or refuses. The way without any walk is in section 7.

Limits of walk plus proof (audit F5 and F6; decisions D-F5 and D-F6).

3. Design

3.1 The type (heimdall-core)

/// Where a bind comes from on the host.
#[derive(Clone, Debug)]
pub enum BindSource {
    Path(PathBuf),
    /// An `O_PATH` descriptor (`O_DIRECTORY` too for a socket or data directory).
    #[cfg(unix)]
    Fd(Arc<OwnedFd>),
}

3.2 The runner's own work on a descriptor (heimdall-container, no path)

All of it in the supervisor thread, before the config is written, through new functions in the private sys module (crates/heimdall-container/src/sys.rs, the crate's only unsafe code):

Today, by path For an Fd
socket_dir.host and data_dir.host must be absolute (service.rs:280-285, :373-382) does not apply
nothing: a path is not a descriptor F_GETFD has FD_CLOEXEC (D-F2). A descriptor without it may already be open in the caller's other children, and the caller must know: refused
a read bind must exist (service.rs:704-711, :978-985) fstat: a directory or a regular file; F_GETFL has O_PATH
nothing the filesystem (D-F6): fstatfs gives ext2/3/4 (0xEF53), xfs or btrfs; or tmpfs whose mount shows inode64 (the descriptor's mount id from statx, looked up in /proc/self/mountinfo; no walk of the bind's path). Any other type is refused, with the type's name
the data directory must be a directory (service.rs:986-994) fstat: a directory
the socket directory is created when missing (service.rs:418-420) does not apply; fstat: a directory
mode 0750, old sockets removed, anything else refuses (service.rs:423-436) one reopen openat(fd, ".", O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC), then fchmod, fdopendir/readdir, fstatat(.., AT_SYMLINK_NOFOLLOW), unlinkat on it
the id shift lchown(socket_dir.host, ..) (service.rs:796-805, :1010-1018) fchown on the same reopened descriptor (the standard library's call, no unsafe code; the plan first said fchownat with AT_EMPTY_PATH on the O_PATH descriptor, which gives the same result with one more unsafe call)

A descriptor that fails a check is RunError::InvalidJob whose reason starts with BIND_FD_REFUSED (not close-on-exec, not O_PATH, a file where a directory is needed). A filesystem on which the proof cannot be claimed is RunError::Unsupported, the text starting with the constant and naming the type.

The filesystem answer is the kernel's, and plain CI runs where a test directory is on overlayfs (/tmp of a toolchain container). So the runner asks it through the same seam as the duplicate (section 3.3): the hand-over tests give an accepting fake, the real check has its own tests (the decision as a table of types and mount lines; the real calls on the directory the test happens to have, held to that table), and the kernel tests use real directories (section 5).

An object that has no name any more (fstat gives st_nlink 0: a removed directory, a file that another was renamed over; M9, M10) is refused here, before anything is made, with RunError::Setup starting with BIND_FD_REFUSED. A removal that races the start after this check makes libcontainer's mount fail or the proof fail; the start is refused either way, and in the first of the two the text is libcontainer's.

3.3 Keeping the descriptor and handing it to each start

3.4 Who mounts, on each start path

Heimdall's own code mounts nothing today (there is no mount call in crates/), and nothing after this change. Every mount of a service is made by libcontainer from config.json.

Start path The config The process that mounts How the descriptor is open there
Image service: HeimdallRunner::launch_in (service.rs:691); the binds at :789-792 through bind() (:440) written by the supervisor thread at :816-820. A Path bind's source is the path, as today. An Fd bind's source is a placeholder that no process can resolve, /proc/self/fd/heimdall-bind-<i> (a name in /proc/self/fd that is not a number never exists; <i> counts the start's descriptor binds). The shim replaces it by /proc/self/fd/<n> in the bundle's config.json, after its check on arrival and before it makes the container (D-F1) libcontainer's container init (container_init_process, libcontainer 0.7.0 src/process/init/process.rs:42; prepare_rootfs at :87), PID 1 of the service's PID namespace The init is a clone of libcontainer's intermediate process, which is a clone of the shim heimdall-container-shim (started by spawn_shim_cmd). No execve lies between the shim's start and the mounts, and libcontainer closes nothing before them: its one sweep (close_range, process.rs:334) comes after pivot_root and only sets close-on-exec; the executor is called from the same process at :482. So <n> in the init is the duplicate the runner made for this start
Function service: launch_function_in (service.rs:960); the binds in spec::function (crates/heimdall-container/src/spec.rs:109, :145-149, through bind_mount, :93) written at service.rs:1020-1024, with the same placeholders; the starter replaces them as the shim does the same process the same; here the shim is the caller's starter program, run from the runner's sealed memfd (service.rs:1061-1070, starter_image.rs:154)
Jobs (JobRunner) not touched: a job has none of the three types

Why the placeholder (D-F1, audit F1). The shim is a separate program and a starter is the caller's; nothing pins either to the runner's build. An older one ignores service.binds (the request has no version and unknown fields are not refused, shim.rs:65-86), and with a resolvable source it would mount without a proof and START THE PROGRAM: its start line comes only after the program's execve (shim.rs:1104-1125), and the runner checks the report after that (service.rs:897-953). With the placeholder an older shim leaves the source as it is, libcontainer's canonicalize fails (libcontainer rootfs/mount.rs:594), no container is made and nothing of the service runs. binds_proven (section 3.5) stays as the second check. A number that is "probably not open" in an older shim was considered and is not a proof; a name that is not a number is.

3.5 The proof

In HeimdallExecutor::exec (shim.rs:639), as its first step: before the learning uid (:650), before the function's view (:666) and before Landlock (:677). That is in the same init process that made the mounts, after pivot_root, before the service's program or function. In this order (D-R2):

  1. fstat of every bind descriptor;
  2. every bind descriptor closed with sys::close_fd, whatever step 1 gave (after this, /proc/self/fd/<n> is no second route to the object);
  3. stat of every dest.

For each bind the two must give the same (st_dev, st_ino), the same file type (a directory, or a regular file for a read bind of a file), the same mode, and the same owner, uid and gid (D-F5). On a miss the executor reports BIND_FD_REFUSED: <dest>: ... on the report pipe and returns an error; the program or function never starts.

What the init is by then (audit, under F6). libcontainer has already given the init the service's uid and gid, dropped every capability and installed the fixed seccomp profile (libcontainer process/init/process.rs:273-413; the executor is called at :482). So:

Where each holder of a bind descriptor lets go of it (A1).

Holder Image service Function service
the runner (supervisor thread), on the host the duplicates of one start are dropped when spawn_shim_cmd returns; the caller's descriptor lives in the Unit until the service is over the same
the shim, on the host, outside the container first act of run (shim.rs:830, before the graph preparation, the broker probe or any other fork or exec): close-on-exec back on every bind descriptor. Its own copies are closed right after build() returned (shim.rs:977): the init has its own by then the same
a program the shim or libcontainer's main process executes (the id-map helpers newuidmap, newgidmap) an execve: close-on-exec closes them the same
libcontainer's intermediate process a clone that executes nothing and ends once the init exists the same
the init, up to and through the mounts open: libcontainer resolves /proc/self/fd/<n> there the same
a hook the init would execute Heimdall configures none; it would be an execve: close-on-exec closes them the same
the init, in HeimdallExecutor::exec (shim.rs:639) 1. the proof; 2. sys::close_fd(n) for every bind; 3. everything else (Landlock at :677, the broker filter, the profile); 4. execve of the program, where close-on-exec is the second barrier (libcontainer's close_range, process.rs:334, set it on every descriptor from 3 up) 1. the proof; 2. sys::close_fd(n) for every bind; 3. starter::enter_view (:666); 4. call_function (:464): sys::close_fds_except(REPORT_FD) at :499 closes every descriptor from 3 up but the report. There is no execve here, so close-on-exec does nothing: step 2 is the close, the sweep of step 4 is the second barrier; 5. the profile, the report written and closed, then the call (starter::call)

So the program's first instruction, and the function's, run with no bind descriptor open, on the first start and on every restart (each start is a new shim, a new init and the same order).

Why this is enough: a mount's root cannot change once it is attached, the init is the only process in that mount namespace, and the held descriptor pins the inode, so its number cannot be given to another object.

InsideReport (shim.rs:122) gets binds_proven: u32, left out of the JSON when zero. start_and_confirm (service.rs:871, the check at :935) requires it to equal the service's number of descriptor binds, or it stops the start. This is the second check. The first is the placeholder of section 3.4: a shim or a starter that does not know the feature cannot make the container at all, so with it nothing of the service runs; binds_proven alone would only stop the service after its program had started.

3.6 Refusals

RunError (crates/heimdall-core/src/runner.rs:36) is not non_exhaustive: a new variant would break every match in Holger. The plan adds none. Every refusal of this feature uses an existing variant, and its text starts with the public constant BIND_FD_REFUSED ("bind by descriptor refused"), followed by which bind and why. A caller matches the variant and starts_with(BIND_FD_REFUSED).

Case Variant
the caller's descriptor is wrong (not close-on-exec, not O_PATH, not a directory where one is needed) InvalidJob
a runner that has no way to keep or pass a descriptor (descriptor_binds() is its check), or a filesystem on which the proof cannot be claimed Unsupported
the object has no name any more, the duplicate cannot be made, the shim did not get the descriptor, the shim did not prove the binds, or the mounted place is not the descriptor's Setup

No case falls back to a path.

The constant comes first in every refusal Heimdall decides itself (D-F7). That is the descriptor check, the duplicate, the hand-over, the arrival in the shim and the proof. Today's code puts its own words in front of what the shim and the executor say: "inside the job, before execve: ..." (lib.rs:685-718, inside_features) and "the service never started: ..." (service.rs:210-215, never_started). The runner builds those reasons with the constant first when what arrives tells of a bind refusal. A refused RESTART is returned to nobody: it becomes the text of the service's status (service.rs:1221-1241, ServiceStatus::Stopped.error and the backoff's), which today is the error's display text ("setup: ..."); for a bind refusal the status text is the reason itself, so it starts with the constant too.

A mount that libcontainer itself cannot make is NOT such a refusal: a walk that ends in ENOENT or EACCES, a directory removed in the moment between the runner's check and the mount, a parent the service's user cannot search. It stays a plain Setup "the service never started" with libcontainer's words and without the constant. docs/API.md says so.

3.7 A path bind is unchanged

The JSON of a Service or FunctionService with only Path binds, the shim's request and the written config.json stay byte-identical. Three tests pin them (section 5, written first, on today's types).

4. All affected code

File Lines at the tag Change
crates/heimdall-core/src/service.rs :36 imports; :82-87 field docs; :102-107 BindRo; :109-120 SocketDir BindSource, its impls, the two constants, Service::descriptor_binds; host: BindSource
crates/heimdall-core/src/function.rs :18 module doc; :28 imports; :112-120 DataDir; :143-147 field docs host: BindSource; FunctionService::descriptor_binds
crates/heimdall-core/src/lib.rs :40, :43 nothing to write: both modules are exported whole
crates/heimdall-container/src/service.rs never_started :210-215; check_service :247, :280-285; check_function_service :337, :373-382; prepare_socket_dir :405-437; bind :440-447; launch_in :691: :704-711, :720, :789-792, :796-805, :844-851, :853; start_and_confirm :871: :881, :897-953; launch_function_in :960: :978-995, :1009, :1010-1018, :1048-1059, :1072; supervise :1212, the refused restart at :1221-1241; unit tests :1558-1563, :1605 sections 3.2 to 3.6; the constant first in "never started" and in the status text of a refused restart (D-F7)
crates/heimdall-container/src/spec.rs bind_mount :93-100; function :109-155, the binds at :145-149 the source of an Fd bind; function takes the start's numbers
crates/heimdall-container/src/lib.rs spawn_shim :582, spawn_shim_with :592, spawn_shim_cmd :603-640 (the command at :612-621); the runner's seams (beside with_child_claim, :498); inside_features :685-718 the numbers kept across execve, only when there are any (D-F8); LISTEN_* removed from the shim's environment (D-F1b); the seam for the duplicate and the filesystem answer; the constant first in the inside error (D-F7)
crates/heimdall-container/src/shim.rs ShimService :74-86; InsideReport :122-145; HeimdallExecutor :349-367; exec :639-650; run :830, the executor made at :941-952, the container made at :977-985 binds, binds_proven, the check on arrival, the placeholder replaced in the bundle's config.json (D-F1), the proof
crates/heimdall-seccomp/src/launch/fds.rs the numbers :5-13, ALL :18-20 read, not changed: the numbers a duplicate must not take (D-R1)
crates/heimdall-plain/src/default_profile.rs, crates/heimdall-container/src/profile.rs :44, :88, :211, :337, :342; REMOVED, KILL read, not changed: the proof's calls are allowed (a test)
crates/heimdall-container/src/sys.rs new functions beside dup_cloexec_to (:95) and close_fd (:268) duplicate with a floor, keep across exec, identity by fstat, the O_PATH and close-on-exec checks, the filesystem type (fstatfs) and the mount id (statx), the socket directory by descriptor, the owner by descriptor
crates/heimdall-container/src/bindfd.rs new (step 2) the runner's work on a descriptor in a module of its own: the seam BindFds (the duplicate, the filesystem), check, proof_holds_on, prepare_socket_dir, BindPlan (each bind's source in the config) and StartBinds (one start's duplicates and request), and the texts refused, relay, refusal_text. sys.rs holds only the raw calls
crates/heimdall-cli/src/profile.rs :355-372 (the --function view options) read, not changed: they are paths inside the view
docs/API.md :468-530 (services, the example at :478-489, the socket directory at :525); :582-630 (function services, the example at :592-602, the table rows at :615-617) the type, the refusals, the escape guard, and the guarantee in the words of section 1 (A4)
CHANGELOG.md :14 [Unreleased] Added and Changed lines under Unreleased; the field type of three public structs changes, which breaks callers that pass a PathBuf without .into()
Tests that build the three types crates/heimdall-core/tests/function_service.rs:24-29; crates/heimdall-container/tests/function_service.rs:29-41, 73; tests/service_fake_shim.rs:121-123; tests/service_kernel.rs:110-115; tests/function_kernel.rs:57-69 (ranges corrected, D-R4) compile with .into(); nothing else
Test fixtures crates/heimdall-container/tests/fixtures/svc_daemon.rs:114-120 (a line that lists a directory); the function fixture of tests/function_kernel.rs (a word that lists and writes) new lines for the kernel tests

Not touched: jobs, heimdall-plain, heimdall-broker, the wasm runner, the CLI's behaviour, libcontainer.

5. Tests, RED first, in build order

Each step is its own commits on e-lane/bind-fd, the RED commit pushed before the fix, each run in a container. Kernel tests run in a KVM guest through scripts/container-tests.sh, one build directory per tree.

Step 0, pins (green on today's code, written before anything changes). crates/heimdall-core/tests/bind_source.rs: the JSON of a Service and of a FunctionService with path binds equals a literal string. tests/service_fake_shim.rs: the request a fake shim receives and the config.json in its bundle, for a service with path binds, equal stored files. tests/spec.rs: spec::function for path binds equals a stored file.

Step 1, the type (core, plain CI). RED in bind_source.rs: a path source equals by path; a clone of a descriptor source equals it and shares the descriptor; two sources made from two descriptors of the same directory are not equal; a path never equals a descriptor; a descriptor source refuses to serialise and the error is BIND_FD_NOT_SERIALISABLE; a service with one refuses as a whole; deserialising gives Path; the From impls; Display. The three pins stay green.

Step 2, the runner's work and the hand-over (container, plain CI, fakes). RED unit tests in sys.rs and service.rs: the socket directory by descriptor (sockets removed, mode 0750, a file that is not a socket refuses, and all of it still lands in the original directory after it was renamed away and another put at its path); a descriptor without O_PATH refuses; a file where a directory is needed refuses; check_service and check_function_service take a descriptor where they demanded an absolute path. RED in tests/service_fake_shim.rs (the fake shim is a shell script; it prints stat -L -c %d:%i /proc/self/fd/<n> for the numbers in its request): a_descriptor_bind_reaches_the_shim_as_the_same_inode_under_the_number_in_its_request; the_descriptor_is_handed_again_at_every_restart_and_the_runner_leaks_none (the count of the runner's open descriptors is the same after three restarts); the_service_keeps_its_descriptor_after_the_caller_dropped_its_own; a_start_whose_descriptor_cannot_be_duplicated_is_refused_and_leaves_nothing_behind (the seam fails); a_shim_that_does_not_prove_its_binds_is_refused_and_leaves_nothing_behind (a start line without binds_proven); no_other_child_of_the_runner_inherits_the_descriptor. The request and config pins stay green.

As built (step 2). The unit tests are in tests/bind_fd.rs and, alone in its process, tests/bind_fd_numbers.rs; the fake-shim tests are the ones named above and those of the decisions below. The RED commit holds the tests and the names they need with every answer "not built yet": 38 tests failed, each on its own assertion. Four things are not as the lines of this plan say, or are not said in them:

Added by the decisions, all RED first:

Step 3, the mount and the proof (kernel tests, RED first; then the unit tests of the proof). In tests/service_kernel.rs, each opens the descriptor first:

Added by the decisions:

Measurements in the guest, reported to the coordinator BEFORE any code for them. They concern every bind, path binds too, and are not part of this change unless the coordinator says so.

The escape guard (A1), kernel tests on both start paths. The test daemon gets a line, and the test function a word, that reports every descriptor it holds as number=dev:ino (the daemon through /proc/self/fd; the function, which has no /proc, by fstat of every number up to its RLIMIT_NOFILE).

A regular file by descriptor (A2). tests/service_kernel.rs, the descriptor opened with O_PATH on a file with known content:

Host ids (A3). tests/service_kernel.rs: with_host_ids_a_socket_directory_by_descriptor_is_owned_by_the_shifted_user_and_serves: a runner made with with_host_ids (as tests/container.rs:1539), a service with a user other than root and the socket directory by descriptor. After the start, fstat of the test's descriptor shows the shifted uid and gid (the owner change by descriptor), the daemon answers on its socket through /proc/self/fd/<fd>/<socket>, and after the swap of section 5 the socket is in the original directory. The guest can give a host id range: the two with_host_ids tests of tests/container.rs (:1529, :1565) passed there on 2026-11-16. The unit test of the owner change by descriptor stays beside it (it needs root, so it is a kernel test too; plain CI checks the call is made with the shifted ids through the seam).

The gate for the whole change: fmt, Clippy for core and for the container crate (plain, youki, youki,graph-follower), the tests of both crates in the same three shapes, the CLI's profile_function tests, and the whole scripts/container-tests.sh in the guest.

As built (step 3). The proof is commit c39bf74; the tests of it are 9088978; D-F1b is 4748741 and d78f6fd.

Measured in step 3 (guest e-lane-kvm2, kernel 7.0.0-43-generic, libcontainer 0.7.0, the real runner and shim, 2026-11-16). None of it has code in this change.

After the merge of main (2ddfe6e8: the end of a service, a function's SIGPIPE rule; 2026-11-16). Main and this change meet in two places, and each has a kernel test with a real container.

6. Kernel

Nothing here needs a kernel newer than the repo already needs for a service (Landlock, 5.13, crates/heimdall-container/src/kernel.rs:286). What the plan uses: O_PATH (2.6.39), F_DUPFD_CLOEXEC (2.6.24), /proc/self/fd, openat, fstat, fstatfs on an O_PATH descriptor (3.12), statx with the mount id (5.8), /proc/self/mountinfo. The mount itself is libcontainer's and does not change (open_tree and move_mount 5.2, mount_setattr 5.12; it has no fallback for older kernels today either). Everything in section 2 was measured on 7.0.0-43 only. The repo's other gate kernel, 6.8, was not measured: the kernel tests of step 3 should run there once before a release.

A directory that was removed after its descriptor was opened cannot be bound (M9). The start is refused.

7. The way without any walk (left out)

M8 shows it exists. It would take:

  1. in the shim, one short-lived helper process per descriptor: fchdir(fd), unshare of a user and mount namespace of its own, open_tree(".", OPEN_TREE_CLONE | AT_RECURSIVE), the mount flags by mount_setattr, and the tree's descriptor sent back over a socket;
  2. Heimdall code inside the container's mount namespace, with the right to mount there, that attaches each tree with move_mount. Measured as root: a process that joins the parked init's user and mount namespace can do it. A runner that is not root cannot join them: the init is not dumpable (the same wall shim.rs:695-705 describes for the broker). So that code would be an OCI createContainer hook: the shim's own program, and every starter program, run once more inside the container before pivot_root;
  3. a placeholder mount per bind, so that libcontainer still makes the mount point safely.

It works for directories only (M8). It would give three things the plan does not: no walk at all; a racing rename could not make a start fail; and a bind below a directory that the service's user namespace cannot search (which matters with with_host_ids). It costs several hundred lines of namespace code in sys.rs and shim.rs, two more kinds of short-lived process per start, and a new mode in every starter. Sections 3.1 to 3.3, 3.5, 3.6 and their tests would stay as they are; only section 3.4 changes. It is not in this plan. It is a second change on the coordinator's word.

8. Choices taken in this plan (all six accepted by the coordinator, 2026-11-16)

Version: this branch changes no version number. It lands on main after the gate lane's bump; if 0.6.0 is not published before it lands, it is part of 0.6.0. The CHANGELOG lines go under Unreleased.

  1. The mount is libcontainer's walk of the descriptor's current name plus Heimdall's proof, not the way without a walk (sections 2 and 7).
  2. No new RunError variant; a constant prefix on existing variants (section 3.6).
  3. From<&str> and From<String> beside the three ordered From impls (section 3.1).
  4. The Fd variant exists on unix only (section 3.1).
  5. A descriptor that is not O_PATH is refused, though a plain read-only directory descriptor would work.
  6. The field type of three public structs changes: callers that pass a PathBuf need .into(). The version numbers of heimdall-core (0.5.1) and heimdall-container (0.5.6) are not changed by this branch.

9. Decisions after the audit (2026-11-16)

The audit (AUDIT-BIND-FD-2026-11-16.md beside the lane's report) found no way past the proof with a current shim on ext4, xfs or btrfs, and eight findings. The coordinator's decisions, and where each is in this plan:

Decision What Step Where
D-F1 An older shim must fail BEFORE a container exists: a placeholder source that no process can resolve, replaced only by a shim that knows the feature 2 and 3 3.3, 3.4, 3.5, section 5
D-F1b LISTEN_PID, LISTEN_FDS, LISTEN_FDNAMES removed from the shim's environment; measured first; its own commits with step 3 (it needs the guest) 3.3, section 5
D-F2 A descriptor that is not close-on-exec is refused 2 3.2, section 5
D-F5 The proof also compares owner and mode; the second mount of the same directory is a stated limit 3 section 2, 3.5
D-F6 The proof is claimed only on ext2/3/4, xfs, btrfs and tmpfs with inode64; any other type is refused 2 section 2, 3.2, section 5
D-F7 The constant first in every refusal Heimdall decides, also in "never started", the inside error and a refused restart's status text; libcontainer's own mount failure stays without it 2 and 3 3.6, section 4
D-F8 The pre_exec closure only when there are numbers to keep 2 3.3
D-R1 No duplicate on a number of fds::ALL; the cited lines corrected 2 3.3, section 4
D-R2 The proof's order: fstat of all, close all, stat of all 3 3.5
D-R4 The line ranges of the test rows corrected plan section 4
(3.5) The proof runs as the service's user, without capabilities, under the fixed profile: its calls named and held by a test 3 3.5
M-F3, M-F4, M-F5 Measured in the guest and reported before any code 3 section 5

Not changed: section 7 (the way without a walk) stays out; the audit's remarks R3 and R5 need no change.