capsule trust: a signed kernel refuses an unsigned capsule; the intermediate is the anchor (#139)

capsule_sig_refused(), the one decision at v4's boot and v3's three
births: INVALID always; MISSING and NO_ROOT_KEY on a signed build
(CAPSULE_SIGNED_BUILD, set exactly when the Makefiles sign). A
developer build warns and boots. test_capsule_sig, built both ways,
did not build without it; 4 checks each way now. nightly.sh
capsule-trust, a nightly step: signed, v4:centre.4th left unsigned
(test only), amd64 must refuse it -- CI's, as ruled, since only CI has
the key. No root check, as ruled; the step-4 trust model (blobs signed
by their authors, MANIFEST.md hashes, contributors' intermediates,
snakeoil) recorded as given. FABRIC-3 XLIX. Gates pass, POST 992/992.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
Claude
2026-11-20 22:37:25 +00:00
parent 5425d52cb1
commit 9db364f7c7
20 changed files with 1750 additions and 11 deletions
+20
View File
@@ -0,0 +1,20 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: LicenseRef-Starship-1.0
# Copyright (c) 2023-2026 Robert A. James
"""capsule_unsign.py GENERATED.c NAME -- for the test only (#139): take one capsule's signature out of a
signed build's capsule_generated.c, so that a signed kernel can be seen to refuse an unsigned capsule
(docs/v4.0.0/plans/2026-11-20-capsule-trust.md, ruling 4: "Left to CI"). kernel/Makefile runs it when
CAPSULE_TEST_UNSIGN names a capsule; nothing else does. Fails if NAME is not there, or was not signed."""
import re
import sys
path, name = sys.argv[1], sys.argv[2]
text = open(path).read()
m = re.search(r"/\* \[\d+\] " + re.escape(name) + r" \*/\n(.*?)\.has_sig = (\d) \}", text, re.S)
if not m:
sys.exit("capsule_unsign: %s is not in %s" % (name, path))
if m.group(2) != "1":
sys.exit("capsule_unsign: %s is not signed in %s -- a signed build is needed" % (name, path))
start = m.start(2)
open(path, "w").write(text[:start] + "0" + text[start + 1:])
print("capsule_unsign: %s left unsigned, for the test (#139)" % name)
+9 -1
View File
@@ -19,6 +19,10 @@
# found, and one value (#172 -- it was one distinct value, which two of the three could make).
# scripts/nightly.sh test-32
# make -C v4 test-32: v4 with 32-bit cells, every test (the acceptance's last part).
# scripts/nightly.sh capsule-trust
# A signed build with one capsule's signature taken out (v4:centre.4th), booted on amd64: the kernel
# must refuse it and stop (#139; plan 2026-11-20-capsule-trust.md, ruling 4, "Left to CI"). Needs
# SIGN_KEY, as CI has it; not a protocol stage, since a developer has no key.
# scripts/nightly.sh v4-checks
# make -C v4 sanitize hosted-check (#16; Captain Bob, 2026-11-13: in the nightly): every v4
# test under ASan and UBSan at both widths, and the three hosted builds booting alike --
@@ -90,7 +94,7 @@ DOCS=build/nightly-docs
LITHOS=$(sed -n 's/^LITHOS_VERSION *?= *//p' kernel/Makefile)
VERSION=${NIGHTLY_VERSION:-$LITHOS-SNAPSHOT}
usage() {
echo "Usage: scripts/nightly.sh accept <amd64|aarch64|riscv64|stick-high> | test-32 | v4-checks | proofs | images" >&2
echo "Usage: scripts/nightly.sh accept <amd64|aarch64|riscv64|stick-high> | test-32 | capsule-trust | v4-checks | proofs | images" >&2
echo " | publish <URL> | docs | publish-docs <URL> | gitea-release <tag>" >&2
echo " | protocol [<stage>...] | protocol-report | dict-hash | post-count" >&2
echo " | diagnose [<stage that failed>]" >&2
@@ -192,6 +196,10 @@ dict-hash)
echo "nightly: the three architectures do not agree on dict_hash -- $(tr '\n' ' ' <<<"$distinct")" >&2; exit 1
fi
;;
capsule-trust)
git checkout -q -- disk/zuse-scratch
python3 scripts/qemu_session.py unsigned_capsule amd64 --label nightly-capsule-trust --make "QEMU_DISPLAY=none"
;;
test-32)
need "$OUT/.started"
make --no-print-directory -C v4 test-32 2>&1 | tee "$OUT/test-32.txt"
+21 -2
View File
@@ -189,6 +189,13 @@ elif a.no_zuse or a.mode in NO_ZUSE_MODES:
if a.mode == "v3_keys":
make_args.append(f"ARTDISK={art}") # v3's Artemis is the virtio disk
make_args += shlex.split(a.make)
if a.mode == "unsigned_capsule":
# #139 (plan 2026-11-20-capsule-trust.md, ruling 4: "Left to CI"): a signed build with one capsule's
# signature taken out, which the kernel must refuse -- needs the signing key, as CI has it
if not (os.environ.get("SIGN_KEY") and os.path.isfile(os.environ["SIGN_KEY"])):
print("unsigned_capsule needs SIGN_KEY, the capsule-signing key (CI's CAPSULE_SIGN_KEY)", flush=True)
sys.exit(2)
make_args.append("CAPSULE_TEST_UNSIGN=v4:centre.4th")
if a.mode in ("v3_keys", "stick_v3"):
make_args.append("KERNEL_ARGS=system=v3")
if a.mode == "screen_boot":
@@ -612,8 +619,17 @@ def births():
wait_for(PROMPT, 120, n) and count(r"Stadium conservation: CONSERVED") > c and "ERROR" not in text()[-300:])
check("POST: PASSED", wait_for(r"POST: PASSED", 900))
m = a.mode
if a.mode == "unsigned_capsule":
# the signed kernel refuses the capsule left unsigned, and the boot stops there (#139)
check("a signed kernel refuses an unsigned capsule: v4:centre.4th, missing",
wait_for(r"V4: capsule v4:centre\.4th signature: missing \(unsigned\)", 900))
check("and the boot stops there: POST: FAILED, and no prompt for 60 s",
wait_for(r"POST: FAILED", 120) and not wait_for(ANYPROMPT, 60))
check("no capsule loaded after it", count(r"PARITY:V4_CAPSULE name=v4:centre\.4th") == 0)
m = "unsigned_capsule_checked"
else:
check("POST: PASSED", wait_for(r"POST: PASSED", 900))
m = a.mode
if m == "headless":
check("no ok> for 60 s after POST", not wait_for(ANYPROMPT, 60))
@@ -1360,6 +1376,9 @@ elif m in ("gpt_zuse", "gpt_hotplug", "gpt_foreign", "gpt_bad_crc", "gpt_bad_ent
check("no identity", count(r"Zuse: identity confirmed") == 0)
check(f"not attached (blk: lines {b0} -> {blk_lines()})", blk_lines() == b0)
elif m == "unsigned_capsule_checked":
pass # its checks are above, where POST would have passed
else:
check(f"known mode {m}", False)