@@ -175,3 +175,16 @@ So:
|
||||
sake.
|
||||
- It is touched only to keep the gates that still run it green: the docs stage's dictionary check
|
||||
(`v4/tools/mkdictionary.py`) and `make -C v4 test`. Ruled "Keep the boot.c change", for that reason.
|
||||
|
||||
## Capsules, keys and trust (Captain Bob, 2026-11-20)
|
||||
|
||||
- **Never a throwaway CA or key**, for a test or anything else: "No throwaway. I never would want that,
|
||||
it's a stupid idea." What needs a real signature is shown in CI, with the real key (#139, ruling 4).
|
||||
- **The root CA's private key is on the CI server**, `/var/lib/starshipos-ca/root/`, beside its
|
||||
certificate. Never mount or copy that directory anywhere. The root's public certificate is in the tree,
|
||||
`ci/pki/starshipos-root-ca.pem`.
|
||||
- **Capsules are becoming trains:** the v4 runtime engine (a `.f18a`) towing named blobs as rolling stock.
|
||||
Each blob is signed by its author and hashed, and the capsule's `MANIFEST.md` holds each blob's hash.
|
||||
Bona fide contributors get their own intermediate certificate under the StarshipOS root; casual users get
|
||||
a snakeoil one, told apart by the chain to the root. For ADR step 4
|
||||
(`docs/v4.0.0/plans/2026-11-20-capsule-trust.md`).
|
||||
|
||||
@@ -65,6 +65,9 @@ jobs:
|
||||
run: scripts/nightly.sh accept stick-high
|
||||
- name: Acceptance 32-bit build
|
||||
run: scripts/nightly.sh test-32
|
||||
- name: A signed kernel refuses an unsigned capsule (#139)
|
||||
if: always()
|
||||
run: scripts/nightly.sh capsule-trust
|
||||
|
||||
- name: Images
|
||||
run: scripts/nightly.sh images
|
||||
|
||||
@@ -6847,3 +6847,39 @@ What the record asks beyond POST, each gap put to Captain Bob one at a time:
|
||||
tag"): PR #197 merges once its Acceptance passes, and a tag on `master` marks the line. New work starts
|
||||
after it.
|
||||
|
||||
|
||||
## XLIX. Capsule trust: the intermediate is the anchor, and a signed kernel refuses an unsigned capsule (#139, 2026-11-20)
|
||||
|
||||
### 1. Found
|
||||
|
||||
XLVI left two things open (2026-11-07). The kernel does not check the image's signing certificate against
|
||||
the StarshipOS Root CA. And an unsigned capsule (`CAPSULE_SIG_MISSING`) is only a warning, as ruled on
|
||||
2026-08-26, when CI had no key. Since XLVI, CI signs every build, and the gate into master and a release
|
||||
refuse an unsigned one (#174).
|
||||
|
||||
### 2. Ruled (Captain Bob, 2026-11-20; `docs/v4.0.0/plans/2026-11-20-capsule-trust.md`)
|
||||
|
||||
1. **"Intermediate is the anchor; no root check."** The "StarshipOS Capsule Signing" certificate in the
|
||||
image (XLVI) is what capsules are trusted by. No root key goes in the kernel or in CI. First ruled
|
||||
"verify at boot"; withdrawn when asked where CI would take the root's certificate from: "Actually we
|
||||
decided to include an intermediate certificate in the kernel". On the way it was found that the root's
|
||||
private key is on the CI server beside its certificate, in `/var/lib/starshipos-ca/root/` (mode 700),
|
||||
so mounting that directory into CI jobs, one way to reach the certificate, would have exposed it.
|
||||
2. **"Refuse on signed builds."** A kernel built with the signing key refuses an unsigned capsule. A
|
||||
developer build, without the key, warns and boots.
|
||||
3. **"NO_ROOT_KEY, by build."** A signing certificate missing from the image, or one that cannot be read,
|
||||
is refused on a signed build and warned of on a developer build.
|
||||
4. **"Left to CI."** The boot of a signed kernel with an unsigned capsule is CI's to show, since only CI
|
||||
has the key.
|
||||
|
||||
### 3. Built
|
||||
|
||||
- `capsule_sig_refused()` (`kernel/src/capsule/capsule_sig.c`): the one decision. INVALID always;
|
||||
MISSING and NO_ROOT_KEY on a signed build (`CAPSULE_SIGNED_BUILD`, set by `kernel/Makefile` and
|
||||
`v4/Makefile` exactly when they sign). v4's boot and v3's three births ask it.
|
||||
- `kernel/tests/test_capsule_sig.c`, built twice, unsigned and signed: written first, it did not build
|
||||
without the function. It now passes 4 checks each way.
|
||||
- `scripts/nightly.sh capsule-trust`, a step of `nightly.yml`: a signed build with `v4:centre.4th` left
|
||||
unsigned (`CAPSULE_TEST_UNSIGN`, `scripts/capsule_unsign.py`, for the test only), booted on amd64. It
|
||||
must say `missing (unsigned)` and stop with `POST: FAILED`, and give no prompt. It is not a protocol
|
||||
stage, since a developer has no key. It is first seen in the nightly after this merges.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Capsule trust: no unsigned capsule on a signed build (#139) -- design, for ruling
|
||||
|
||||
Written 2026-11-20. **Nothing here is built.**
|
||||
Written 2026-11-20. **Built 2026-11-20** (section "Built", below; FABRIC-3 XLIX).
|
||||
|
||||
## The rulings (Captain Bob, 2026-11-20, one at a time)
|
||||
|
||||
@@ -52,3 +52,43 @@ Written 2026-11-20. **Nothing here is built.**
|
||||
capsule's signature, and expects the boot refused at that capsule. This container has no key, so that
|
||||
boot is CI's, and the host test and the boots here cover the rest. Asked: that, or a throwaway CA made
|
||||
here, its intermediate standing in for the real one in a test build.
|
||||
|
||||
## Built (2026-11-20)
|
||||
|
||||
As the design, with one difference in step 4: the refused-capsule boot is CI's (ruling 4).
|
||||
`scripts/nightly.sh capsule-trust`, in `nightly.yml`, builds signed with `CAPSULE_TEST_UNSIGN=v4:centre.4th`
|
||||
(`scripts/capsule_unsign.py` takes that one signature out after mkcapsule), and boots amd64 in the session's
|
||||
`unsigned_capsule` mode. It expects the capsule's "missing (unsigned)" line, `POST: FAILED` and no prompt.
|
||||
- **Checked here:** the mode refuses to run without `SIGN_KEY`. The script unsigns only the capsule named,
|
||||
and refuses one that is not signed and one that is not there.
|
||||
- **To see in CI:** the boot itself, in the first nightly after the merge.
|
||||
|
||||
`kernel/tests/test_capsule_sig.c` (and `_signed.c`) was written first and did not build without
|
||||
`capsule_sig_refused`. It now passes 4 checks on each build (`logs/20261120-capsule-trust/`).
|
||||
|
||||
|
||||
## Given for ADR step 4, when capsules carry trains (Captain Bob, 2026-11-20)
|
||||
|
||||
Recorded as given, to design from at step 4 ("Integrity, provenance, and reproducibility checks" and the
|
||||
carrying of artifacts in capsules). Nothing of it is built.
|
||||
|
||||
- **The capsule is a train:** "we are evolving to capsules with the v4 runtime engine towing rolling stock
|
||||
named blobs". The engine is the train's `.f18a`, and the cars are its named blobs (ABI.md, "one train
|
||||
per capsule").
|
||||
- **Each blob is signed by its author and hashed:** "Each blob in the capsule is signed by the author and
|
||||
hashed. The MANIFEST.md inside the capsule will hold each named blobs hash."
|
||||
- **The authors:** "Bonafide contributors will have their own intermediate certificate and 'casual' users
|
||||
get a snakeoil cert." StarshipOS's own trains are signed with the StarshipOS Capsule Signing certificate,
|
||||
as today.
|
||||
- **How they are told apart:** "It can tell the intermediate cert from a snakeoil because it has an
|
||||
intermediate chained to the CA." So at step 4 the kernel checks an author's intermediate against the
|
||||
StarshipOS Root CA's public key, anchored in the kernel. The public certificate is in the tree
|
||||
(`ci/pki/starshipos-root-ca.pem`, with its published hash); the root's private key stays on the server.
|
||||
This is the chain check ruling 1 leaves out for now, for the one system certificate. It comes in with
|
||||
contributors' trains.
|
||||
|
||||
**For step 4's design, to be asked one at a time then:**
|
||||
- whether `MANIFEST.md` is itself a signed blob, so its hashes are trusted;
|
||||
- what placement does with a blob whose hash differs from its manifest's;
|
||||
- what each tier is allowed: StarshipOS, a contributor, a snakeoil user. `contrib_capsule_refused()`
|
||||
(`capsule_birth.c`, FABRIC-2 I.5) is where tiers began.
|
||||
|
||||
+7
-1
@@ -249,6 +249,11 @@ MKARTEMIS_BIN = $(BUILD_DIR)/tools/mkartemis
|
||||
# which boots with a warning per capsule. mkcapsule refuses a key that is not the certificate's.
|
||||
SIGN_KEY ?=
|
||||
SIGN_KEY_ARGS = $(if $(wildcard $(SIGN_KEY)),--sign-key $(SIGN_KEY),)
|
||||
# #139: a kernel whose capsules are signed refuses an unsigned one (capsule_sig.h)
|
||||
CAPSULE_SIGNED_DEF = $(if $(wildcard $(SIGN_KEY)),-DCAPSULE_SIGNED_BUILD=1,)
|
||||
# For the test only (#139, scripts/qemu_session.py unsigned_capsule): a signed build with this one capsule's
|
||||
# signature taken out after mkcapsule, which the kernel must refuse. Never set for a build that ships.
|
||||
CAPSULE_TEST_UNSIGN ?=
|
||||
CAPSULE_GENERATED = $(BUILD_DIR)/capsule_generated.c
|
||||
CAPSULE_GENERATED_OBJ = $(BUILD_DIR)/capsule_generated.o
|
||||
CAPSULE_GENERATED_KOBJ = $(KERNEL_OBJ_DIR)/capsule_generated.o
|
||||
@@ -435,7 +440,7 @@ DOE_SEED ?= 12345
|
||||
# production default (Kconfig.heartbeat's own default n, same decision).
|
||||
$(eval $(call kconfig_bool,EMERGENCY_CONSOLE_ENABLED,0))
|
||||
LOADER_CFLAGS := $(LOADER_BASE_CFLAGS) -I$(KERNEL_SRC)/vm
|
||||
KERNEL_CFLAGS := $(COMMON_CFLAGS) -D__STARKERNEL__ -I$(KERNEL_SRC)/vm
|
||||
KERNEL_CFLAGS := $(COMMON_CFLAGS) -D__STARKERNEL__ -I$(KERNEL_SRC)/vm $(CAPSULE_SIGNED_DEF)
|
||||
|
||||
# Linker flags
|
||||
ifeq ($(ARCH),aarch64)
|
||||
@@ -859,6 +864,7 @@ $(CAPSULE_GENERATED): $(MKCAPSULE_BIN) $(CAPSULE_SRCS)
|
||||
@mkdir -p $(dir $@)
|
||||
@echo " MKCAP $(CAPSULES_DIR) -> $@"
|
||||
@$(MKCAPSULE_BIN) $(SIGN_KEY_ARGS) $(CAPSULES_DIR) $@
|
||||
@$(if $(CAPSULE_TEST_UNSIGN),python3 scripts/capsule_unsign.py $@ $(CAPSULE_TEST_UNSIGN),:)
|
||||
@echo " MKCAP $(CAPSULES_DIR) -> $(CAPSULES_DIR)/BLOCK_MAP.md"
|
||||
@$(MKCAPSULE_BIN) --manifest $(SIGN_KEY_ARGS) $(CAPSULES_DIR) $(CAPSULES_DIR)/BLOCK_MAP.md
|
||||
|
||||
|
||||
@@ -8,6 +8,14 @@
|
||||
* signature/behavior stays untouched; this is a new, additive check
|
||||
* called alongside it, not folded into it.
|
||||
*
|
||||
* Which results are refused is capsule_sig_refused()'s, the one decision every caller asks (#139,
|
||||
* docs/v4.0.0/plans/2026-11-20-capsule-trust.md, ruled 2026-11-20): INVALID on every build; MISSING
|
||||
* and NO_ROOT_KEY as well on a signed build (CAPSULE_SIGNED_BUILD 1, set by kernel/Makefile and
|
||||
* v4/Makefile exactly when they sign the capsules). A developer build, without the key, warns of them
|
||||
* and boots. The anchor is the signing certificate in the image (FABRIC-3 XLVI): it is not checked
|
||||
* against the root CA (ruled 2026-11-20). Corrected 2026-11-20: until then, as below, only INVALID
|
||||
* was refused on any build.
|
||||
*
|
||||
* Enforced ONLY on CAPSULE_SIG_INVALID (2026-08-26, after landing
|
||||
* WARN-only and proving correct on all three architectures against both
|
||||
* a valid and a deliberately-corrupted capsule -- see FABRIC-2.md's
|
||||
@@ -31,6 +39,12 @@
|
||||
* mkcapsule refuses to sign with a key that is not this certificate's. */
|
||||
#define CAPSULE_SIGNING_CERT_NAME "pki:starshipos-intermediate.der"
|
||||
|
||||
/* 1 when the kernel is built with the signing key (kernel/Makefile, v4/Makefile): its capsules are
|
||||
* signed, so an unsigned one, or no certificate to check by, is refused (#139). */
|
||||
#ifndef CAPSULE_SIGNED_BUILD
|
||||
#define CAPSULE_SIGNED_BUILD 0
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
CAPSULE_SIG_OK = 0, /* has_sig=1, and it verifies */
|
||||
CAPSULE_SIG_MISSING, /* has_sig=0 -- not signed at all */
|
||||
@@ -58,4 +72,8 @@ CapsuleSigResult capsule_verify_signature(
|
||||
* capsule_validate_result_str()'s existing shape. */
|
||||
const char *capsule_sig_result_str(CapsuleSigResult result);
|
||||
|
||||
/* 1 if a capsule with this result is refused (#139): INVALID always; MISSING and NO_ROOT_KEY on a
|
||||
* signed build (CAPSULE_SIGNED_BUILD). Every caller asks this rather than testing a result itself. */
|
||||
int capsule_sig_refused(CapsuleSigResult result);
|
||||
|
||||
#endif /* STARKERNEL_CAPSULE_SIG_H */
|
||||
|
||||
@@ -593,7 +593,7 @@ CapsuleRunResult capsule_birth_mama(
|
||||
if (sr != CAPSULE_SIG_OK) {
|
||||
log_message(LOG_WARN, "capsule sig: %s: %s",
|
||||
names[idx].name, capsule_sig_result_str(sr));
|
||||
if (sr == CAPSULE_SIG_INVALID) return CAPSULE_RUN_ERR_INVALID;
|
||||
if (capsule_sig_refused(sr)) return CAPSULE_RUN_ERR_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -674,7 +674,7 @@ CapsuleRunResult capsule_birth_baby(
|
||||
if (sr != CAPSULE_SIG_OK) {
|
||||
log_message(LOG_WARN, "capsule sig: %s: %s",
|
||||
names[idx].name, capsule_sig_result_str(sr));
|
||||
if (sr == CAPSULE_SIG_INVALID) return CAPSULE_RUN_ERR_INVALID;
|
||||
if (capsule_sig_refused(sr)) return CAPSULE_RUN_ERR_INVALID;
|
||||
}
|
||||
/* FABRIC-2.md §I.5: contrib trust tier -- see contrib_capsule_
|
||||
* refused()'s own doc comment. */
|
||||
@@ -940,7 +940,7 @@ CapsuleRunResult capsule_run_experiment(
|
||||
if (sr != CAPSULE_SIG_OK) {
|
||||
log_message(LOG_WARN, "capsule sig: %s: %s",
|
||||
names[idx].name, capsule_sig_result_str(sr));
|
||||
if (sr == CAPSULE_SIG_INVALID) return CAPSULE_RUN_ERR_INVALID;
|
||||
if (capsule_sig_refused(sr)) return CAPSULE_RUN_ERR_INVALID;
|
||||
}
|
||||
/* FABRIC-2.md §I.5: contrib trust tier -- see contrib_capsule_
|
||||
* refused()'s own doc comment. */
|
||||
|
||||
@@ -67,3 +67,14 @@ const char *capsule_sig_result_str(CapsuleSigResult result) {
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
int capsule_sig_refused(CapsuleSigResult result)
|
||||
{
|
||||
switch (result) {
|
||||
case CAPSULE_SIG_OK: return 0;
|
||||
case CAPSULE_SIG_INVALID: return 1;
|
||||
case CAPSULE_SIG_MISSING:
|
||||
case CAPSULE_SIG_NO_ROOT_KEY: return CAPSULE_SIGNED_BUILD;
|
||||
}
|
||||
return 1; /* not a result this code knows: refused */
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ CC ?= cc
|
||||
CFLAGS := -std=c99 -Wall -Wextra -Werror -O2 -g -I$(HERE) -I$(ROOT)/kernel/include \
|
||||
-I$(ROOT)/kernel/include/starkernel -I$(ROOT)/v3/include
|
||||
|
||||
TESTS := test_heartbeat test_gpt test_usb_config test_sk_v4_stop test_sk_v4_slots test_sk_v4_mint test_sk_v4_identity test_heartbeat_export test_ssm_jacquard test_physics_l2 test_stadium_node test_stadium_ops test_stadium_words
|
||||
TESTS := test_capsule_sig test_capsule_sig_signed test_heartbeat test_gpt test_usb_config test_sk_v4_stop test_sk_v4_slots test_sk_v4_mint test_sk_v4_identity test_heartbeat_export test_ssm_jacquard test_physics_l2 test_stadium_node test_stadium_ops test_stadium_words
|
||||
# the one adaptive heartbeat paces itself (plan 2026-11-17-one-adaptive-heartbeat): heartbeat.c, its Q48.16, and the
|
||||
# v4 inference arithmetic its slope provider runs
|
||||
SRC_test_heartbeat := $(ROOT)/kernel/src/heartbeat.c $(ROOT)/kernel/src/math/q48_16.c $(ROOT)/v4/system/inference.c
|
||||
@@ -40,6 +40,10 @@ EXTRA_test_sk_v4_mint := -D__STARKERNEL__ -I$(ROOT)/v4/include
|
||||
SRC_test_sk_v4_slots := $(ROOT)/kernel/src/v4/sk_v4_slots.c
|
||||
SRC_test_sk_v4_stop := $(ROOT)/kernel/src/v4/sk_v4_stop.c
|
||||
SRC_test_gpt := $(ROOT)/kernel/src/gpt.c
|
||||
# #139: the signature results the kernel refuses, on a developer build and a signed one
|
||||
SRC_test_capsule_sig := $(ROOT)/kernel/src/capsule/capsule_sig.c $(addprefix $(ROOT)/kernel/src/crypto/,x509_ed25519.c ed25519.c fe25519.c scalar25519.c sha512.c)
|
||||
SRC_test_capsule_sig_signed := $(SRC_test_capsule_sig)
|
||||
EXTRA_test_capsule_sig_signed := -DCAPSULE_SIGNED_BUILD=1
|
||||
SRC_test_usb_config := $(ROOT)/kernel/src/usb/usb_config.c
|
||||
|
||||
define TEST_RULE
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/* SPDX-License-Identifier: LicenseRef-Starship-1.0
|
||||
* Copyright (c) 2023-2026 Robert A. James
|
||||
*/
|
||||
/* test_capsule_sig.c -- which capsule signature results the kernel refuses (#139;
|
||||
* docs/v4.0.0/plans/2026-11-20-capsule-trust.md, ruled 2026-11-20): capsule_sig_refused(), the one
|
||||
* decision every caller asks. INVALID is refused on every build. A signed build (built with the
|
||||
* signing key, CAPSULE_SIGNED_BUILD 1) also refuses MISSING and NO_ROOT_KEY; a build without the key
|
||||
* warns of them and boots. Built twice: as here, unsigned, and as test_capsule_sig_signed.c.
|
||||
*/
|
||||
#include "harness.h"
|
||||
#include "starkernel/capsule_sig.h"
|
||||
|
||||
#ifndef CAPSULE_SIGNED_BUILD
|
||||
#define CAPSULE_SIGNED_BUILD 0
|
||||
#endif
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("capsule_sig_refused, a %s build\n", CAPSULE_SIGNED_BUILD ? "signed" : "developer (unsigned)");
|
||||
CHECK(!capsule_sig_refused(CAPSULE_SIG_OK), "a good signature is never refused");
|
||||
CHECK(capsule_sig_refused(CAPSULE_SIG_INVALID), "a signature that does not verify is always refused");
|
||||
CHECK(capsule_sig_refused(CAPSULE_SIG_MISSING) == CAPSULE_SIGNED_BUILD,
|
||||
"an unsigned capsule: refused on a signed build, warned of on a developer build");
|
||||
CHECK(capsule_sig_refused(CAPSULE_SIG_NO_ROOT_KEY) == CAPSULE_SIGNED_BUILD,
|
||||
"no signing certificate to check by: refused on a signed build, warned of on a developer build");
|
||||
return DONE();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/* SPDX-License-Identifier: LicenseRef-Starship-1.0
|
||||
* Copyright (c) 2023-2026 Robert A. James
|
||||
*/
|
||||
/* test_capsule_sig_signed.c -- test_capsule_sig.c on a signed build (CAPSULE_SIGNED_BUILD 1, from the
|
||||
* Makefile's EXTRA, as the kernel's build sets it with the signing key). */
|
||||
#include "test_capsule_sig.c"
|
||||
@@ -0,0 +1,11 @@
|
||||
make: Entering directory '/home/user/LithosAnanke/kernel/tests'
|
||||
cc -std=c99 -Wall -Wextra -Werror -O2 -g -I/home/user/LithosAnanke/kernel/tests -I/home/user/LithosAnanke/kernel/include -I/home/user/LithosAnanke/kernel/include/starkernel -I/home/user/LithosAnanke/v3/include /home/user/LithosAnanke/kernel/tests/test_capsule_sig.c /home/user/LithosAnanke/kernel/tests/fakes.c /home/user/LithosAnanke/kernel/src/capsule/capsule_sig.c /home/user/LithosAnanke/kernel/src/crypto/x509_ed25519.c /home/user/LithosAnanke/kernel/src/crypto/ed25519.c /home/user/LithosAnanke/kernel/src/crypto/fe25519.c /home/user/LithosAnanke/kernel/src/crypto/scalar25519.c /home/user/LithosAnanke/kernel/src/crypto/sha512.c -o /home/user/LithosAnanke/build/kernel-tests/test_capsule_sig
|
||||
test_capsule_sig
|
||||
capsule_sig_refused, a developer (unsigned) build
|
||||
4 checks, 0 failures
|
||||
cc -std=c99 -Wall -Wextra -Werror -O2 -g -I/home/user/LithosAnanke/kernel/tests -I/home/user/LithosAnanke/kernel/include -I/home/user/LithosAnanke/kernel/include/starkernel -I/home/user/LithosAnanke/v3/include -DCAPSULE_SIGNED_BUILD=1 /home/user/LithosAnanke/kernel/tests/test_capsule_sig_signed.c /home/user/LithosAnanke/kernel/tests/fakes.c /home/user/LithosAnanke/kernel/src/capsule/capsule_sig.c /home/user/LithosAnanke/kernel/src/crypto/x509_ed25519.c /home/user/LithosAnanke/kernel/src/crypto/ed25519.c /home/user/LithosAnanke/kernel/src/crypto/fe25519.c /home/user/LithosAnanke/kernel/src/crypto/scalar25519.c /home/user/LithosAnanke/kernel/src/crypto/sha512.c -o /home/user/LithosAnanke/build/kernel-tests/test_capsule_sig_signed
|
||||
test_capsule_sig_signed
|
||||
capsule_sig_refused, a signed build
|
||||
4 checks, 0 failures
|
||||
make: Leaving directory '/home/user/LithosAnanke/kernel/tests'
|
||||
exit 0
|
||||
@@ -0,0 +1,14 @@
|
||||
make: Entering directory '/home/user/LithosAnanke/kernel/tests'
|
||||
cc -std=c99 -Wall -Wextra -Werror -O2 -g -I/home/user/LithosAnanke/kernel/tests -I/home/user/LithosAnanke/kernel/include -I/home/user/LithosAnanke/kernel/include/starkernel -I/home/user/LithosAnanke/v3/include /home/user/LithosAnanke/kernel/tests/test_capsule_sig.c /home/user/LithosAnanke/kernel/tests/fakes.c /home/user/LithosAnanke/kernel/src/capsule/capsule_sig.c /home/user/LithosAnanke/kernel/src/crypto/x509_ed25519.c /home/user/LithosAnanke/kernel/src/crypto/ed25519.c /home/user/LithosAnanke/kernel/src/crypto/fe25519.c /home/user/LithosAnanke/kernel/src/crypto/scalar25519.c /home/user/LithosAnanke/kernel/src/crypto/sha512.c -o /home/user/LithosAnanke/build/kernel-tests/test_capsule_sig
|
||||
In file included from /home/user/LithosAnanke/kernel/tests/test_capsule_sig.c:10:
|
||||
/home/user/LithosAnanke/kernel/tests/test_capsule_sig.c: In function 'main':
|
||||
/home/user/LithosAnanke/kernel/tests/test_capsule_sig.c:20:12: error: implicit declaration of function 'capsule_sig_refused'; did you mean 'capsule_sig_result_str'? [-Werror=implicit-function-declaration]
|
||||
20 | CHECK(!capsule_sig_refused(CAPSULE_SIG_OK), "a good signature is never refused");
|
||||
| ^~~~~~~~~~~~~~~~~~~
|
||||
/home/user/LithosAnanke/kernel/tests/harness.h:16:52: note: in definition of macro 'CHECK'
|
||||
16 | #define CHECK(c, ...) do { harness_checks++; if (!(c)) { harness_failures++; \
|
||||
| ^
|
||||
cc1: all warnings being treated as errors
|
||||
make: *** [Makefile:60: /home/user/LithosAnanke/build/kernel-tests/test_capsule_sig] Error 1
|
||||
make: Leaving directory '/home/user/LithosAnanke/kernel/tests'
|
||||
exit 2
|
||||
@@ -0,0 +1,39 @@
|
||||
make: Entering directory '/home/user/LithosAnanke/kernel/tests'
|
||||
test_capsule_sig
|
||||
capsule_sig_refused, a developer (unsigned) build
|
||||
4 checks, 0 failures
|
||||
test_capsule_sig_signed
|
||||
capsule_sig_refused, a signed build
|
||||
4 checks, 0 failures
|
||||
test_heartbeat
|
||||
test_heartbeat
|
||||
13 checks, 0 failures
|
||||
test_gpt
|
||||
12 checks, 0 failures
|
||||
test_usb_config
|
||||
20 checks, 0 failures
|
||||
test_sk_v4_stop
|
||||
2 checks, 0 failures
|
||||
test_sk_v4_slots
|
||||
6 checks, 0 failures
|
||||
test_sk_v4_mint
|
||||
17 checks, 0 failures
|
||||
test_sk_v4_identity
|
||||
10 checks, 0 failures
|
||||
test_heartbeat_export
|
||||
4 checks, 0 failures
|
||||
test_ssm_jacquard
|
||||
7 checks, 0 failures
|
||||
test_physics_l2
|
||||
4 checks, 0 failures
|
||||
test_stadium_node
|
||||
21 checks, 0 failures
|
||||
test_stadium_ops
|
||||
20 checks, 0 failures
|
||||
test_stadium_words
|
||||
9 checks, 0 failures
|
||||
check_cap
|
||||
3 checks, 0 failures
|
||||
all kernel host tests passed
|
||||
make: Leaving directory '/home/user/LithosAnanke/kernel/tests'
|
||||
exit 0
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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
@@ -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
@@ -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)
|
||||
|
||||
|
||||
+2
-1
@@ -190,6 +190,7 @@ RUN_riscv64 ?= qemu-riscv64
|
||||
# as kernel/Makefile: CI sets SIGN_KEY; unset, the capsules are built unsigned
|
||||
SIGN_KEY ?=
|
||||
SIGN_KEY_ARGS = $(if $(wildcard $(SIGN_KEY)),--sign-key $(SIGN_KEY),)
|
||||
CAPSULE_SIGNED_DEF = $(if $(wildcard $(SIGN_KEY)),-DCAPSULE_SIGNED_BUILD=1,) # #139, as kernel/Makefile
|
||||
CRYPTO_SRCS := $(addprefix $(ROOT)/kernel/src/crypto/,ed25519.c fe25519.c scalar25519.c sha512.c)
|
||||
MKCAPSULE_SRCS := $(ROOT)/tools/mkcapsule.c $(ROOT)/tools/pkcs8_ed25519.c $(CRYPTO_SRCS) \
|
||||
$(ROOT)/kernel/src/crypto/x509_ed25519.c
|
||||
@@ -204,7 +205,7 @@ SYSTEM_SRCS := $(HERE)/system/boot.c $(HERE)/system/post.c $(HERE)/system/post
|
||||
$(ROOT)/kernel/src/hash/xxhash64.c $(ROOT)/kernel/src/crypto/x509_ed25519.c $(CRYPTO_SRCS)
|
||||
# The kernel's sources are held to the kernel's warnings, not this model's.
|
||||
SYSTEM_CFLAGS := $(CSTD) -Wall -Wextra $(OPT) -I$(HERE)/include -I$(ROOT)/kernel/include -I$(ROOT)/v3/include \
|
||||
-DV4_CELL_BITS=64 $(HOST_DEFS)
|
||||
-DV4_CELL_BITS=64 $(HOST_DEFS) $(CAPSULE_SIGNED_DEF)
|
||||
|
||||
$(BINDIR)/mkcapsule: $(MKCAPSULE_SRCS)
|
||||
@mkdir -p $(BINDIR)
|
||||
|
||||
+1
-1
@@ -345,7 +345,7 @@ static const uint8_t *open_capsule(const v4_boot *b, const char *name, const Cap
|
||||
sr = capsule_verify_signature(descs, names, capsule_get_signatures(), arena, dir->desc_count, (int)(cap - descs));
|
||||
if (sr != CAPSULE_SIG_OK) {
|
||||
say(b, "V4: capsule "); say(b, name); say(b, " signature: "); say(b, capsule_sig_result_str(sr)); say(b, "\n");
|
||||
if (sr == CAPSULE_SIG_INVALID) return 0;
|
||||
if (capsule_sig_refused(sr)) return 0;
|
||||
}
|
||||
|
||||
p = capsule_get_payload(cap, arena);
|
||||
|
||||
Reference in New Issue
Block a user