Public: anyone can read this; the crew can change it.

A check step behind Landlock stacked under its cell says so too, on the forge and on a runner #16996

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

fix/look-floor-in-cells → main 0 commits

  • Merged. fix/look-floor-in-cells was merged into main as 0bd9528.

Review

Sign in to review this change.
7 files changed +39 −10
docs/features/landlock-floor.md +1 −1
@@ -35,7 +35,7 @@ holds the work instead, with no root and no namespace.
3535 - **Never silent.** The kernel's ABI is probed; rights it lacks are dropped and named. UDP is never
3636 covered before ABI 10 and every record says so.
3737 - `FORGE_LANDLOCK=off` declines the floor on purpose.
38 - A no-cell check step carries `FORGE_CHECK_FLOOR=landlock`. Under the floor no user namespace can be made (writing `/proc/self/uid_map` is denied), so the loopback-only look test skips there and names the floor, rather than failing as a missing prerequisite.
38 - A check step behind Landlock, alone or stacked under its cell, carries `FORGE_CHECK_FLOOR=landlock`. Under the floor no user namespace can be made (writing `/proc/self/uid_map` is denied), so the loopback-only look test skips there and names the floor, rather than failing as a missing prerequisite.
3939
4040 Not covered: network. Crew runs must reach their model's API and checks start servers on loopback
4141 ports, so TCP connect is not confined yet (the plan supports `connect: [ports]`, ABI 4+, for a
src/apps/contain.ts +3
@@ -484,6 +484,9 @@ async function probe(): Promise<{ ok: true } | { ok: false; reason: string }> {
484484 /** The Landlock floor stacked under every cell on this host, once `cellsAvailable` has asked. */
485485 let cellFloor: Extract<LandlockProbe, { ok: true }> | undefined;
486486
487 /** Whether a cell on this host runs its command behind the Landlock floor (`floored`). */
488 export const cellsFloored = (): boolean => cellFloor !== undefined;
489
487490 /**
488491 * The command a cell runs, behind Landlock where the kernel holds it: read-only outside what the
489492 * cell may write, signals and abstract sockets scoped. TCP is left to the cell's own network
src/checks/run_tier.ts +6 −3
@@ -1,6 +1,6 @@
11
22 import { checkFloor } from "./floor.ts";
3 import { CHECK_FLOOR_ENV, READS_PARTLY } from "../sandbox/landlock.ts";
3 import { READS_PARTLY, stepFloorEnv } from "../sandbox/landlock.ts";
44 import { probeLandlock } from "../sandbox/landlock_probe.ts";
55 import { cellHides } from "../spawn/hosted-mark.ts";
66 import { forgeApiKey } from "../crew/runner_env.ts";
@@ -29,7 +29,7 @@ import { BASE_GATE_FILE, runsAsBaseGate, withBaseGate } from "./base_gate.ts";
2929 import { childEnv, killedStep, runStep } from "../apps/process.ts";
3030 import { noteReached } from "../apps/egress_report.ts";
3131 import { capacityEnv, checkShardCpus, egressSetting, shardsInForce, shardsLine } from "../core/capacity.ts";
32 import { cellsAvailable, origin, limitWarnings, resolveLimits, STEP_HOSTS, stoppedForCpu, type CellSpec } from "../apps/contain.ts";
32 import { cellsAvailable, cellsFloored, origin, limitWarnings, resolveLimits, STEP_HOSTS, stoppedForCpu, type CellSpec } from "../apps/contain.ts";
3333 import { summariseCheckFailure } from "./summary.ts";
3434 import { withPlan } from "./plan_line.ts";
3535 import { err, type Result } from "../kernel/result.ts";
@@ -284,7 +284,10 @@ async function runTierOnce(lane: LaneState, x: Execution, sample: (green: LentGr
284284 // nested cells, and those never answer in time. Its children run as
285285 // plain processes here — as they do on a runner without bwrap.
286286 FORGE_CELLS: "off",
287 ...(floor === undefined ? {} : { TMPDIR: `${dir}.tmp`, HOME: home, [CHECK_FLOOR_ENV]: "landlock" }),
287 ...(floor === undefined ? {} : { TMPDIR: `${dir}.tmp`, HOME: home }),
288 // The step is behind Landlock alone (no cell) or stacked under its cell (`floored`): either
289 // way it can make no user namespace, and a test may say so rather than blame the runner.
290 ...stepFloorEnv({ alone: floor !== undefined, inCell: cell !== undefined, cellsFloored: cell?.floor !== undefined || cellsFloored() }),
288291 });
289292 let ran: Result<void, string>;
290293 const checkLines: string[] = [];
src/runner/main.ts +5
@@ -21,6 +21,7 @@
2121 * FORGE_CELLS `off`: never use cells here; jobs that require one go back to the forge
2222 */
2323
24 import { stepFloorEnv } from "../sandbox/landlock.ts";
2425 import { existsSync, mkdirSync } from "node:fs";
2526 import { rm } from "node:fs/promises";
2627 import { tmpdir } from "node:os";
@@ -28,6 +29,7 @@ import { join } from "node:path";
2829 import { exportTree } from "../apps/checkout.ts";
2930 import {
3031 cellsAvailable,
32 cellsFloored,
3133 resolveLimits,
3234 type CellSpec,
3335 } from "../apps/contain.ts";
@@ -321,6 +323,9 @@ export async function runRunner(options: RunnerOptions): Promise<void> {
321323 ...checkVars(job.env),
322324 FORGE_CELL_CPUS: String(limits.cpus),
323325 ...scratchEnv(cell === undefined ? undefined : home),
326 // The cell runs its command behind the Landlock floor (`floored`) where this kernel has
327 // it: the step can make no user namespace, and a test may say so (#16888).
328 ...stepFloorEnv({ alone: false, inCell: cell !== undefined, cellsFloored: cellsFloored() }),
324329 });
325330 const timeoutMs =
326331 Math.min(Math.max(Number(job.timeoutS) || 900, 1), 7_200) * 1000;
src/sandbox/landlock.ts +11 −3
@@ -162,12 +162,20 @@ export function landlockNote(plan: LandlockPlan): string {
162162 }
163163
164164 /**
165 * Set to `landlock` in a check step's environment when the step is held by the Landlock floor alone
166 * (no cell): a test can then tell a namespace it cannot make there (the floor denies writing
167 * `/proc/self/uid_map`) from a prerequisite the runner truly lacks.
165 * Set to `landlock` in a check step's environment when the step runs behind the Landlock floor,
166 * alone (no cell) or stacked under its cell: a test can then tell a namespace it cannot make there
167 * (the floor denies writing `/proc/self/uid_map`) from a prerequisite the runner truly lacks.
168168 */
169169 export const CHECK_FLOOR_ENV = "FORGE_CHECK_FLOOR";
170170
171 /**
172 * What a check step's environment says of the floor: `landlock` when the step runs behind it, held
173 * by it alone (no cell) or stacked under a cell whose host floors its cells; nothing otherwise.
174 */
175 export function stepFloorEnv(step: { readonly alone: boolean; readonly inCell: boolean; readonly cellsFloored: boolean }): Record<string, string> {
176 return step.alone || (step.inCell && step.cellsFloored) ? { [CHECK_FLOOR_ENV]: "landlock" } : {};
177 }
178
171179 /** What a floor used alone, with no bubblewrap above it, leaves open: said wherever it is named. */
172180 export const READS_OPEN = "reads are not hidden (the whole filesystem stays readable) and tcp is not confined";
173181
test/look-loopback-only-verdict.test.ts +10
@@ -5,6 +5,7 @@
55 */
66 import { describe, expect, test } from "bun:test";
77 import { verdict } from "./look-loopback-only.verdict.ts";
8 import { stepFloorEnv } from "../src/sandbox/landlock.ts";
89
910 describe("loopback-only look verdict", () => {
1011 test("in the check, a missing prerequisite fails and names it", () => {
@@ -37,6 +38,15 @@ describe("loopback-only look verdict", () => {
3738 expect(verdict(namespace, { FORGE_CHECK: "01abc", FORGE_CHECK_FLOOR: "" }).kind).toBe("fail");
3839 });
3940
41 test("a step behind the floor is told so, alone or stacked under its cell, on the forge and on a runner", () => {
42 expect(stepFloorEnv({ alone: true, inCell: false, cellsFloored: false })).toEqual({ FORGE_CHECK_FLOOR: "landlock" });
43 // A runner's or a forge's cell whose host floors its cells: what the verify lane runs in.
44 expect(stepFloorEnv({ alone: false, inCell: true, cellsFloored: true })).toEqual({ FORGE_CHECK_FLOOR: "landlock" });
45 expect(stepFloorEnv({ alone: false, inCell: true, cellsFloored: false })).toEqual({});
46 // Uncontained: no floor, so a namespace the runner cannot make is the runner's gap and fails.
47 expect(stepFloorEnv({ alone: false, inCell: false, cellsFloored: true })).toEqual({});
48 });
49
4050 test("nothing missing runs, in the check or not", () => {
4151 expect(verdict(undefined, { FORGE_CHECK: "01abc" })).toEqual({ kind: "run" });
4252 expect(verdict(undefined, {})).toEqual({ kind: "run" });
test/look-loopback-only.verdict.ts +3 −3
@@ -4,9 +4,9 @@
44 * namespace) is a skip that says why; inside it — the check sets
55 * `FORGE_CHECK` to its run id — the same gap is a failure that names it, so a
66 * green check always means a picture was taken. One gap is the check's own
7 * doing, not the runner's: a step held by the Landlock floor alone (#16888,
8 * `FORGE_CHECK_FLOOR=landlock`) cannot write `/proc/self/uid_map`, so no user
9 * namespace can be made there by design. That one skips, naming the floor;
7 * doing, not the runner's: a step behind the Landlock floor, alone or stacked
8 * under its cell (#16888, `FORGE_CHECK_FLOOR=landlock`), cannot write
9 * `/proc/self/uid_map`, so no user namespace can be made there by design. That one skips, naming the floor;
1010 * every other gap in the check still fails.
1111 */
1212 import { findChromium } from "../src/looks/capture.ts";

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs