Skip to content

eBPF-based security platform

testing: check live config updates and interrupted updates

KP Singh4ba83234fa2f
diff --git a/.gitignore b/.gitignore
index b92ba99c..cf857309 100644
--- a/.gitignore
+++ b/.gitignore
@@ -46,6 +46,7 @@
/testing/helper/*
/testing/upatch/kernel-obs/exec/exec-paths
!/testing/helper/*.c
+!/testing/helper/*.h
!/testing/helper/otel-mock.py
!/testing/helper/otel-s3-mock.py
!/testing/helper/test-bpm-key.py
diff --git a/Makefile.shirudo b/Makefile.shirudo
index 8f2b6d94..5e52cf19 100644
--- a/Makefile.shirudo
+++ b/Makefile.shirudo
@@ -552,13 +552,32 @@ build/verity-tests/shirudo-policy-probe: \
-Iinclude -D_GNU_SOURCE -static -o $@ $<
-verity-test-helpers: $(VERITY_TEST_HELPERS)
+ifeq ($(PROFILE),target)
+VERITY_TEST_LIBS := $(TARGET_TLS_STATIC_LINK_LIBS) \
+ $(TARGET_STATIC_RUNTIME_LINK_LIBS) \
+ -Wl,-Bdynamic $(TARGET_TLS_DYNAMIC_LINK_LIBS)
+else
+VERITY_TEST_LIBS := $(DYNAMIC_LIBS)
+endif
+
+build/verity-tests/shirudo-image-fault: testing/helper/image-fault.c \
+ testing/helper/image-fault.h \
+ $(MAIN_OBJ) $(BUILTIN_OBJS) $(UTIL_OBJS) $(VERSION_OBJ) $(LIBBPF_A)
+ @printf ' CC $@\n'
+ $(Q)mkdir -p $(dir $@)
+ $(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(RPATH_LDFLAGS) -o $@ \
+ $(filter-out %.h,$^) \
+ -Wl,--wrap=main,--wrap=Esys_PCR_Extend \
+ $(STATIC_LIBS) $(VERITY_TEST_LIBS)
+
+verity-test-helpers: $(VERITY_TEST_HELPERS) build/verity-tests/shirudo-image-fault
# Compiled test helpers (also usable as fuzz entry points).
TEST_HELPERS := $(VERITY_TEST_HELPERS) \
testing/helper/test-image-cli \
testing/helper/test-image-config \
testing/helper/test-config-image \
+ testing/helper/test-config-update \
testing/helper/test-image-keys \
testing/helper/test-json-parser \
testing/helper/test-string \
@@ -742,6 +761,11 @@ testing/helper/test-config-image: testing/helper/test-config-image.c \
@printf ' CC $@\n'
$(Q)$(CC) $(CFLAGS) -o $@ $^ -lcrypto -lssl
+testing/helper/test-config-update: testing/helper/test-config-update.c \
+ util/config_update.o util/config_measure.o util/config_image.o \
+ $(REGISTER_OBJS)
+ @printf ' CC $@\n'
+ $(Q)$(CC) $(CFLAGS) -o $@ $^ $(REGISTER_LIBS)
testing/helper/test-image-keys: testing/helper/test-image-keys.c \
diff --git a/contrib/verity-vm-bundle.sh b/contrib/verity-vm-bundle.sh
index e5b23134..6bf2c139 100755
--- a/contrib/verity-vm-bundle.sh
+++ b/contrib/verity-vm-bundle.sh
@@ -25,6 +25,7 @@ EOF
--config-cert "$keys/cert.der" --output "$bundle/verity/runtime" \
--keys-dir "$keys" --builder "$source_dir/tools/shirudo-build/shirudo-build" \
--extra-binary "$source_dir/build/verity-tests/shirudo-policy-probe" \
+ --extra-binary "$source_dir/build/verity-tests/shirudo-image-fault" \
--unit-output "$bundle/verity/runtime-service.conf" \
>"$bundle/verity/runtime.root"
printf 'runtime.image = /var/lib/shirudo/images/runtime\nruntime.root_hash = %s\n' \
diff --git a/testing/helper/image-fault.c b/testing/helper/image-fault.c
new file mode 100644
index 00000000..75a16041
--- /dev/null
+++ b/testing/helper/image-fault.c
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: BSD-2-Clause
+/* Copyright (c) 2026 Authors of shirudo */
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "image-fault.h"
+
+int __wrap_main(int argc, const char **argv)
+{
+ if (argc != 4 || strcmp(argv[1], "image") ||
+ strcmp(argv[2], "update")) {
+ fprintf(stderr, "usage: shirudo-image-fault "
+ "image update <prefix>\n");
+ return 2;
+ }
+ return __real_main(argc, argv);
+}
+
+TSS2_RC __wrap_Esys_PCR_Extend(ESYS_CONTEXT *context, ESYS_TR pcr,
+ ESYS_TR first, ESYS_TR second, ESYS_TR third,
+ const TPML_DIGEST_VALUES *digests)
+{
+ TSS2_RC rc;
+
+ rc = __real_Esys_PCR_Extend(context, pcr, first, second, third,
+ digests);
+ if (!rc)
+ _exit(99);
+ return rc;
+}
diff --git a/testing/helper/image-fault.h b/testing/helper/image-fault.h
new file mode 100644
index 00000000..cbeb3147
--- /dev/null
+++ b/testing/helper/image-fault.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+/* Copyright (c) 2026 Authors of shirudo */
+
+#ifndef SHIRUDO_TEST_IMAGE_FAULT_H
+#define SHIRUDO_TEST_IMAGE_FAULT_H
+
+#include <tss2/tss2_esys.h>
+
+int __real_main(int argc, const char **argv);
+int __wrap_main(int argc, const char **argv);
+TSS2_RC __real_Esys_PCR_Extend(ESYS_CONTEXT *context, ESYS_TR pcr,
+ ESYS_TR first, ESYS_TR second, ESYS_TR third,
+ const TPML_DIGEST_VALUES *digests);
+TSS2_RC __wrap_Esys_PCR_Extend(ESYS_CONTEXT *context, ESYS_TR pcr,
+ ESYS_TR first, ESYS_TR second, ESYS_TR third,
+ const TPML_DIGEST_VALUES *digests);
+
+#endif /* SHIRUDO_TEST_IMAGE_FAULT_H */
diff --git a/testing/helper/test-config-update.c b/testing/helper/test-config-update.c
new file mode 100644
index 00000000..4eb2213a
--- /dev/null
+++ b/testing/helper/test-config-update.c
@@ -0,0 +1,363 @@
+// SPDX-License-Identifier: BSD-2-Clause
+/* Copyright (c) 2026 Authors of shirudo */
+
+#include <shirudo/misc.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "util/chain.h"
+#include "util/config_measure.h"
+#include "util/config_update.h"
+#include "util/hex.h"
+#include "util/io.h"
+#include "util/tpm.h"
+
+struct simulated_tpm {
+ __u8 value[32];
+ __u8 active[32];
+ __u32 reset_count;
+ __u32 restart_count;
+ __u32 extends;
+ __u32 prepares;
+ __u32 activations;
+ __u32 partial;
+};
+
+struct test_context {
+ struct shirudo_config_update *update;
+ struct simulated_tpm sim;
+ struct shirudo_tpm *tpm;
+ const char *directory;
+};
+
+static int simulator_save(struct test_context *ctx)
+{
+ char path[PATH_MAX], temporary[PATH_MAX];
+ int fd, dir, rc;
+
+ if (snprintf(path, sizeof(path), "%s/simulator", ctx->directory) >=
+ (int)sizeof(path) ||
+ snprintf(temporary, sizeof(temporary), "%s/simulator.tmp",
+ ctx->directory) >= (int)sizeof(temporary))
+ return -ENAMETOOLONG;
+ fd = open(temporary,
+ O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NOFOLLOW, 0600);
+ if (fd < 0)
+ return -errno;
+ rc = write_complete(fd, &ctx->sim, sizeof(ctx->sim));
+ if (!rc && fsync(fd))
+ rc = -errno;
+ if (close(fd) && !rc)
+ rc = -errno;
+ if (!rc && rename(temporary, path))
+ rc = -errno;
+ if (rc)
+ return rc;
+ dir = open(ctx->directory, O_RDONLY | O_DIRECTORY | O_CLOEXEC);
+ if (dir < 0)
+ return -errno;
+ rc = fsync(dir) ? -errno : 0;
+ close(dir);
+ return rc;
+}
+
+static int simulator_load(struct test_context *ctx)
+{
+ char path[PATH_MAX];
+ ssize_t got;
+ int fd;
+
+ if (snprintf(path, sizeof(path), "%s/simulator", ctx->directory) >=
+ (int)sizeof(path))
+ return -ENAMETOOLONG;
+ fd = open(path, O_RDONLY | O_CLOEXEC | O_NOFOLLOW);
+ if (fd < 0) {
+ if (errno != ENOENT)
+ return -errno;
+ ctx->sim.reset_count = 1;
+ return 0;
+ }
+ got = read(fd, &ctx->sim, sizeof(ctx->sim));
+ close(fd);
+ return got == sizeof(ctx->sim) ? 0 : -EIO;
+}
+
+static int test_boot_identity(void *opaque, __u32 *reset, __u32 *restart)
+{
+ struct test_context *ctx = opaque;
+
+ if (ctx->tpm)
+ return shirudo_tpm_boot_identity(ctx->tpm, reset, restart);
+ *reset = ctx->sim.reset_count;
+ *restart = ctx->sim.restart_count;
+ return 0;
+}
+
+static int test_pcr_read(void *opaque, __u32 pcr, __u8 out[32])
+{
+ struct test_context *ctx = opaque;
+
+ if (getenv("SHIRUDO_TEST_CONFIG_READ_FAIL"))
+ return -EIO;
+ if (ctx->tpm)
+ return tpm_pcr_read(ctx->tpm, pcr, out);
+ memcpy(out, ctx->sim.value, 32);
+ return 0;
+}
+
+static int test_pcr_extend(void *opaque, __u32 pcr,
+ const __u8 event[32])
+{
+ const char *mode = getenv("SHIRUDO_TEST_CONFIG_EXTEND");
+ struct test_context *ctx = opaque;
+ __u8 wrong[32] = { 1 };
+ int rc;
+
+ ctx->sim.extends++;
+ rc = simulator_save(ctx);
+ if (rc)
+ return rc;
+ if (mode && !strcmp(mode, "before"))
+ return -EIO;
+ if (mode && !strcmp(mode, "drift"))
+ event = wrong;
+ if (ctx->tpm)
+ rc = tpm_pcr_extend(ctx->tpm, pcr, event);
+ else
+ rc = shirudo_chain_fold_checked(ctx->sim.value, event);
+ if (!rc)
+ rc = simulator_save(ctx);
+ if (!rc && mode && !strcmp(mode, "ambiguous"))
+ return -ETIMEDOUT;
+ return rc;
+}
+
+static int test_prepare(void *opaque,
+ const struct shirudo_config_update_target *target)
+{
+ struct test_context *ctx = opaque;
+ size_t i;
+ int rc;
+
+ ctx->sim.prepares++;
+ rc = simulator_save(ctx);
+ if (rc)
+ return rc;
+ if (getenv("SHIRUDO_TEST_CONFIG_PREPARE_FAIL"))
+ return -EKEYREJECTED;
+ if (strlen(target->prefix) != sizeof("/verified/config-A") - 1 ||
+ strncmp(target->prefix, "/verified/config-",
+ sizeof("/verified/config-") - 1))
+ return -EKEYREJECTED;
+ for (i = 0; i < sizeof(target->root_hash); i++)
+ if (target->root_hash[i] !=
+ (__u8)target->prefix[strlen(target->prefix) - 1])
+ return -EKEYREJECTED;
+ return 0;
+}
+
+static int test_activate(void *opaque,
+ const struct shirudo_config_update_target *target)
+{
+ struct shirudo_config_update_record record;
+ struct test_context *ctx = opaque;
+ __u8 live[32];
+ int rc;
+
+ rc = shirudo_config_update_read(ctx->update, &record);
+ if (!rc)
+ rc = test_pcr_read(ctx, record.pcr, live);
+ if (rc)
+ return rc;
+ if (!record.pending ||
+ memcmp(target->root_hash, record.target.root_hash, 32))
+ return -EUCLEAN;
+ ctx->sim.activations++;
+ ctx->sim.partial = target->prefix[strlen(target->prefix) - 1];
+ rc = simulator_save(ctx);
+ if (rc)
+ return rc;
+ if (getenv("SHIRUDO_TEST_CONFIG_ACTIVATE_FAIL"))
+ return -EIO;
+ memcpy(ctx->sim.active, target->root_hash, sizeof(ctx->sim.active));
+ ctx->sim.partial = 0;
+ return simulator_save(ctx);
+}
+
+static int test_seal(void *opaque, int fd)
+{
+ (void)opaque;
+ (void)fd;
+ return getenv("SHIRUDO_TEST_CONFIG_SEAL_FAIL") ? -EPERM : 0;
+}
+
+static int test_checkpoint(void *opaque,
+ enum shirudo_config_update_checkpoint checkpoint)
+{
+ const char *crash = getenv("SHIRUDO_TEST_CONFIG_CRASH");
+ const char *fail = getenv("SHIRUDO_TEST_CONFIG_FAIL");
+
+ (void)opaque;
+ if (crash && strtoul(crash, NULL, 10) == checkpoint)
+ _exit(99);
+ if (fail && strtoul(fail, NULL, 10) == checkpoint)
+ return -ECANCELED;
+ return 0;
+}
+
+static const struct shirudo_config_update_ops test_ops = {
+ .boot_identity = test_boot_identity,
+ .pcr_read = test_pcr_read,
+ .pcr_extend = test_pcr_extend,
+ .prepare = test_prepare,
+ .activate = test_activate,
+ .seal = test_seal,
+ .checkpoint = test_checkpoint,
+};
+
+static int make_target(char id, struct shirudo_config_update_target *target)
+{
+ memset(target, 0, sizeof(*target));
+ snprintf(target->prefix, sizeof(target->prefix), "/verified/config-%c",
+ id);
+ memset(target->root_hash, id, sizeof(target->root_hash));
+ return 0;
+}
+
+static int show_event(const struct shirudo_config_update_record *record,
+ void *opaque)
+{
+ __u32 *count = opaque;
+ char hex[65];
+
+ hex_encode(record->target.root_hash, 32, hex);
+ printf("event=%llu:%u:%u:%u:%s\n", (__u64)record->sequence,
+ record->reset_count, record->pcr, record->kind, hex);
+ (*count)++;
+ return 0;
+}
+
+static void inspect(struct test_context *ctx)
+{
+ struct shirudo_config_update_record record;
+ __u8 value[32];
+ __u32 count = 0;
+ char hex[65];
+ int rc;
+
+ printf("extends=%u\nprepares=%u\nactivations=%u\npartial=%u\n",
+ ctx->sim.extends, ctx->sim.prepares, ctx->sim.activations,
+ ctx->sim.partial);
+ if (!test_pcr_read(ctx, 15, value)) {
+ hex_encode(value, 32, hex);
+ printf("pcr_value=%s\n", hex);
+ }
+ rc = shirudo_config_update_read(ctx->update, &record);
+ printf("state_rc=%d\n", rc);
+ if (!rc) {
+ printf("sequence=%llu\npending=%u\nkind=%u\npcr=%u\nreset=%u\n",
+ (__u64)record.sequence, record.pending,
+ record.kind, record.pcr, record.reset_count);
+ printf("prefix=%s\nrestart=%u\n", record.target.prefix,
+ record.restart_count);
+ hex_encode(record.initial_pcr, 32, hex);
+ printf("initial_pcr=%s\n", hex);
+ hex_encode(record.target.root_hash, 32, hex);
+ printf("root_hash=%s\n", hex);
+ }
+ rc = shirudo_config_update_events(ctx->update, show_event, &count);
+ printf("events_rc=%d\nevents=%u\n", rc, count);
+}
+
+int main(int argc, char **argv)
+{
+ struct shirudo_config_update second = { .dir_fd = -1, .lock_fd = -1 };
+ struct shirudo_config_update update = { .dir_fd = -1, .lock_fd = -1 };
+ struct test_context ctx = { .update = &update };
+ struct shirudo_config_update_target target;
+ char hex[65];
+ __u32 pcr = 15;
+ __u8 event[32];
+ int rc;
+
+ if (argc < 3 || argc > 5)
+ return 2;
+ ctx.directory = argv[1];
+ if (argc > 3 &&
+ (strlen(argv[3]) != 1 || argv[3][0] < 'A' || argv[3][0] > 'Z'))
+ return 2;
+ if (argc == 5)
+ pcr = strtoul(argv[4], NULL, 10);
+ rc = make_target(argc > 3 ? argv[3][0] : 'A', &target);
+ if (rc)
+ return 1;
+ if (!strcmp(argv[2], "describe")) {
+ hex_encode(target.root_hash, sizeof(target.root_hash),
+ hex);
+ printf("root_hash=%s\n", hex);
+ rc = shirudo_config_measure_event(SHIRUDO_CONFIG_EVENT_BOOT,
+ target.root_hash, event);
+ if (!rc) {
+ hex_encode(event, sizeof(event), hex);
+ printf("boot_event=%s\n", hex);
+ }
+ return rc ? 1 : 0;
+ }
+ rc = simulator_load(&ctx);
+ if (rc)
+ goto out;
+ if (getenv("SHIRUDO_TEST_CONFIG_TPM")) {
+ rc = tpm_open(&ctx.tpm);
+ if (rc)
+ goto out;
+ }
+ rc = shirudo_config_update_open(argv[1], &test_ops, &ctx, &update);
+ if (rc)
+ goto out;
+ if (!strcmp(argv[2], "boot")) {
+ rc = shirudo_config_update_boot(&update, &target, pcr);
+ if (!rc && !getenv("SHIRUDO_TEST_CONFIG_BOOT_PENDING"))
+ rc = shirudo_config_update_complete_boot(&update);
+ } else if (!strcmp(argv[2], "update")) {
+ rc = shirudo_config_update_begin(&update, &target, pcr);
+ } else if (!strcmp(argv[2], "complete")) {
+ rc = shirudo_config_update_complete_boot(&update);
+ } else if (!strcmp(argv[2], "check")) {
+ rc = shirudo_config_update_check(&update, NULL);
+ } else if (!strcmp(argv[2], "inspect")) {
+ rc = 0;
+ } else if (!strcmp(argv[2], "reset")) {
+ ctx.sim.reset_count++;
+ memset(ctx.sim.value, 0, sizeof(ctx.sim.value));
+ rc = simulator_save(&ctx);
+ } else if (!strcmp(argv[2], "restart")) {
+ ctx.sim.restart_count++;
+ memset(ctx.sim.value, 0, sizeof(ctx.sim.value));
+ rc = simulator_save(&ctx);
+ } else if (!strcmp(argv[2], "drift")) {
+ memset(ctx.sim.value, 0x55, sizeof(ctx.sim.value));
+ rc = simulator_save(&ctx);
+ } else if (!strcmp(argv[2], "lock")) {
+ rc = shirudo_config_update_open(argv[1], &test_ops, &ctx,
+ &second);
+ shirudo_config_update_close(&second);
+ } else {
+ rc = -EINVAL;
+ }
+ inspect(&ctx);
+ shirudo_config_update_close(&update);
+out:
+ if (ctx.tpm)
+ tpm_close(ctx.tpm);
+ printf("rc=%d\n", rc);
+ return rc ? 1 : 0;
+}
diff --git a/testing/helper/test-image-keys.c b/testing/helper/test-image-keys.c
index 073f4a86..a066a764 100644
--- a/testing/helper/test-image-keys.c
+++ b/testing/helper/test-image-keys.c
@@ -11,6 +11,8 @@
#include <unistd.h>
#include "image_keys.h"
+#include "chain.h"
+#include "config_update.h"
#include "malloc.h"
#include "keyring.h"
#include "keys.h"
@@ -19,6 +21,15 @@ static __u32 mutations;
static char **held;
static int held_count;
+struct test_context {
+ struct shirudo_trusted_set *set;
+ __u8 pcr[32];
+ __u32 extends;
+ __u32 activations;
+ bool live;
+ bool interrupt;
+};
+
key_serial_t keyring_bpf_serial(void)
{
return 42;
@@ -55,17 +66,116 @@ int shirudo_keys_revoke_image(const __u8 *der, size_t size, bool boot)
return -EPERM;
}
+static int boot_count(void *opaque, __u32 *reset, __u32 *restart)
+{
+ (void)opaque;
+ *reset = 1;
+ *restart = 1;
+ return 0;
+}
+
+static int pcr_read(void *opaque, __u32 pcr, __u8 out[32])
+{
+ struct test_context *ctx = opaque;
+
+ (void)pcr;
+ memcpy(out, ctx->pcr, 32);
+ return 0;
+}
+
+static int pcr_extend(void *opaque, __u32 pcr, const __u8 event[32])
+{
+ struct test_context *ctx = opaque;
+
+ (void)pcr;
+ ctx->extends++;
+ return shirudo_chain_fold_checked(ctx->pcr, event);
+}
+
+static int prepare(void *opaque,
+ const struct shirudo_config_update_target *target)
+{
+ struct test_context *ctx = opaque;
+
+ (void)target;
+ return ctx->live ? shirudo_keys_check_image_set(ctx->set) : 0;
+}
+
+static int activate(void *opaque,
+ const struct shirudo_config_update_target *target)
+{
+ struct test_context *ctx = opaque;
+
+ (void)target;
+ ctx->activations++;
+ if (ctx->live && ctx->interrupt) {
+ ctx->interrupt = false;
+ return -EIO;
+ }
+ return 0;
+}
+
+static int seal(void *opaque, int fd)
+{
+ (void)opaque;
+ (void)fd;
+ return 0;
+}
+
+static const struct shirudo_config_update_ops ops = {
+ .boot_identity = boot_count,
+ .pcr_read = pcr_read,
+ .pcr_extend = pcr_extend,
+ .prepare = prepare,
+ .activate = activate,
+ .seal = seal,
+};
+
+static int live_update(const char *directory, struct shirudo_trusted_set *set)
+{
+ struct shirudo_config_update_target target = {};
+ struct shirudo_config_update update;
+ struct test_context ctx = { .set = set };
+ int rc;
+
+ rc = shirudo_config_update_open(directory, &ops, &ctx, &update);
+ if (rc)
+ return rc;
+ strcpy(target.prefix, "/verified/boot");
+ memset(target.root_hash, 1, 32);
+ rc = shirudo_config_update_boot(&update, &target, 15);
+ if (!rc)
+ rc = shirudo_config_update_complete_boot(&update);
+ ctx.live = true;
+ ctx.interrupt = !!getenv("SHIRUDO_TEST_IMAGE_INTERRUPT");
+ ctx.extends = 0;
+ ctx.activations = 0;
+ strcpy(target.prefix, "/verified/live");
+ memset(target.root_hash, 2, 32);
+ if (!rc)
+ rc = shirudo_config_update_begin(&update, &target, 15);
+
+ printf("extends=%u activations=%u\n", ctx.extends, ctx.activations);
+ shirudo_config_update_close(&update);
+ return rc;
+}
+
int main(int argc, char **argv)
{
struct shirudo_trusted_set set = {};
int fd, rc;
- if (argc != 3)
+ if (argc != 3 && argc < 5)
return 2;
fd = open(argv[2], O_RDONLY | O_DIRECTORY | O_CLOEXEC | O_NOFOLLOW);
if (fd < 0)
return 2;
rc = shirudo_keys_validate_image_set(argv[1], fd, &set);
+ if (!rc && argc >= 5) {
+ held = argv + 4;
+ held_count = argc - 4;
+ rc = live_update(argv[3], &set);
+ }
close(fd);
printf("rc=%d mutations=%u signers=%zu\n", rc, mutations, set.n);
return rc || mutations ? 1 : 0;
diff --git a/testing/run-target-verity-tests.sh b/testing/run-target-verity-tests.sh
index 33fd1608..205a1001 100755
--- a/testing/run-target-verity-tests.sh
+++ b/testing/run-target-verity-tests.sh
@@ -45,6 +45,12 @@ for t in \
t1108-tpm-chain.sh \
t1111-upatch-get.sh \
t1114-uprobe-multi.sh \
+ t1118-bpm-tree.sh \
+ t1119-bpm-tree-sequential.sh \
+ t1120-bpm-tree-delete.sh \
+ otel/t1115-map-export-all.sh \
+ otel/t1116-otel-backend.sh \
+ otel/t1117-otel-serialized-metric.sh \
tamperproof/t1110-lsm-deny.sh \
tamperproof/t1112-prog-load-keyring-gate.sh \
tamperproof/t1113-mount-lockdown.sh \
@@ -59,7 +65,10 @@ for t in \
tamperproof/t1150-verity-devices.sh \
tamperproof/t1151-verity-process.sh \
tamperproof/t1153-verity-hidden.sh \
- tamperproof/t1157-verity-cli.sh
+ tamperproof/t1154-verity-config.sh \
+ tamperproof/t1157-verity-cli.sh \
+ tamperproof/t1156-verity-revocation.sh \
+ tamperproof/t1158-verity-interruption.sh
do
log="$SHIRUDO_TEST_RESULTS/$(basename "$t").log"
rc=0
diff --git a/testing/t0046-config-update.sh b/testing/t0046-config-update.sh
new file mode 100755
index 00000000..d6dfcafd
--- /dev/null
+++ b/testing/t0046-config-update.sh
@@ -0,0 +1,245 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+
+cd "$(dirname "$0")"
+. ./test-lib.sh
+
+H=${SHIRUDO_TEST_CONFIG_HELPER:-$(pwd)/helper/test-config-update}
+SIM=$(pwd)/helper/tpmsim-cmd
+[ -x "$H" ] || test_skip_all "test-config-update helper not built"
+command -v python3 >/dev/null 2>&1 || test_skip_all "no python3"
+WORK=$(mktemp -d)
+trap 'rm -rf "$WORK"' EXIT HUP INT TERM
+
+field() {
+ sed -n "s/^$2=//p" "$1"
+}
+
+fresh() {
+ mkdir -m 700 "$WORK/$1"
+ "$H" "$WORK/$1" boot A >"$WORK/$1.out"
+}
+
+crash_update() {
+ SHIRUDO_TEST_CONFIG_CRASH=$2 "$H" "$WORK/$1" update B \
+ >"$WORK/$1.crash" 2>&1
+ rc=$?
+ [ "$rc" = 99 ]
+}
+
+test_expect_success 'event hash binds domain, event kind and binary root' '
+ "$H" "$WORK" describe A >"$WORK/hash" &&
+ python3 - "$WORK/hash" <<"PYTEST"
+import hashlib, sys
+v = dict(line.rstrip().split("=", 1) for line in open(sys.argv[1]))
+root = bytes.fromhex(v["root_hash"])
+assert len(root) == 32
+assert v["boot_event"] == hashlib.sha256(b"shirudo-config-root-v1\0" +
+ (1).to_bytes(4, "big") + root).hexdigest()
+PYTEST
+'
+
+test_expect_success 'static PCR policy excludes resettable PCRs and boot anchors' '
+ for pcr in 0 1 7 8 10 12 13 14 15; do
+ mkdir -m 700 "$WORK/pcr-$pcr" &&
+ "$H" "$WORK/pcr-$pcr" boot A "$pcr" >/dev/null || exit 1
+ done &&
+ for pcr in 9 11 16 23 24 4294967295; do
+ mkdir -m 700 "$WORK/pcr-$pcr" &&
+ ! "$H" "$WORK/pcr-$pcr" boot A "$pcr" >/dev/null || exit 1
+ done
+'
+
+test_expect_success 'boot completion, idempotence and live updates have exact event counts' '
+ fresh normal &&
+ [ "$(field "$WORK/normal.out" pending)" = 0 ] &&
+ "$H" "$WORK/normal" boot A >/dev/null &&
+ "$H" "$WORK/normal" update B >/dev/null &&
+ "$H" "$WORK/normal" update A >/dev/null &&
+ "$H" "$WORK/normal" update A >"$WORK/same" &&
+ [ "$(field "$WORK/same" extends)" = 3 ] &&
+ [ "$(field "$WORK/same" events)" = 3 ] &&
+ "$H" "$WORK/normal" check >/dev/null
+'
+
+test_expect_success 'live update cannot create the initial BOOT selection' '
+ mkdir -m 700 "$WORK/no-boot" &&
+ ! "$H" "$WORK/no-boot" update B >"$WORK/no-boot.out" &&
+ [ "$(field "$WORK/no-boot.out" extends)" = 0 ]
+'
+
+for failure in PREPARE READ; do
+ test_expect_success "failure before pending intent ($failure) leaves current selection healthy" '
+ fresh bad-'"$failure"' &&
+ ! env SHIRUDO_TEST_CONFIG_'"$failure"'_FAIL=1 "$H" "$WORK/bad-'"$failure"'" update B >"$WORK/failure" &&
+ [ "$(field "$WORK/failure" extends)" = 1 ] &&
+ [ "$(field "$WORK/failure" pending)" = 0 ] &&
+ "$H" "$WORK/bad-'"$failure"'" check >/dev/null
+ '
+done
+
+for response in before ambiguous drift; do
+ test_expect_success "TPM $response response leaves pending state and never retries in this boot" '
+ fresh tpm-'"$response"' &&
+ ! SHIRUDO_TEST_CONFIG_EXTEND='"$response"' "$H" "$WORK/tpm-'"$response"'" update B >"$WORK/failed" &&
+ [ "$(field "$WORK/failed" pending)" = 1 ] &&
+ ! "$H" "$WORK/tpm-'"$response"'" check >/dev/null &&
+ ! "$H" "$WORK/tpm-'"$response"'" update B >/dev/null &&
+ ! "$H" "$WORK/tpm-'"$response"'" boot B >"$WORK/retry" &&
+ [ "$(field "$WORK/retry" extends)" = 2 ]
+ '
+done
+
+test_expect_success 'boot remains pending until restore and NV initialization explicitly complete' '
+ mkdir -m 700 "$WORK/boot-pending" &&
+ SHIRUDO_TEST_CONFIG_BOOT_PENDING=1 "$H" "$WORK/boot-pending" boot A >"$WORK/boot-pending.out" &&
+ [ "$(field "$WORK/boot-pending.out" pending)" = 1 ] &&
+ ! "$H" "$WORK/boot-pending" check >/dev/null &&
+ ! "$H" "$WORK/boot-pending" complete >/dev/null &&
+ ! "$H" "$WORK/boot-pending" boot A >/dev/null
+'
+
+test_expect_success 'activation failure leaves pending state and blocks further changes' '
+ fresh partial &&
+ ! SHIRUDO_TEST_CONFIG_ACTIVATE_FAIL=1 "$H" "$WORK/partial" update B >/dev/null &&
+ ! "$H" "$WORK/partial" check >/dev/null &&
+ ! "$H" "$WORK/partial" update A >/dev/null
+'
+
+test_expect_success 'PCR drift and a changed PCR allocation refuse live updates' '
+ fresh drift && "$H" "$WORK/drift" drift >/dev/null &&
+ ! "$H" "$WORK/drift" check >/dev/null &&
+ ! "$H" "$WORK/drift" update B >/dev/null &&
+ fresh pcr-change && ! "$H" "$WORK/pcr-change" update B 14 >/dev/null
+'
+
+for action in reset restart; do
+ test_expect_success "$action requires a new BOOT event for the same root" '
+ fresh epoch-'"$action"' &&
+ "$H" "$WORK/epoch-'"$action"'" '"$action"' >/dev/null &&
+ ! "$H" "$WORK/epoch-'"$action"'" check >/dev/null &&
+ "$H" "$WORK/epoch-'"$action"'" boot A >"$WORK/epoch" &&
+ [ "$(field "$WORK/epoch" extends)" = 2 ] &&
+ [ "$(field "$WORK/epoch" kind)" = 1 ]
+ '
+done
+
+test_expect_success 'process death after measurement leaves a persistent pending latch' '
+ fresh crash && crash_update crash 2 &&
+ ! "$H" "$WORK/crash" check >/dev/null &&
+ ! "$H" "$WORK/crash" update B >/dev/null &&
+ ! "$H" "$WORK/crash" boot B >"$WORK/retry" &&
+ [ "$(field "$WORK/retry" extends)" = 2 ]
+'
+
+test_expect_success 'death before pending rename leaves the completed selection usable' '
+ fresh pre-pending && crash_update pre-pending 6 &&
+ "$H" "$WORK/pre-pending" check >/dev/null
+'
+
+test_expect_success 'death after durable completion leaves a healthy selection' '
+ fresh completed && crash_update completed 5 &&
+ "$H" "$WORK/completed" check >"$WORK/completed.out" &&
+ [ "$(field "$WORK/completed.out" extends)" = 2 ] &&
+ [ "$(field "$WORK/completed.out" pending)" = 0 ]
+'
+
+test_expect_success 'a truncated completed eventlog is rejected' '
+ fresh truncated-log &&
+ python3 - "$WORK/truncated-log/events" <<"PY" &&
+import os, sys
+os.truncate(sys.argv[1], os.path.getsize(sys.argv[1]) - 1)
+PY
+ ! "$H" "$WORK/truncated-log" check >/dev/null
+'
+
+test_expect_success 'corrupted state fails without any extension or activation' '
+ fresh corrupt-state &&
+ python3 - "$WORK/corrupt-state/state" <<"PY" &&
+from pathlib import Path
+import sys
+p = Path(sys.argv[1]); b = bytearray(p.read_bytes()); b[100] ^= 1; p.write_bytes(b)
+PY
+ ! "$H" "$WORK/corrupt-state" check >"$WORK/corrupt-state.out" &&
+ [ "$(field "$WORK/corrupt-state.out" extends)" = 1 ] &&
+ [ "$(field "$WORK/corrupt-state.out" activations)" = 1 ]
+'
+
+test_expect_success 'a stale temporary-file symlink cannot redirect durable writes' '
+ fresh stale-tmp && printf untouched >"$WORK/victim" &&
+ ln -s "$WORK/victim" "$WORK/stale-tmp/.state.tmp" &&
+ "$H" "$WORK/stale-tmp" update B >/dev/null &&
+ [ "$(cat "$WORK/victim")" = untouched ]
+'
+
+test_expect_success 'a state symlink and a hard-linked state are refused' '
+ fresh state-link && mv "$WORK/state-link/state" "$WORK/saved-state" &&
+ ln -s "$WORK/saved-state" "$WORK/state-link/state" &&
+ ! "$H" "$WORK/state-link" check >/dev/null &&
+ rm "$WORK/state-link/state" &&
+ ln "$WORK/saved-state" "$WORK/state-link/state" &&
+ ! "$H" "$WORK/state-link" check >/dev/null
+'
+
+test_expect_success 'eventlog and lock symlinks are refused before measurement' '
+ mkdir -m 700 "$WORK/event-link" "$WORK/lock-link" &&
+ printf untouched >"$WORK/linked-victim" &&
+ ln -s "$WORK/linked-victim" "$WORK/event-link/events" &&
+ ! "$H" "$WORK/event-link" boot A >"$WORK/event-link.out" &&
+ ln -s "$WORK/linked-victim" "$WORK/lock-link/lock" &&
+ ! "$H" "$WORK/lock-link" boot A >/dev/null &&
+ [ "$(cat "$WORK/linked-victim")" = untouched ] &&
+ [ "$(field "$WORK/event-link.out" extends)" = 0 ]
+'
+
+test_expect_success 'missing, symlinked and world-writable state directories are refused' '
+ ! "$H" "$WORK/missing" boot A >/dev/null &&
+ mkdir -m 700 "$WORK/real-dir" &&
+ ln -s "$WORK/real-dir" "$WORK/dir-link" &&
+ ! "$H" "$WORK/dir-link" boot A >/dev/null &&
+ chmod 777 "$WORK/real-dir" &&
+ ! "$H" "$WORK/real-dir" boot A >/dev/null
+'
+
+test_expect_success 'a second writer cannot acquire the same operation lock' '
+ fresh locked &&
+ ! "$H" "$WORK/locked" lock >"$WORK/locked.out" &&
+ [ "$(field "$WORK/locked.out" rc)" = -11 ]
+'
+
+test_expect_success 'seal failures prevent trusted journal creation' '
+ mkdir -m 700 "$WORK/no-seal" &&
+ ! SHIRUDO_TEST_CONFIG_SEAL_FAIL=1 "$H" "$WORK/no-seal" boot A >/dev/null &&
+ test ! -e "$WORK/no-seal/state"
+'
+
+if [ -x "$SIM" ]; then
+ test_expect_success 'actual TPM values match independently computed root events' '
+ mkdir -m 700 "$WORK/real-tpm" &&
+ SHIRUDO_TPM_TCTI="cmd:$SIM $WORK/tpm" SHIRUDO_TEST_CONFIG_TPM=1 \
+ "$H" "$WORK/real-tpm" boot A >"$WORK/real-a" &&
+ SHIRUDO_TPM_TCTI="cmd:$SIM $WORK/tpm" SHIRUDO_TEST_CONFIG_TPM=1 \
+ "$H" "$WORK/real-tpm" update B >"$WORK/real-b" &&
+ python3 - "$WORK/real-b" <<"PYTEST"
+import hashlib, sys
+pcr = bytes(32)
+for kind, root in [(1, b"A" * 32), (2, b"B" * 32)]:
+ event = hashlib.sha256(b"shirudo-config-root-v1\0" + kind.to_bytes(4, "big") + root).digest()
+ pcr = hashlib.sha256(pcr + event).digest()
+f = dict(line.rstrip().split("=", 1) for line in open(sys.argv[1]))
+assert f["pcr_value"] == pcr.hex() and f["extends"] == "2"
+PYTEST
+ '
+ test_expect_success 'ambiguous real TPM completion refuses retries without another extension' '
+ ! SHIRUDO_TPM_TCTI="cmd:$SIM $WORK/tpm" SHIRUDO_TEST_CONFIG_TPM=1 \
+ SHIRUDO_TEST_CONFIG_EXTEND=ambiguous "$H" "$WORK/real-tpm" update C >/dev/null &&
+ ! SHIRUDO_TPM_TCTI="cmd:$SIM $WORK/tpm" SHIRUDO_TEST_CONFIG_TPM=1 \
+ "$H" "$WORK/real-tpm" update C >"$WORK/no-retry" &&
+ [ "$(field "$WORK/no-retry" extends)" = 3 ]
+ '
+else
+ test_skip_all "libtpms helper required for actual PCR coverage"
+fi
+
+test_done
diff --git a/testing/t0050-image-keys.sh b/testing/t0050-image-keys.sh
index 5471e143..8913c94e 100755
--- a/testing/t0050-image-keys.sh
+++ b/testing/t0050-image-keys.sh
@@ -128,4 +128,29 @@ test_expect_success 'malformed additional certificates fail before mutation' '
invalid bad-trusted
'
+test_expect_success 'a live config with a new signer fails before PCR measurement or activation' '
+ fresh new-live && vouch new-live b "$fp_b" a &&
+ mkdir -m 700 "$W/new-journal" &&
+ ! "$H" "$W/a/cert.der" "$W/new-live" "$W/new-journal" \
+ "$W/a/cert.der" >"$W/result" &&
+ grep -q "extends=0 activations=0" "$W/result" &&
+ grep -q "rc=-126 mutations=0" "$W/result"
+'
+
+test_expect_success 'a live config using boot-enrolled signers measures and activates' '
+ mkdir -m 700 "$W/existing-journal" &&
+ "$H" "$W/a/cert.der" "$W/new-live" "$W/existing-journal" \
+ "$W/a/cert.der" "$W/b/cert.der" >"$W/result" &&
+ grep -q "extends=1 activations=1" "$W/result" &&
+ grep -q "rc=0 mutations=0" "$W/result"
+'
+
+test_expect_success 'an interrupted enrolled-key config refuses same-boot completion' '
+ mkdir -m 700 "$W/pending-journal" &&
+ ! SHIRUDO_TEST_IMAGE_INTERRUPT=1 "$H" "$W/a/cert.der" "$W/new-live" \
+ "$W/pending-journal" "$W/a/cert.der" "$W/b/cert.der" >"$W/result" &&
+ grep -q "extends=1 activations=1" "$W/result" &&
+ grep -q "rc=-5 mutations=0" "$W/result"
+'
+
test_done
diff --git a/testing/tamperproof/t1154-verity-config.sh b/testing/tamperproof/t1154-verity-config.sh
index 36b51d26..4de289f9 100755
--- a/testing/tamperproof/t1154-verity-config.sh
+++ b/testing/tamperproof/t1154-verity-config.sh
@@ -56,4 +56,16 @@ test_expect_success 'kernel rejects a modified root or detached root signature'
python3 tamperproof/t1154-verity-config.py corrupt-signature "$work"
'
+test_expect_success 'live CONFIG A to B extends PCR once and replaces config' '
+ python3 tamperproof/t1154-verity-config.py update "$work"
+'
+
+test_expect_success 'malformed signed revocation leaves PCR, active mapping and journal unchanged' '
+ python3 tamperproof/t1154-verity-config.py malformed "$work"
+'
+
+test_expect_success 'requesting current CONFIG B is a measured-state no-op' '
+ python3 tamperproof/t1154-verity-config.py repeat "$work"
+'
+
test_done
diff --git a/testing/tamperproof/t1155-verity-boot-signers.sh b/testing/tamperproof/t1155-verity-boot-signers.sh
index 7602e353..6c6d7102 100755
--- a/testing/tamperproof/t1155-verity-boot-signers.sh
+++ b/testing/tamperproof/t1155-verity-boot-signers.sh
@@ -42,4 +42,12 @@ test_expect_success 'boot enrolls the vouched signer and measures its signed CON
python3 tamperproof/t1155-verity-boot-signers.py initial "$work"
'
+test_expect_success 'a signed CONFIG needing a new live signer refuses before changes' '
+ python3 tamperproof/t1155-verity-boot-signers.py new-signer "$work"
+'
+
+test_expect_success 'the current CONFIG with two boot-enrolled signers is a no-op' '
+ python3 tamperproof/t1155-verity-boot-signers.py repeat "$work"
+'
+
test_done
diff --git a/testing/tamperproof/t1156-verity-revocation.py b/testing/tamperproof/t1156-verity-revocation.py
new file mode 100644
index 00000000..7c099127
--- /dev/null
+++ b/testing/tamperproof/t1156-verity-revocation.py
@@ -0,0 +1,83 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+
+import hashlib
+import importlib.util
+import json
+from pathlib import Path
+import sys
+
+spec = importlib.util.spec_from_file_location(
+ "signer_test", Path(__file__).with_name("t1155-verity-boot-signers.py"))
+signer = importlib.util.module_from_spec(spec)
+spec.loader.exec_module(signer)
+config = signer.config
+require = config.require
+NAME = "shirudo-test-revoked-key"
+UPATCH = signer.FIXTURES / (NAME + ".upatch")
+PIN = Path("/run/shirudo/bpffs/upatches") / NAME
+ARCHIVE = Path("/var/lib/shirudo/upatches") / (NAME + ".upatch")
+
+
+def snapshot(label, expected):
+ # Pin the current register at every stage, then independently check each
+ # signed load/unload event against the preceding register value below.
+ (config.RESULTS / "anchor.json").unlink(missing_ok=True)
+ view = config.snapshot(label)
+ view["keys"] = signer.keyring(expected)["keys"]
+ config.save(label, view)
+ return view
+
+
+def extension(before, after, kind, payload):
+ event = hashlib.sha256(b"shirudo-" + kind + b"\0" +
+ bytes.fromhex(payload) + NAME.encode()).digest()
+ expected = hashlib.sha256(bytes.fromhex(before["chain"]) + event).hexdigest()
+ require(after["chain"] == expected, "unexpected upatch NV extension")
+
+
+def main():
+ mode = sys.argv[1]
+ if mode == "initial":
+ require(UPATCH.is_file(), "missing boot-signed upatch fixture")
+ signer.check_members(signer.keyring())
+ require(not PIN.exists() and not ARCHIVE.exists(), "stale revoked upatch")
+ snapshot("before", 2)
+ elif mode == "load":
+ before = config.load("before")
+ info = json.loads(config.run("upatch-info", "upatch", "info", UPATCH, "--json"))
+ config.save("upatch", info)
+ config.run("load", "upatch", "load", UPATCH, "--no-precheck")
+ require((PIN / "link").exists() and ARCHIVE.is_file(), "upatch not installed")
+ after = snapshot("loaded", 2)
+ require(before["config"] == after["config"], "load changed CONFIG")
+ extension(before, after, b"upatch", info["payload_sha256"])
+ elif mode == "revoke":
+ before = config.load("loaded")
+ config.run("revoke-config", "image", "update", signer.FIXTURES / "config-revoke")
+ after = snapshot("revoked", 1)
+ require(not PIN.exists() and not ARCHIVE.exists(), "revoked upatch remains")
+ require(after["status"]["root_hash"] == config.root("config-revoke"),
+ "revocation image not active")
+ require(after["status"]["sequence"] == before["status"]["sequence"] + 1 and
+ after["config"]["events"][:-1] == before["config"]["events"],
+ "revocation did not append exactly one CONFIG event")
+ expected = signer.certificate_description(signer.FIXTURES / "primary.der")
+ require({value[4] for value in after["keys"].values()} == {expected},
+ "revocation removed the wrong signer")
+ cert_digest = hashlib.sha256((signer.FIXTURES / "boot.der").read_bytes()).digest()
+ revoke = hashlib.sha256(b"shirudo-key-revoke\0" + cert_digest).digest()
+ intermediate = dict(before)
+ intermediate["chain"] = hashlib.sha256(bytes.fromhex(before["chain"]) + revoke).hexdigest()
+ extension(intermediate, after, b"unload", config.load("upatch")["payload_sha256"])
+ config.run("revoked-load", "upatch", "load", UPATCH,
+ "--no-precheck", success=False)
+ repeat = snapshot("refused-load", 1)
+ require(after == repeat, "refused load changed state")
+ else:
+ raise ValueError(mode)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/testing/tamperproof/t1156-verity-revocation.sh b/testing/tamperproof/t1156-verity-revocation.sh
new file mode 100644
index 00000000..4b52f55b
--- /dev/null
+++ b/testing/tamperproof/t1156-verity-revocation.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+
+cd "$(dirname "$0")/.."
+. ./integration-lib.sh
+target_guard
+: "${SHIRUDO_TEST_KEY_FIXTURES:?signed key fixtures are required}"
+work=${SHIRUDO_TEST_REVOKE_RESULTS:-$(mktemp -d)}
+mkdir -p "$work"
+export SHIRUDO_BIN SHIRUDO_TEST_KEY_FIXTURES
+
+test_expect_success 'signed revocation fixture retains the primary and names the boot signer' '
+ python3 tamperproof/t1156-verity-revocation.py initial "$work"
+'
+test_expect_success 'boot signer loads a pinned upatch with checked NV status' '
+ python3 tamperproof/t1156-verity-revocation.py load "$work"
+'
+test_expect_success 'signed CONFIG revocation unlinks its signer and purges its measured upatch' '
+ python3 tamperproof/t1156-verity-revocation.py revoke "$work"
+'
+test_done
diff --git a/testing/tamperproof/t1158-verity-interruption.py b/testing/tamperproof/t1158-verity-interruption.py
new file mode 100755
index 00000000..74b3aeff
--- /dev/null
+++ b/testing/tamperproof/t1158-verity-interruption.py
@@ -0,0 +1,80 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+
+import hashlib
+import importlib.util
+import json
+import os
+from pathlib import Path
+import re
+import struct
+import subprocess
+import sys
+
+spec = importlib.util.spec_from_file_location(
+ "config_test", Path(__file__).with_name("t1154-verity-config.py"))
+config = importlib.util.module_from_spec(spec)
+spec.loader.exec_module(config)
+RESULTS = config.RESULTS
+
+
+def fault_command():
+ runtime = config.RUNTIME
+ directories = []
+ for directory, _, files in os.walk(runtime, followlinks=False):
+ if any(name.endswith(".so") or ".so." in name for name in files):
+ directories.append(directory)
+ library_path = ":".join(sorted(directories))
+ for name in ("lib64/ld-linux-x86-64.so.2", "lib/ld-linux-aarch64.so.1",
+ "lib/ld-linux-riscv64-lp64d.so.1"):
+ interpreter = runtime / name
+ if interpreter.is_file():
+ return [str(interpreter), "--inhibit-cache", "--library-path",
+ library_path, str(runtime / "usr/bin/shirudo-image-fault")]
+ raise AssertionError("runtime ELF interpreter missing")
+
+
+def pcr(label):
+ result = subprocess.run(["tpm2_pcrread", "sha256:14"], capture_output=True,
+ text=True, timeout=30)
+ (RESULTS / (label + ".pcr.stdout")).write_text(result.stdout)
+ (RESULTS / (label + ".pcr.stderr")).write_text(result.stderr)
+ config.require(result.returncode == 0, f"PCR read failed: {result.stderr}")
+ match = re.search(r"14\s*:\s*0x([0-9a-fA-F]{64})", result.stdout)
+ config.require(match is not None, f"missing SHA-256 PCR 14: {result.stdout}")
+ return match.group(1).lower()
+
+
+def main():
+ RESULTS.mkdir(parents=True, exist_ok=True)
+ (RESULTS / "anchor.json").unlink(missing_ok=True)
+ before = config.snapshot("before")
+ target = "config-interrupted"
+ config.require(before["status"]["root_hash"] != config.root(target),
+ "interruption fixture was already active")
+ config.require(pcr("before") == before["pcr"], "quote/PCR mismatch before crash")
+ digest = hashlib.sha256(b"shirudo-config-root-v1\0" + struct.pack(">I", 2) +
+ bytes.fromhex(config.root(target))).digest()
+ expected = hashlib.sha256(bytes.fromhex(before["pcr"]) + digest).hexdigest()
+ result = subprocess.run(fault_command() + ["image", "update",
+ str(config.IMAGES / target)],
+ capture_output=True, text=True, timeout=120)
+ (RESULTS / "crash.stdout").write_text(result.stdout)
+ (RESULTS / "crash.stderr").write_text(result.stderr)
+ config.require(result.returncode == 99,
+ f"fault did not fire: exit {result.returncode}: {result.stderr}")
+ (RESULTS / "crash.state").write_bytes((config.JOURNAL / "state").read_bytes())
+ (RESULTS / "crash.events").write_bytes((config.JOURNAL / "events").read_bytes())
+ config.require(pcr("crash") == expected, "config PCR did not extend exactly once")
+ status = json.loads(config.run("pending-status", "image", "status", success=False))
+ config.require(status["pending"] and not status["consistent"],
+ "interrupted activation looked healthy")
+ config.run("blocked-update", "image", "update", config.IMAGES / target, success=False)
+ config.run("blocked-init", "init", success=False)
+ config.run("blocked-attest", "attest", "--nonce=" + "a5" * 32, success=False)
+ config.require(pcr("after-refusals") == expected, "refusal retried PCR extension")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/testing/tamperproof/t1158-verity-interruption.sh b/testing/tamperproof/t1158-verity-interruption.sh
new file mode 100755
index 00000000..410b0b00
--- /dev/null
+++ b/testing/tamperproof/t1158-verity-interruption.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+
+cd "$(dirname "$0")/.."
+. ./integration-lib.sh
+target_guard
+work=${SHIRUDO_TEST_INTERRUPTION_RESULTS:?persistent results directory required}
+for command in python3 tpm2_pcrread; do
+ command -v "$command" >/dev/null 2>&1 || {
+ printf "Bail out! missing required interruption test tool: %s\n" "$command" >&2
+ exit 1
+ }
+done
+[ -x /run/shirudo/runtime/usr/bin/shirudo-image-fault ] || {
+ printf "Bail out! trusted interruption helper is missing\n" >&2
+ exit 1
+}
+mkdir -p "$work"
+export SHIRUDO_BIN
+test_expect_success 'post-measurement interruption blocks mutations and attestation' '
+ python3 tamperproof/t1158-verity-interruption.py interruption "$work"
+'
+test_done