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

Main green on Linux: the loopback-only look skips (named) under the Landlock floor instead of failing every check #16954

Merged opened this

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

Merged

fix/look-loopback-test → main 0 commits

  • Merged. fix/look-loopback-test was merged into main as 4d6a134.

Review

Sign in to review this change.
5 files changed +35 −4
docs/features/landlock-floor.md +1
@@ -26,6 +26,7 @@ holds the work instead, with no root and no namespace.
2626 - **Never silent.** The kernel's ABI is probed; rights it lacks are dropped and named. UDP is never
2727 covered before ABI 10 and every record says so.
2828 - `FORGE_LANDLOCK=off` declines the floor on purpose.
29 - 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.
2930
3031 Not covered: network. Crew runs must reach their model's API and checks start servers on loopback
3132 ports, so TCP connect is not confined yet (the plan supports `connect: [ports]`, ABI 4+, for a
src/checks/run_tier.ts +2 −2
@@ -1,5 +1,5 @@
11
2 import { READS_OPEN } from "../sandbox/landlock.ts";
2 import { CHECK_FLOOR_ENV, READS_OPEN } from "../sandbox/landlock.ts";
33 import { probeLandlock } from "../sandbox/landlock_probe.ts";
44 import { cellHides } from "../spawn/hosted-mark.ts";
55 import { forgeApiKey } from "../crew/runner_env.ts";
@@ -285,7 +285,7 @@ async function runTierOnce(lane: LaneState, x: Execution, sample: (green: LentGr
285285 // nested cells, and those never answer in time. Its children run as
286286 // plain processes here — as they do on a runner without bwrap.
287287 FORGE_CELLS: "off",
288 ...(floor === undefined ? {} : { TMPDIR: `${dir}.tmp`, HOME: home }),
288 ...(floor === undefined ? {} : { TMPDIR: `${dir}.tmp`, HOME: home, [CHECK_FLOOR_ENV]: "landlock" }),
289289 });
290290 let ran: Result<void, string>;
291291 const checkLines: string[] = [];
src/sandbox/landlock.ts +7
@@ -74,6 +74,13 @@ export function landlockNote(plan: LandlockPlan): string {
7474 return `landlock ABI ${plan.abi}: ${held.join("; ")}; not enforced: ${gaps.join(", ")}`;
7575 }
7676
77 /**
78 * Set to `landlock` in a check step's environment when the step is held by the Landlock floor alone
79 * (no cell): a test can then tell a namespace it cannot make there (the floor denies writing
80 * `/proc/self/uid_map`) from a prerequisite the runner truly lacks.
81 */
82 export const CHECK_FLOOR_ENV = "FORGE_CHECK_FLOOR";
83
7784 /** What a floor used alone, with no bubblewrap above it, leaves open: said wherever it is named. */
7885 export const READS_OPEN = "reads are not hidden (the whole filesystem stays readable) and tcp is not confined";
7986
test/look-loopback-only-verdict.test.ts +14
@@ -23,6 +23,20 @@ describe("loopback-only look verdict", () => {
2323 expect(verdict("cannot make a network namespace: denied", { FORGE_CHECK: "" }).kind).toBe("skip");
2424 });
2525
26 test("in a check held by the Landlock floor, no user namespace is the floor's doing: it skips, naming it; any other gap still fails", () => {
27 const held = { FORGE_CHECK: "01abc", FORGE_CHECK_FLOOR: "landlock" };
28 const namespace = "cannot make a network namespace: unshare: cannot open /proc/self/uid_map: Permission denied";
29 expect(verdict(namespace, held)).toEqual({
30 kind: "skip",
31 line: `loopback-only look: skipped in the check, held by the Landlock floor, which makes no user namespace: ${namespace}`,
32 });
33 expect(verdict("no Chromium found", held).kind).toBe("fail");
34 expect(verdict("unshare is not installed", held).kind).toBe("fail");
35 // In a check with a cell, or none at all, the same namespace gap fails as before.
36 expect(verdict(namespace, { FORGE_CHECK: "01abc" }).kind).toBe("fail");
37 expect(verdict(namespace, { FORGE_CHECK: "01abc", FORGE_CHECK_FLOOR: "" }).kind).toBe("fail");
38 });
39
2640 test("nothing missing runs, in the check or not", () => {
2741 expect(verdict(undefined, { FORGE_CHECK: "01abc" })).toEqual({ kind: "run" });
2842 expect(verdict(undefined, {})).toEqual({ kind: "run" });
test/look-loopback-only.verdict.ts +11 −2
@@ -3,9 +3,16 @@
33 * the forge's check a missing prerequisite (Chromium, `unshare`, a network
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
6 * green check always means a picture was taken.
6 * 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;
10 * every other gap in the check still fails.
711 */
812 import { findChromium } from "../src/looks/capture.ts";
13 import { CHECK_FLOOR_ENV } from "../src/sandbox/landlock.ts";
14
15 const NO_NAMESPACE = "cannot make a network namespace";
916
1017 export type Verdict =
1118 | { kind: "run" }
@@ -16,6 +23,8 @@ export type Verdict =
1623 export function verdict(missing: string | undefined, env: Record<string, string | undefined>): Verdict {
1724 if (missing === undefined) return { kind: "run" };
1825 const inCheck = (env["FORGE_CHECK"] ?? "") !== "";
26 if (inCheck && env[CHECK_FLOOR_ENV] === "landlock" && missing.startsWith(NO_NAMESPACE))
27 return { kind: "skip", line: `loopback-only look: skipped in the check, held by the Landlock floor, which makes no user namespace: ${missing}` };
1928 return inCheck
2029 ? { kind: "fail", line: `loopback-only look: failed in the check, ${missing}` }
2130 : { kind: "skip", line: `loopback-only look: skipped, ${missing}` };
@@ -31,6 +40,6 @@ export function missingPrerequisite(): string | undefined {
3140 stderr: "pipe",
3241 });
3342 if (probe.exitCode !== 0)
34 return `cannot make a network namespace: ${probe.stderr.toString().trim().slice(0, 200)}`;
43 return `${NO_NAMESPACE}: ${probe.stderr.toString().trim().slice(0, 200)}`;
3544 return undefined;
3645 }

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

Keyboard shortcuts

Docs