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

opened this

Merged 7h 21m ago, live in production

torque/forge:torque/18352-the-loopback-only-look-test-stops-failin → main 0 commits fork

  • Merged. torque/18352-the-loopback-only-look-test-stops-failin was merged into main as be7c1a3.

Review

Sign in to review this change.
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.
3737 - **Never silent.** The kernel's ABI is probed; rights it lacks are dropped and named. UDP is never
3838 covered before ABI 10 and every record says so.
3939 - `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.
4141
4242 Not covered: network. Crew runs must reach their model's API and checks start servers on loopback
4343 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 @@
44 * names itself; outside it the same gap skips with the reason.
55 */
66 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";
88 import { stepFloorEnv } from "../src/sandbox/landlock.ts";
99
1010 describe("loopback-only look verdict", () => {
@@ -75,7 +75,7 @@ describe("loopback-only look verdict", () => {
7575 { gap: "no Chromium", has: { ...all, chromium: false }, outside: "skip", check: "fail", floored: "fail" },
7676 { gap: "uid_map refused making a user namespace", has: { ...all, userNamespace: eacces }, outside: "skip", check: "fail", floored: "skip" },
7777 { 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" },
7979 { gap: "nothing", has: all, outside: "run", check: "run", floored: "run" },
8080 ];
8181 for (const c of cases)
@@ -101,11 +101,26 @@ describe("loopback-only look verdict", () => {
101101 });
102102 });
103103
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
104117 const line = (v: Verdict) => (v.kind === "run" ? "" : v.line);
105118
106119 test("a namespace gap that fails in the check says which floor the step carried and which check", () => {
107120 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]`);
110125 expect(line(verdict("no Chromium found", { FORGE_CHECK: "01abc" }))).toBe("loopback-only look: failed in the check, no Chromium found");
111126 });
test/look-loopback-only.verdict.ts +16
@@ -10,6 +10,12 @@
1010 * one skips, naming the floor; every other gap in the check still fails, and
1111 * so does the same uid_map refusal in a check the floor does not hold
1212 * (#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.
1319 */
1420 import { findChromium } from "../src/looks/capture.ts";
1521 import { CHECK_FLOOR_ENV } from "../src/sandbox/landlock.ts";
@@ -27,6 +33,8 @@ export function verdict(missing: string | undefined, env: Record<string, string
2733 const inCheck = (env["FORGE_CHECK"] ?? "") !== "";
2834 if (inCheck && env[CHECK_FLOOR_ENV] === "landlock" && missing.startsWith(NO_NAMESPACE) && uidMapDenied({ exitCode: 1, stderr: missing }))
2935 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}` };
3038 return inCheck
3139 ? { kind: "fail", line: `loopback-only look: failed in the check, ${missing}${whereLine(missing, env)}` }
3240 : { kind: "skip", line: `loopback-only look: skipped, ${missing}` };
@@ -100,3 +108,11 @@ export function missingPrerequisite(): string | undefined {
100108 export function uidMapDenied(probe: UnshareProbe): boolean {
101109 return probe.exitCode !== 0 && probe.stderr.includes("uid_map") && probe.stderr.includes("Permission denied");
102110 }
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 }

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

Keyboard shortcuts

Docs