Public: anyone can read this; the crew can change it.
The loopback-only look test stops failing checks: the missing prerequisite is named and provided, or the check skips by name #18362
Merged 7h 21m ago, live in production
torque/forge:torque/18352-the-loopback-only-look-test-stops-failin → main 0 commits fork
3 files
changed +36
−5
docs/features/landlock-floor.md +1 −1
| @@ -37,7 +37,7 @@ holds the work instead, with no root and no namespace. | ||
| 37 | 37 | - **Never silent.** The kernel's ABI is probed; rights it lacks are dropped and named. UDP is never |
| 38 | 38 | covered before ABI 10 and every record says so. |
| 39 | 39 | - `FORGE_LANDLOCK=off` declines the floor on purpose. |
| 40 | - 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. | |
| 40 | - 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. A step with no floor flag whose kernel refuses user namespaces (`unshare failed: Operation not permitted`) skips too, naming that refusal (#18352); every other gap fails. | |
| 41 | 41 | |
| 42 | 42 | Not covered: network. Crew runs must reach their model's API and checks start servers on loopback |
| 43 | 43 | ports, so TCP connect is not confined yet (the plan supports `connect: [ports]`, ABI 4+, for a |
test/look-loopback-only-verdict.test.ts +19 −4
| @@ -4,7 +4,7 @@ | ||
| 4 | 4 | * names itself; outside it the same gap skips with the reason. |
| 5 | 5 | */ |
| 6 | 6 | import { describe, expect, test } from "bun:test"; |
| 7 | import { missingFrom, uidMapDenied, verdict, type Prerequisites, type Verdict } from "./look-loopback-only.verdict.ts"; | |
| 7 | import { missingFrom, uidMapDenied, userNamespaceRefused, verdict, type Prerequisites, type Verdict } from "./look-loopback-only.verdict.ts"; | |
| 8 | 8 | import { stepFloorEnv } from "../src/sandbox/landlock.ts"; |
| 9 | 9 | |
| 10 | 10 | describe("loopback-only look verdict", () => { |
| @@ -75,7 +75,7 @@ describe("loopback-only look verdict", () => { | ||
| 75 | 75 | { gap: "no Chromium", has: { ...all, chromium: false }, outside: "skip", check: "fail", floored: "fail" }, |
| 76 | 76 | { gap: "uid_map refused making a user namespace", has: { ...all, userNamespace: eacces }, outside: "skip", check: "fail", floored: "skip" }, |
| 77 | 77 | { gap: "uid_map refused making a network namespace", has: { ...all, networkNamespace: eacces }, outside: "skip", check: "fail", floored: "skip" }, |
| 78 | { gap: "user namespaces not permitted at all", has: { ...all, userNamespace: eperm }, outside: "skip", check: "fail", floored: "fail" }, | |
| 78 | { gap: "user namespaces not permitted at all", has: { ...all, userNamespace: eperm }, outside: "skip", check: "skip", floored: "fail" }, | |
| 79 | 79 | { gap: "nothing", has: all, outside: "run", check: "run", floored: "run" }, |
| 80 | 80 | ]; |
| 81 | 81 | for (const c of cases) |
| @@ -101,11 +101,26 @@ describe("loopback-only look verdict", () => { | ||
| 101 | 101 | }); |
| 102 | 102 | }); |
| 103 | 103 | |
| 104 | test("a runner whose kernel refuses user namespaces (EPERM, no floor) skips in the check, naming it (#18352)", () => { | |
| 105 | const gap = "cannot make a network namespace: unshare: unshare failed: Operation not permitted"; | |
| 106 | expect(verdict(gap, { FORGE_CHECK: "01abc" })).toEqual({ | |
| 107 | kind: "skip", | |
| 108 | line: `loopback-only look: skipped in the check, the runner's kernel refuses user namespaces (no floor flag, check 01abc): ${gap}`, | |
| 109 | }); | |
| 110 | expect(verdict(gap, { FORGE_CHECK: "01abc", FORGE_CHECK_FLOOR: "landlock" }).kind).toBe("fail"); | |
| 111 | expect(verdict("no Chromium found", { FORGE_CHECK: "01abc" }).kind).toBe("fail"); | |
| 112 | expect(userNamespaceRefused({ exitCode: 1, stderr: "unshare: unshare failed: Operation not permitted" })).toBe(true); | |
| 113 | expect(userNamespaceRefused({ exitCode: 1, stderr: "unshare: unshare failed: Invalid argument" })).toBe(false); | |
| 114 | expect(userNamespaceRefused({ exitCode: 0, stderr: "" })).toBe(false); | |
| 115 | }); | |
| 116 | ||
| 104 | 117 | const line = (v: Verdict) => (v.kind === "run" ? "" : v.line); |
| 105 | 118 | |
| 106 | 119 | test("a namespace gap that fails in the check says which floor the step carried and which check", () => { |
| 107 | 120 | const gap = "cannot make a network namespace: unshare: unshare failed: Operation not permitted"; |
| 108 | expect(line(verdict(gap, { FORGE_CHECK: "01abc" }))).toBe(`loopback-only look: failed in the check, ${gap} [FORGE_CHECK_FLOOR=unset, check 01abc]`); | |
| 109 | expect(line(verdict(gap, { FORGE_CHECK: "01abc", FORGE_CHECK_FLOOR: "landlock" }))).toContain("[FORGE_CHECK_FLOOR=landlock, check 01abc]"); | |
| 121 | expect(line(verdict(gap, { FORGE_CHECK: "01abc", FORGE_CHECK_FLOOR: "landlock" }))).toBe(`loopback-only look: failed in the check, ${gap} [FORGE_CHECK_FLOOR=landlock, check 01abc]`); | |
| 122 | // Another namespace failure, with no floor, still fails and names where. | |
| 123 | const other = "cannot make a network namespace: unshare: unshare failed: Invalid argument"; | |
| 124 | expect(line(verdict(other, { FORGE_CHECK: "01abc" }))).toBe(`loopback-only look: failed in the check, ${other} [FORGE_CHECK_FLOOR=unset, check 01abc]`); | |
| 110 | 125 | expect(line(verdict("no Chromium found", { FORGE_CHECK: "01abc" }))).toBe("loopback-only look: failed in the check, no Chromium found"); |
| 111 | 126 | }); |
test/look-loopback-only.verdict.ts +16
| @@ -10,6 +10,12 @@ | ||
| 10 | 10 | * one skips, naming the floor; every other gap in the check still fails, and |
| 11 | 11 | * so does the same uid_map refusal in a check the floor does not hold |
| 12 | 12 | * (#17522): every probe reaches `verdict`, none decides on its own. |
| 13 | * | |
| 14 | * The other gap seen in the check (#18352) is a runner whose kernel refuses | |
| 15 | * user namespaces outright: `unshare: unshare failed: Operation not permitted` | |
| 16 | * (EPERM, not the floor's uid_map EACCES) in a step with no floor flag. It | |
| 17 | * is the runner's policy, never the pull's, so it skips, naming the refusal; | |
| 18 | * the same refusal under the floor, and every other gap, still fails. | |
| 13 | 19 | */ |
| 14 | 20 | import { findChromium } from "../src/looks/capture.ts"; |
| 15 | 21 | import { CHECK_FLOOR_ENV } from "../src/sandbox/landlock.ts"; |
| @@ -27,6 +33,8 @@ export function verdict(missing: string | undefined, env: Record<string, string | ||
| 27 | 33 | const inCheck = (env["FORGE_CHECK"] ?? "") !== ""; |
| 28 | 34 | if (inCheck && env[CHECK_FLOOR_ENV] === "landlock" && missing.startsWith(NO_NAMESPACE) && uidMapDenied({ exitCode: 1, stderr: missing })) |
| 29 | 35 | return { kind: "skip", line: `loopback-only look: skipped in the check, held by the Landlock floor, which makes no user namespace: ${missing}` }; |
| 36 | if (inCheck && (env[CHECK_FLOOR_ENV] ?? "") === "" && missing.startsWith(NO_NAMESPACE) && userNamespaceRefused({ exitCode: 1, stderr: missing })) | |
| 37 | return { kind: "skip", line: `loopback-only look: skipped in the check, the runner's kernel refuses user namespaces (no floor flag, check ${env["FORGE_CHECK"]}): ${missing}` }; | |
| 30 | 38 | return inCheck |
| 31 | 39 | ? { kind: "fail", line: `loopback-only look: failed in the check, ${missing}${whereLine(missing, env)}` } |
| 32 | 40 | : { kind: "skip", line: `loopback-only look: skipped, ${missing}` }; |
| @@ -100,3 +108,11 @@ export function missingPrerequisite(): string | undefined { | ||
| 100 | 108 | export function uidMapDenied(probe: UnshareProbe): boolean { |
| 101 | 109 | return probe.exitCode !== 0 && probe.stderr.includes("uid_map") && probe.stderr.includes("Permission denied"); |
| 102 | 110 | } |
| 111 | ||
| 112 | /** | |
| 113 | * The runner's own refusal (#18352): `unshare` exits non-zero with "unshare failed" and "Operation | |
| 114 | * not permitted" when the kernel or its policy allows no user namespace. True only for that. | |
| 115 | */ | |
| 116 | export function userNamespaceRefused(probe: UnshareProbe): boolean { | |
| 117 | return probe.exitCode !== 0 && probe.stderr.includes("unshare failed") && probe.stderr.includes("Operation not permitted"); | |
| 118 | } |
new above
offline