eBPF-based security platform
testing: run the target suite with dm-verity only
KP Singhe2f23c642f9f
diff --git a/.github/scripts/target-tests.sh b/.github/scripts/target-tests.shindex f7cc0fbb..ca93a39a 100755--- a/.github/scripts/target-tests.sh+++ b/.github/scripts/target-tests.sh@@ -6,10 +6,9 @@# make -C testing test-tgt does on a developer's host. setup makes the# runner the VM host: KVM, the VM's packages, the bpf-next kernel unless a# restored copy is current, and the OpenSSL 3.5 toolchain from-# vm-toolchain.sh. staging runs the suite as is, production boots the-# guest from a dracut initrd.+# vm-toolchain.sh. The suite boots an image-backed target from a dracut initrd.#-# .github/scripts/target-tests.sh setup|staging|production+# .github/scripts/target-tests.sh setup|production## Runs as a user with passwordless sudo, from the checkout.@@ -66,7 +65,7 @@ setup() {.github/scripts/vm-toolchain.sh \autoconf autoconf-archive automake clang-20 cloud-image-utils \dracut-core file isc-dhcp-client libguestfs-tools libltdl-dev \- libtool libzstd-dev qemu-system-x86 qemu-utils swtpm \+ libtool libzstd-dev cryptsetup-bin e2fsprogs qemu-system-x86 qemu-utils swtpm \swtpm-tools tpm2-tools# Ubuntu 24.04's clang 18 lacks the BPF address-space casts the@@ -95,9 +94,9 @@ setup() {}case "${1:-}" in-setup|staging|production) ;;+setup|production) ;;*)- echo "usage: $0 setup|staging|production" >&2+ echo "usage: $0 setup|production" >&2exit 2;;esac@@ -116,8 +115,4 @@ fi# emergency mode for instance, would otherwise hold the job for an hour.export TEST_VM_TIMEOUT=900-if [ "$1" = staging ]; then- make -C testing test-tgt-else- sudo -E env PATH="$PATH" make -C testing test-tgt TEST_VM_INITRD=1-fi+sudo -E env PATH="$PATH" make -C testing test-tgtdiff --git a/.github/workflows/target-tests.yml b/.github/workflows/target-tests.ymlindex 2b0aa02c..6649c9d8 100644--- a/.github/workflows/target-tests.yml+++ b/.github/workflows/target-tests.yml@@ -13,7 +13,7 @@ concurrency:jobs:test-tgt:- name: Target suite in the test VM, staging and production+ name: Target suite in the dm-verity VMruns-on: ubuntu-latesttimeout-minutes: 150@@ -51,15 +51,7 @@ jobs:- name: Prepare the runner as the VM hostrun: .github/scripts/target-tests.sh setup- - name: Run the target suite in the staging configuration- run: .github/scripts/target-tests.sh staging-- # Every unit with a private mount namespace fails after switch-root- # since d2ffd16 ("bpf: refuse unmounting any mount above the- # private bpffs"); the step reports without failing the job until- # that is fixed.- - name: Run the target suite in the production configuration- continue-on-error: true+ - name: Run the target suite in the dm-verity VMrun: .github/scripts/target-tests.sh production# Each part is saved once it is complete, even when a later stepdiff --git a/Makefile.shirudo b/Makefile.shirudoindex 19ae0f32..586a0d0c 100644--- a/Makefile.shirudo+++ b/Makefile.shirudo@@ -587,6 +587,7 @@ verity-test-helpers: $(VERITY_TEST_HELPERS) build/verity-tests/shirudo-image-fauTEST_HELPERS := $(VERITY_TEST_HELPERS) \testing/helper/test-image-cli \testing/helper/test-image-cleanup \+ testing/helper/test-mode-objects \testing/helper/test-image-config \testing/helper/test-config-image \testing/helper/test-config-update \@@ -817,6 +818,10 @@ testing/helper/test-image-cleanup: testing/helper/test-image-cleanup.c \-Wl,--wrap=shirudo_dm_verity_remove,--wrap=usleep \$(STATIC_LIBS) $(DYNAMIC_LIBS)+testing/helper/test-mode-objects: testing/helper/test-mode-objects.c \+ $(call obj,util/loader.o) $(LIBBPF_A)+ @printf ' CC $@\n'+ $(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ -lelf -lztest-helpers: $(TEST_HELPERS)diff --git a/contrib/build-test-vm-bundle.sh b/contrib/build-test-vm-bundle.shindex 2accd985..e7f81845 100755--- a/contrib/build-test-vm-bundle.sh+++ b/contrib/build-test-vm-bundle.sh@@ -26,7 +26,7 @@ STAMP_FILE="${TEST_VM_BUNDLE_STAMP:-${BUNDLE_DIR}/.stamp}"STAMP_INPUTS="${TEST_VM_BUNDLE_INPUTS:-}"PACKAGE_CERT="${TEST_VM_PACKAGE_CERT:-}"RUNTIME_PREP_VERSION=4-TEST_VM_MODE=${TEST_VM_MODE:-legacy}+TEST_VM_MODE=${TEST_VM_MODE:-verity}RUNTIME_DISK_SIZE="${TEST_VM_RUNTIME_DISK_SIZE:-8G}"log()@@ -205,10 +205,8 @@ done# which Ubuntu 24.04 no longer installs; without it apt in the appliance# reaches nothing.[[ "$TEST_VM_HOST_PKG" != apt ]] || require_command dhclient isc-dhcp-client-if [[ "$TEST_VM_MODE" == verity ]]; then- require_command veritysetup cryptsetup-bin cryptsetup- require_command mkfs.ext4 e2fsprogs e2fsprogs-fi+require_command veritysetup cryptsetup-bin cryptsetup+require_command mkfs.ext4 e2fsprogs e2fsprogscheck_libguestfs_hostresolve_rootfs()@@ -286,7 +284,7 @@ bundle_is_current()command -v flock >/dev/null 2>&1 ||die "flock is required; install it with: $(test_vm_install_cmd util-linux)"-case "$TEST_VM_MODE" in legacy|verity) ;; *) die "invalid TEST_VM_MODE" ;; esac+[[ "$TEST_VM_MODE" == verity ]] || die "TEST_VM_MODE must be verity"validate_package_certmkdir -p "$(dirname "$BUNDLE_DIR")"@@ -314,10 +312,8 @@ cleanup()trap cleanup EXITmake -C "$REPO_ROOT" DESTDIR="$TMP_DIR/root" install-target-if [[ "$TEST_VM_MODE" == verity ]]; then- make -C "$REPO_ROOT" -j"$(nproc)" -f Makefile.shirudo \- PROFILE=target CONFIG_MK=config-target.mk verity-test-helpers-fi+make -C "$REPO_ROOT" -j"$(nproc)" -f Makefile.shirudo \+ PROFILE=target CONFIG_MK=config-target.mk verity-test-helpersinstall -d "$TMP_DIR/test-helpers/testing/helper" \"$TMP_DIR/test-helpers/testing/upatch/kernel-obs/exec"@@ -734,10 +730,8 @@ fithird.vouch package-cert.der > manifest)-if [[ "$TEST_VM_MODE" == verity ]]; then- "$REPO_ROOT/contrib/verity-vm-bundle.sh" "$TMP_DIR" "$FIXTURE_WORK" \- "$FIXTURE_WORK/trusted" "$FIXTURE_WORK/own"-fi+"$REPO_ROOT/contrib/verity-vm-bundle.sh" "$TMP_DIR" "$FIXTURE_WORK" \+ "$FIXTURE_WORK/trusted" "$FIXTURE_WORK/own"printf '%s\n' "$TEST_VM_MODE" >"$TMP_DIR/test-mode"printf 'shirudo-test-vm-bundle-v1\n' >"$TMP_DIR/format"diff --git a/contrib/test-vm-guest.sh b/contrib/test-vm-guest.shindex 13a4f624..1ab88b91 100755--- a/contrib/test-vm-guest.sh+++ b/contrib/test-vm-guest.sh@@ -19,10 +19,8 @@ UPPER=/var/tmp/shirudo-upperOVERLAY_WORK=/var/tmp/shirudo-overlay-workWORKSPACE=/workspace/shirudoVM_MODE="${VM_MODE:-test}"-TEST_MODE="${TEST_VM_MODE:-legacy}"SHIRUDO_BIN=/usr/local/bin/shirudo-SKIP_SEAL="${TEST_VM_SKIP_SEAL:-0}"-VM_INITRD="${TEST_VM_INITRD:-0}"+VM_INITRD="${TEST_VM_INITRD:-1}"log(){@@ -331,63 +329,22 @@ test -c /dev/tpm0test -c /dev/tpmrm0tpm2_getrandom 8 >/dev/null-if [[ "$TEST_MODE" == verity ]]; then- (cd "$BUNDLE/verity" && sha256sum -c manifest)- mountpoint -q /run/shirudo/runtime- mountpoint -q /run/shirudo/config- install -m 0755 "$BUNDLE/verity/shirudo-runtime" /usr/local/bin/shirudo-runtime- SHIRUDO_BIN=/usr/local/bin/shirudo-runtime- for unit in "${TARGET_UNITS[@]}"; do- case "$unit" in *.service) ;; *) continue ;; esac- mkdir -p "/etc/systemd/system/$unit.d"- {- printf '[Service]\nExecStart=\n'- sed -n 's|^ExecStart=/usr/local/bin/shirudo |ExecStart=/usr/local/bin/shirudo-runtime |p' \- "/usr/lib/systemd/system/$unit"- } >"/etc/systemd/system/$unit.d/runtime.conf"- done- systemctl daemon-reload-else-log "importing operator certificate and attaching the measured Shirudo LSM"-install -d -m 0700 /var/lib/shirudo/keys--package_cert="${TEST_VM_PACKAGE_CERT:-$BUNDLE/fixtures/cert.der}"-if [[ -n "${TEST_VM_PACKAGE_CERT:-}" ]]; then- [[ "$package_cert" == /mnt/shirudo-package-cert/package-cert.der &&- -s "$package_cert" ]] || {- log "package certificate is missing from the package certificate share"- exit 1- }-fi-cmp -s "$package_cert" /var/lib/shirudo/keys/cert.der ||- install -m 0644 "$package_cert" \- /var/lib/shirudo/keys/cert.der-# The own-keyring certificate is a second trusted certificate, vouched-# for by the primary, so the enrolled set has two members for the tests-# to work with.-own_cert="$BUNDLE/fixtures/own.der"-if [[ -s "$own_cert" ]]; then- install -d -m 0700 /var/lib/shirudo/keys/trusted- own_fp="$(/usr/local/bin/shirudo bpm key fingerprint "$own_cert")"- cmp -s "$own_cert" "/var/lib/shirudo/keys/trusted/$own_fp.der" || {- install -m 0644 "$BUNDLE/fixtures/own.vouch" \- "/var/lib/shirudo/keys/trusted/$own_fp.vouch"- install -m 0644 "$own_cert" \- "/var/lib/shirudo/keys/trusted/$own_fp.der"- }-fi-rm -f /var/lib/shirudo/keys/signing_key.pem-init_args=()-if [[ "$SKIP_SEAL" == 1 ]]; then- log "filesystem sealing disabled: target LSM hooks are not sleepable"- init_args+=(--no-seal)-fi-configure_bpm_tree-/usr/local/bin/shirudo init "${init_args[@]}"-fi-if [[ "$TEST_MODE" == verity ]]; then- "$SHIRUDO_BIN" init-fi+(cd "$BUNDLE/verity" && sha256sum -c manifest)+mountpoint -q /run/shirudo/runtime+mountpoint -q /run/shirudo/config+install -m 0755 "$BUNDLE/verity/shirudo-runtime" /usr/local/bin/shirudo-runtime+SHIRUDO_BIN=/usr/local/bin/shirudo-runtime+for unit in "${TARGET_UNITS[@]}"; do+ case "$unit" in *.service) ;; *) continue ;; esac+ mkdir -p "/etc/systemd/system/$unit.d"+ {+ printf '[Service]\nExecStart=\n'+ sed -n 's|^ExecStart=/usr/local/bin/shirudo |ExecStart=/usr/local/bin/shirudo-runtime |p' \+ "/usr/lib/systemd/system/$unit"+ } >"/etc/systemd/system/$unit.d/runtime.conf"+done+systemctl daemon-reload+"$SHIRUDO_BIN" inittest -e /run/shirudo/bpffs/lsm_linkif [[ "$VM_INITRD" == 1 ]]; thenlog "checking that the initrd brought enforcement up"@@ -455,7 +412,6 @@ log "running target test suite: ${TEST_VM_SUITE:-all}"(cd testingexport SHIRUDO_BIN- export SHIRUDO_TEST_MODE="$TEST_MODE"export SHIRUDO_TEST_KEY_FIXTURES="$BUNDLE/verity"export SHIRUDO_TEST_RESULTS=/mnt/shirudo-out/verityif [[ "${TEST_VM_SUITE:-all}" == obs ]]; thendiff --git a/contrib/test-vm.sh b/contrib/test-vm.shindex 0280df42..060910d5 100755--- a/contrib/test-vm.sh+++ b/contrib/test-vm.sh@@ -63,9 +63,9 @@ DISK_SIZE="${TEST_VM_DISK_SIZE:-30G}"VM_TIMEOUT="${TEST_VM_TIMEOUT:-3600}"VM_MODE="${VM_MODE:-test}"VM_SUITE="${TEST_VM_SUITE:-all}"-TEST_MODE="${TEST_VM_MODE:-legacy}"+TEST_MODE="${TEST_VM_MODE:-verity}"SKIP_SEAL="${TEST_VM_SKIP_SEAL:-0}"-VM_INITRD="${TEST_VM_INITRD:-0}"+VM_INITRD="${TEST_VM_INITRD:-1}"VM_INITRD_MODULES="${TEST_VM_INITRD_MODULES:-base systemd systemd-initrd dracut-systemd rootfs-block fs-lib udev-rules terminfo shirudo}"INITRD=""VM_VERBOSE="${VM_VERBOSE:-0}"@@ -155,16 +155,11 @@ valid_vm_name()validate_mode(){- case "$TEST_MODE" in- legacy) ;;- verity)- [[ "$VM_INITRD" == 1 && "$SKIP_SEAL" == 0 ]] ||- die "verity mode requires TEST_VM_INITRD=1 and TEST_VM_SKIP_SEAL=0"- [[ "$VM_SUITE" == all && "$VM_MODE" == test ]] ||- die "verity mode requires the complete test suite"- ;;- *) die "TEST_VM_MODE must be legacy or verity" ;;- esac+ [[ "$TEST_MODE" == verity ]] || die "TEST_VM_MODE must be verity"+ [[ "$VM_INITRD" == 1 && "$SKIP_SEAL" == 0 ]] ||+ die "dm-verity requires TEST_VM_INITRD=1 and TEST_VM_SKIP_SEAL=0"+ [[ "$VM_SUITE" == all || "$VM_SUITE" == obs ]] ||+ die "dm-verity requires the complete test suite or obs"case "$VM_MODE" ininteractive|test) ;;*) die "VM_MODE must be 'interactive' or 'test'" ;;@@ -986,21 +981,19 @@ build_initrd()die "cannot fingerprint the bundle's own certificate"cp "$TEST_VM_HOST_BUNDLE/fixtures/own.der" "$trusted/$fp.der"cp "$TEST_VM_HOST_BUNDLE/fixtures/own.vouch" "$trusted/$fp.vouch"- if [[ "$TEST_MODE" == verity ]]; then- [[ -s "$TEST_VM_HOST_BUNDLE/verity/manifest" ]] ||- die "verity fixtures missing from the host bundle"- (cd "$TEST_VM_HOST_BUNDLE/verity" && sha256sum -c manifest) ||- die "verity fixture checksum mismatch"- mkdir -p "$seed/shirudo-test-images"- cp "$TEST_VM_HOST_BUNDLE/verity/"*.{img,verity,roothash,p7s} \- "$seed/shirudo-test-images/"- cp "$TEST_VM_HOST_BUNDLE/verity/bootstrap.conf" \- "$seed/shirudo-test-images/bootstrap.conf"- cp "$REPO_ROOT/contrib/verity-vm/seed-images.sh" \- "$seed/shirudo-test-seed-images.sh"- cat "$REPO_ROOT/contrib/verity-vm/shirudo-test-seed-images.conf" \- >>"$seed/usr/lib/systemd/system/shirudo-test-seed.service"- fi+ [[ -s "$TEST_VM_HOST_BUNDLE/verity/manifest" ]] ||+ die "verity fixtures missing from the host bundle"+ (cd "$TEST_VM_HOST_BUNDLE/verity" && sha256sum -c manifest) ||+ die "verity fixture checksum mismatch"+ mkdir -p "$seed/shirudo-test-images"+ cp "$TEST_VM_HOST_BUNDLE/verity/"*.{img,verity,roothash,p7s} \+ "$seed/shirudo-test-images/"+ cp "$TEST_VM_HOST_BUNDLE/verity/bootstrap.conf" \+ "$seed/shirudo-test-images/bootstrap.conf"+ cp "$REPO_ROOT/contrib/verity-vm/seed-images.sh" \+ "$seed/shirudo-test-seed-images.sh"+ cat "$REPO_ROOT/contrib/verity-vm/shirudo-test-seed-images.conf" \+ >>"$seed/usr/lib/systemd/system/shirudo-test-seed.service"cert="$RUN_DIR/cert.der"cp "$TEST_VM_HOST_BUNDLE/fixtures/cert.der" "$cert"args=(--kver "$kver" --output "$RUN_DIR/initrd.img"@@ -1009,9 +1002,7 @@ build_initrd()--cert "$cert"--trusted-dir "$trusted"--unit "$unit" --module-dir "$REPO_ROOT/tools/gen-initrd")- if [[ "$TEST_MODE" == verity ]]; then- args+=(--bootstrap-conf "$seed/shirudo-test-images/bootstrap.conf")- fi+ args+=(--bootstrap-conf "$seed/shirudo-test-images/bootstrap.conf")if [[ -n "$KERNEL_ARTIFACT_DIR" ]]; thenargs+=(--kmoddir "$KERNEL_ARTIFACT_DIR/lib/modules")else@@ -1238,12 +1229,14 @@ validate_oci_cavalidate_package_certvalidate_bpm_tree_configvalidate_bpm_oci+[[ -z "$BPM_TREE_CONFIG" && -z "$PACKAGE_CERT" && -z "$BPM_OCI_REPOSITORY_RAW" ]] ||+ die "custom trust and repository inputs must be built into signed config fixtures"if [[ "$VM_INITRD" == 1 ]]; thenHOST_DEPENDENCIES+=("dracut:dracut-core:dracut" "lsinitrd:dracut-core:dracut" "file:file:file")- [[ "$EUID" == 0 ]] || die "TEST_VM_INITRD=1 builds the initrd with dracut, which needs root"ficheck_host_dependenciesvalidate_host_bundle+[[ "$EUID" == 0 ]] || die "building the initrd with dracut needs root"[[ "$CPUS" =~ ^[1-9][0-9]*$ ]] || die "TEST_VM_CPUS must be a positive integer"[[ "$VM_TIMEOUT" =~ ^[1-9][0-9]*$ ]] || die "TEST_VM_TIMEOUT must be a positive integer"@@ -1480,9 +1473,7 @@ log "booting $(basename "$KERNEL") with ${CPUS} CPUs and ${MEMORY} memory"# The bpf keyring is left open for init to enrol the certificate and# seal it, as a production initrd does.KERNEL_LSM_ARGS="lsm=bpf bpf.keyring_unsealed=1"-if [ "$TEST_MODE" = verity ]; then- KERNEL_LSM_ARGS+=" dm_verity.keyring_unsealed=1"-fi+KERNEL_LSM_ARGS+=" dm_verity.keyring_unsealed=1"KERNEL_NET_DEVICE="virtio-net-pci,netdev=net0"# The virt machine has no if=virtio mapping, so its disks are explicit PCIdiff --git a/testing/Makefile b/testing/Makefileindex f9ee946f..7a6ea8ef 100644--- a/testing/Makefile+++ b/testing/Makefile@@ -19,7 +19,7 @@ test-vm-arch = $(shell TEST_VM_ARCH='$(TEST_VM_ARCH)'; \. $(ROOT)/contrib/test-vm-arch.sh && printf '%s' "$$$(1)").DEFAULT_GOAL := help-.PHONY: help clean test-helpers test-op fuzz test test-installer bundle test-vm-bundle kernel \+.PHONY: help clean test-helpers test-op fuzz test bundle test-vm-bundle kernel \bpf-next vm vm-console vm-ssh vm-stop vm-clean test-tgt test-tgt-obs \test-vm test-vm-clean@@ -27,11 +27,11 @@ KERNEL_PATCHES ?= $(if $(wildcard $(ROOT)/kernel/*.patch),$(ROOT)/kernel/,)override KERNEL_PATCHES := $(if $(strip $(KERNEL_PATCHES)),$(call root-path,$(KERNEL_PATCHES)),)PACKAGE_FORMAT ?= $(call test-vm-arch,TEST_VM_HOST_PKG_FORMAT)-TEST_VM_MODE ?= legacy-ifneq ($(filter $(TEST_VM_MODE),legacy verity),$(TEST_VM_MODE))- $(error TEST_VM_MODE must be legacy or verity)+TEST_VM_MODE ?= verity+ifneq ($(TEST_VM_MODE),verity)+ $(error TEST_VM_MODE must be verity)endif-TEST_VM_INITRD ?= $(if $(filter verity,$(TEST_VM_MODE)),1,0)+TEST_VM_INITRD ?= 1TEST_VM_WORK_DIR ?= build/test-vmoverride TEST_VM_WORK_DIR := $(call root-path,$(TEST_VM_WORK_DIR))TEST_VM_BUNDLE_DIR ?= $(TEST_VM_WORK_DIR)/host-bundle-$(VM_KERNEL_TAG)$(KERNEL_COMMIT_SUFFIX)-$(TEST_VM_MODE)@@ -284,12 +284,6 @@ fuzz:+$(Q)$(MAKE) -C $(ROOT) -f Makefile.shirudo fuzz-targets$(Q)sh $(ROOT)/testing/fuzz/run.sh $(FUZZ_SECONDS)-# The installer end to end: a stock cloud image in QEMU with a vTPM, the-# bpf-next kernel packages, tools/gen-initrd/install.sh with a local-# target package, two reboots and the production configuration.-test-installer:- $(Q)cd $(ROOT) && bash testing/t1300-installer-e2e.sh-bundle: test-vm-bundletest-vm: test-tgt@@ -306,10 +300,8 @@ help:' make -C testing test-op' \' make -C testing test-helpers' \' make -C testing fuzz [FUZZ_SECONDS=60]' \- ' make -C testing test-tgt TEST_VM_MODE=legacy [TEST_VM_INITRD=1]' \- ' make -C testing test-tgt TEST_VM_MODE=verity (dracut initrd, root required)' \+ ' make -C testing test-tgt (dm-verity, dracut initrd, root required)' \' make -C testing test-tgt-obs' \- ' make -C testing test-installer' \' make -C testing vm, vm-console, vm-ssh, vm-stop, or vm-clean' \' make -C testing vm KERNEL=7.4' \' make -C testing kernel KERNEL_TAG=v7.4' \diff --git a/testing/bpm/t1118-bpm-tree.sh b/testing/bpm/t1118-bpm-tree.shindex 858060a3..a16068b4 100755--- a/testing/bpm/t1118-bpm-tree.sh+++ b/testing/bpm/t1118-bpm-tree.sh@@ -26,10 +26,8 @@ do[ -s "$fixture" ] || test_skip_all "missing tree fixture: $fixture"done-[ "${SHIRUDO_TEST_MODE:-legacy}" = verity ] || [ ! -e "$TREE_CONFIG" ] || test_skip_all "tree config already exists"[ ! -e /var/lib/shirudo/bpm/upatch-tree ] ||test_skip_all "tree state already exists"-[ "${SHIRUDO_TEST_MODE:-legacy}" = verity ] || [ ! -e "$TREE_LABELS" ] || test_skip_all "node labels already exist"cleanup(){diff --git a/testing/bpm/t1119-bpm-tree-sequential.sh b/testing/bpm/t1119-bpm-tree-sequential.shindex 90cbc455..22cf2034 100755--- a/testing/bpm/t1119-bpm-tree-sequential.sh+++ b/testing/bpm/t1119-bpm-tree-sequential.sh@@ -28,8 +28,6 @@ do[ -s "$fixture" ] || test_skip_all "missing tree fixture: $fixture"done-[ "${SHIRUDO_TEST_MODE:-legacy}" = verity ] || [ ! -e "$TREE_CONFIG" ] || test_skip_all "tree config already exists"-[ "${SHIRUDO_TEST_MODE:-legacy}" = verity ] || [ ! -e "$TREE_LABELS" ] || test_skip_all "node labels already exist"[ "$(tree_state_field tree_id)" = shirudo-test-tree ] &&[ "$(tree_state_field last_seq)" = 2 ] ||test_skip_all "tree state is not where t1118 leaves it"diff --git a/testing/bpm/t1120-bpm-tree-delete.sh b/testing/bpm/t1120-bpm-tree-delete.shindex e718b659..75c8cec1 100755--- a/testing/bpm/t1120-bpm-tree-delete.sh+++ b/testing/bpm/t1120-bpm-tree-delete.sh@@ -27,8 +27,6 @@ do[ -s "$fixture" ] || test_skip_all "missing tree fixture: $fixture"done-[ "${SHIRUDO_TEST_MODE:-legacy}" = verity ] || [ ! -e "$TREE_CONFIG" ] || test_skip_all "tree config already exists"-[ "${SHIRUDO_TEST_MODE:-legacy}" = verity ] || [ ! -e "$TREE_LABELS" ] || test_skip_all "node labels already exist"[ "$(tree_state_field tree_id)" = shirudo-test-tree ] &&[ "$(tree_state_field last_seq)" = 3 ] &&[ -e "$MATCH_PIN" ] ||diff --git a/testing/helper/test-conditions.c b/testing/helper/test-conditions.cindex 3a8886ad..9b3a162f 100644--- a/testing/helper/test-conditions.c+++ b/testing/helper/test-conditions.c@@ -5,7 +5,7 @@* Drives util/conditions.c for t0050 with the input `shirudo status`* derives from what it reads off the host.*- * test-conditions <lsm 0|1> <bpf|user|none> <serial> <pinned> \+ * test-conditions <lsm 0|1> <bpf|none> <serial> <pinned> \* <notpm|none|match|mismatch>** serial is the live keyring's, -1 when it is absent; pinned the one initdiff --git a/testing/helper/test-mode-objects.c b/testing/helper/test-mode-objects.cnew file mode 100644index 00000000..fdc2f28d--- /dev/null+++ b/testing/helper/test-mode-objects.c@@ -0,0 +1,86 @@+// SPDX-License-Identifier: BSD-2-Clause+/* Copyright (c) 2026 Authors of shirudo */++#include <gelf.h>+#include <stdbool.h>+#include <stdio.h>++#include <bpf/libbpf.h>++#include "util/loader.h"++static int symbols(const char *selection,+ const struct shirudo_embedded_bpf *blob)+{+ Elf_Scn *section = NULL;+ Elf *elf;+ int rc = 0;++ if (elf_version(EV_CURRENT) == EV_NONE)+ return 1;+ elf = elf_memory((char *)blob->data, blob->size);+ if (!elf)+ return 1;+ while ((section = elf_nextscn(elf, section))) {+ GElf_Shdr header;+ Elf_Data *data;+ size_t i;++ if (!gelf_getshdr(section, &header)) {+ rc = 1;+ break;+ }+ if (header.sh_type != SHT_SYMTAB)+ continue;+ data = elf_getdata(section, NULL);+ if (!data || !header.sh_entsize) {+ rc = 1;+ break;+ }+ for (i = 1; i < header.sh_size / header.sh_entsize; i++) {+ GElf_Sym symbol;+ const char *name;++ if (!gelf_getsym(data, i, &symbol)) {+ rc = 1;+ break;+ }+ if (symbol.st_shndx != SHN_UNDEF)+ continue;+ name = elf_strptr(elf, header.sh_link, symbol.st_name);+ if (!name) {+ rc = 1;+ break;+ }+ printf("extern %s %s\n", selection, name);+ }+ }+ elf_end(elf);+ return rc;+}++static int inspect(const char *selection,+ const struct shirudo_embedded_bpf *blob)+{+ struct bpf_program *program;+ struct bpf_object *obj;+ struct bpf_map *map;++ obj = bpf_object__open_mem(blob->data, blob->size, NULL);+ if (!obj)+ return 1;+ printf("blob %s %s\n", selection, blob->name);+ bpf_object__for_each_program(program, obj)+ printf("program %s %s\n", selection,+ bpf_program__name(program));+ bpf_object__for_each_map(map, obj)+ printf("map %s %s\n", selection, bpf_map__name(map));+ bpf_object__close(obj);+ return symbols(selection, blob);+}++int main(void)+{+ return inspect("admission", bpf2_blob()) ||+ inspect("seal", seal_blob());+}diff --git a/testing/helper/test-seal-seccomp.py b/testing/helper/test-seal-seccomp.pyindex 0ccd84a0..7083c31b 100644--- a/testing/helper/test-seal-seccomp.py+++ b/testing/helper/test-seal-seccomp.py@@ -26,6 +26,6 @@ with tempfile.TemporaryDirectory(prefix="shirudo-seal-seccomp-") as directory:"-I" + str(root / "bpf/lib"),"-I" + str(root / "vendor/libbpf"),"-I" + str(root / "vendor/libbpf/include/uapi"),- "-c", str(root / "bpf/seal_verity.c"),+ "-c", str(root / "bpf/seal.c"),"-o", str(work / "seal_verity.bpf.o")]subprocess.run(command, check=True)diff --git a/testing/integration-lib.sh b/testing/integration-lib.shindex 810e09d8..2542366b 100644--- a/testing/integration-lib.sh+++ b/testing/integration-lib.sh@@ -72,22 +72,12 @@ tree_state_field() {# Point the target at the fixture tree at the given reference.tree_configure() {- if [ "${SHIRUDO_TEST_MODE:-legacy}" = verity ]; then- "$SHIRUDO_BIN" image update \- "$SHIRUDO_TEST_KEY_FIXTURES/config-tree-$1"- return- fi- mkdir -p /etc/shirudo/bpm- printf 'env=tree-test\n' >"$TREE_LABELS"- printf '%s\n' \- 'endpoint = oci://127.0.0.1:5443/shirudo/upatch-tree' \- "reference = $1" >"$TREE_CONFIG"+ "$SHIRUDO_BIN" image update \+ "$SHIRUDO_TEST_KEY_FIXTURES/config-tree-$1"}-tree_cleanup_config() {- [ "${SHIRUDO_TEST_MODE:-legacy}" != verity ] || return 0- rm -f "$TREE_CONFIG" "$TREE_LABELS"-}+# Config fixtures are immutable; later tests activate their own signed image.+tree_cleanup_config() { :; }# Serve the fixture registry $1 on 127.0.0.1:5443, logging requests to# $2/requests.log, and wait for it; tree_registry_stop ends it.@@ -115,15 +105,7 @@ tree_sync() {BPM_OCI_SCHEME=http "$SHIRUDO_BIN" bpm tree sync --report "$1" >/dev/null}-# "bpf" once init enrolled the certificate in the kernel's bpf keyring,-# "user" while it is staged in the user keyring.-keyring_mode() {- "$SHIRUDO_BIN" status --json 2>/dev/null | report_field keyring_mode-}--# What a load verified against a keyring the caller supplied gets: the-# kernel refuses the keyring outright (EPERM) when the bpf keyring is the-# trust anchor, the admission hook denies it (EACCES) while staging.+# A sealed kernel BPF keyring refuses caller-supplied trust anchors.foreign_keyring_errno() {- [ "$(keyring_mode)" = bpf ] && echo 1 || echo 13+ echo 1}diff --git a/testing/otel/t1115-map-export-all.sh b/testing/otel/t1115-map-export-all.shindex 30035543..624295d2 100644--- a/testing/otel/t1115-map-export-all.sh+++ b/testing/otel/t1115-map-export-all.sh@@ -11,25 +11,14 @@ NAME=shirudo-test-map-exportLOAD="$FIXTURES/$NAME.upatch"UNLOAD="$FIXTURES/$NAME.unload.upatch"PIN="/run/shirudo/bpffs/upatches/$NAME/link"-CONFIG=/etc/shirudo/shirudo.confWORK=$(mktemp -d)SERVER=""-JSON_DIR="$WORK/jsonl"-CONFIG_EXISTED=0-if [ "${SHIRUDO_TEST_MODE:-legacy}" = verity ]; then- export SHIRUDO_TEST_OTEL_PORT=5444- JSON_DIR=/tmp/shirudo-test-jsonl-elif [ -e "$CONFIG" ]; then- cp "$CONFIG" "$WORK/config"- CONFIG_EXISTED=1-fi+JSON_DIR=/tmp/shirudo-test-jsonl+export SHIRUDO_TEST_OTEL_PORT=5444restore() {[ -n "$SERVER" ] && kill "$SERVER" >/dev/null 2>&1 || true[ -n "$SERVER" ] && wait "$SERVER" 2>/dev/null || trueif [ -e "$PIN" ]; then "$SHIRUDO_BIN" upatch unload "$UNLOAD" --no-precheck >/dev/null 2>&1 || true; fi- if [ "${SHIRUDO_TEST_MODE:-legacy}" != verity ]; then- if [ "$CONFIG_EXISTED" -eq 1 ]; then cp "$WORK/config" "$CONFIG"; else rm -f "$CONFIG"; fi- firm -rf "$JSON_DIR" "$WORK"}trap restore EXIT@@ -80,11 +69,7 @@ test_expect_success '--all exports one detailed JSON record per loaded map' ''test_expect_success 'configured JSON-lines output appends one valid record per map' '- if [ "${SHIRUDO_TEST_MODE:-legacy}" = verity ]; then- "$SHIRUDO_BIN" image update "$SHIRUDO_TEST_KEY_FIXTURES/config-jsonl"- else- printf "map_export.json_path = %s\n" "$JSON_DIR/maps.ndjson" >"$CONFIG"- fi &&+ "$SHIRUDO_BIN" image update "$SHIRUDO_TEST_KEY_FIXTURES/config-jsonl" &&"$SHIRUDO_BIN" upatch map --all &&"$SHIRUDO_BIN" upatch map --all &&python3 - "$JSON_DIR/maps.ndjson" <<'\''PY'\''@@ -98,11 +83,7 @@ PY'test_expect_success 'configured JSON-lines output reports an unwritable destination' '- if [ "${SHIRUDO_TEST_MODE:-legacy}" = verity ]; then- "$SHIRUDO_BIN" image update "$SHIRUDO_TEST_KEY_FIXTURES/config-jsonl-bad"- else- printf "map_export.json_path = %s\n" "$JSON_DIR/missing/maps.ndjson" >"$CONFIG"- fi &&+ "$SHIRUDO_BIN" image update "$SHIRUDO_TEST_KEY_FIXTURES/config-jsonl-bad" &&! "$SHIRUDO_BIN" upatch map --all >/dev/null 2>&1'@@ -112,12 +93,7 @@ test_expect_success '--all auto exports mixed metric and log maps' 'i=0; while test ! -s "$WORK/otel.port" && test "$i" -lt 100; do i=$((i+1)); sleep .02; done;test -s "$WORK/otel.port" &&port=$(cat "$WORK/otel.port") &&- if [ "${SHIRUDO_TEST_MODE:-legacy}" = verity ]; then- "$SHIRUDO_BIN" image update "$SHIRUDO_TEST_KEY_FIXTURES/config-otel"- else- printf "%s\n" "map_export.tenant_id = tenant-config-0000" \- "map_export.otel_endpoint = http://127.0.0.1:1/ignored" >"$CONFIG"- fi &&+ "$SHIRUDO_BIN" image update "$SHIRUDO_TEST_KEY_FIXTURES/config-otel" &&"$SHIRUDO_BIN" upatch map --all --otel --otel-endpoint="http://127.0.0.1:$port/base" &&"$SHIRUDO_BIN" upatch map --all --otel --tenant-id=tenant-uuid-1234 --otel-endpoint="http://127.0.0.1:$port/base";kill "$SERVER" >/dev/null 2>&1 || true; wait "$SERVER" 2>/dev/null || true; SERVER="";diff --git a/testing/otel/t1116-otel-backend.sh b/testing/otel/t1116-otel-backend.shindex e7d96d0b..d58653b1 100644--- a/testing/otel/t1116-otel-backend.sh+++ b/testing/otel/t1116-otel-backend.sh@@ -14,22 +14,15 @@ NAME=shirudo-test-otel-backendLOAD="$FIXTURES/$NAME.upatch"UNLOAD="$FIXTURES/$NAME.unload.upatch"PIN="/run/shirudo/bpffs/upatches/$NAME/link"-CONFIG=/etc/shirudo/shirudo.confWORK=$(mktemp -d)SERVER=""-CONFIG_EXISTED=0TIMER_WAS_ACTIVE=0[ -s "$LOAD" ] || test_skip_all "missing OTEL backend fixture"[ -s "$UNLOAD" ] || test_skip_all "missing OTEL backend unload fixture"systemctl cat shirudo-map-export.service >/dev/null 2>&1 || test_skip_all "map-export service is not installed"systemctl cat shirudo-map-export.timer >/dev/null 2>&1 || test_skip_all "map-export timer is not installed"-if [ "${SHIRUDO_TEST_MODE:-legacy}" = verity ]; then- "$SHIRUDO_BIN" image update "$SHIRUDO_TEST_KEY_FIXTURES/config-otel"- export SHIRUDO_TEST_OTEL_PORT=5444-elif [ -e "$CONFIG" ]; then- cp "$CONFIG" "$WORK/config"- CONFIG_EXISTED=1-fi+"$SHIRUDO_BIN" image update "$SHIRUDO_TEST_KEY_FIXTURES/config-otel"+export SHIRUDO_TEST_OTEL_PORT=5444if systemctl is-active --quiet shirudo-map-export.timer; then TIMER_WAS_ACTIVE=1; firestore() {systemctl stop shirudo-map-export.timer >/dev/null 2>&1 || true@@ -37,9 +30,6 @@ restore() {[ -n "$SERVER" ] && kill "$SERVER" >/dev/null 2>&1 || true[ -n "$SERVER" ] && wait "$SERVER" 2>/dev/null || trueif [ -e "$PIN" ]; then "$SHIRUDO_BIN" upatch unload "$UNLOAD" --no-precheck >/dev/null 2>&1 || true; fi- if [ "${SHIRUDO_TEST_MODE:-legacy}" != verity ]; then- if [ "$CONFIG_EXISTED" -eq 1 ]; then cp "$WORK/config" "$CONFIG"; else rm -f "$CONFIG"; fi- fi[ "$TIMER_WAS_ACTIVE" -eq 1 ] && systemctl start shirudo-map-export.timer >/dev/null 2>&1 || truerm -rf "$WORK"}@@ -76,8 +66,6 @@ test_expect_success 'map-export service delivers both decoder-backed maps' 'i=0; while { test ! -s "$WORK/otel.port" || test ! -s "$WORK/otel.meta"; } && test "$i" -lt 100; do i=$((i+1)); sleep .1; done;test -s "$WORK/otel.port" &&port=$(cat "$WORK/otel.port") &&- { [ "${SHIRUDO_TEST_MODE:-legacy}" = verity ] ||- printf "%s\n" "map_export.otel_endpoint = http://127.0.0.1:$port" "map_export.otel_insecure = true" "map_export.otel_retries = 0" >"$CONFIG"; } &&"$SHIRUDO_BIN" upatch load "$LOAD" --no-precheck >/dev/null 2>&1 &&systemctl start shirudo-map-export.service &&systemctl start shirudo-map-export.timer;@@ -122,9 +110,7 @@ while state["completed"] < 4:PYpython3 "$WORK/slow-otel.py" "$WORK/slow.port" "$WORK/slow.meta" & SERVER=$!;i=0; while test ! -s "$WORK/slow.port" && test "$i" -lt 100; do i=$((i+1)); sleep .1; done;- port=$(cat "$WORK/slow.port") && test -n "$port" &&- { [ "${SHIRUDO_TEST_MODE:-legacy}" = verity ] ||- printf "%s\n" "map_export.otel_endpoint = http://127.0.0.1:$port" "map_export.otel_insecure = true" "map_export.otel_retries = 0" >"$CONFIG"; } || return 1;+ port=$(cat "$WORK/slow.port") && test -n "$port" || return 1;(systemctl start shirudo-map-export.service >/dev/null 2>&1) & service_start=$!;systemctl start shirudo-map-export.timer && wait "$service_start";i=0; while { test ! -s "$WORK/slow.meta" || test "$(python3 -c "import json,sys; print(json.load(open(sys.argv[1]))['completed'])" "$WORK/slow.meta" 2>/dev/null || echo 0)" -lt 4; } && test "$i" -lt 300; do i=$((i+1)); sleep .1; done;diff --git a/testing/otel/t1117-otel-serialized-metric.sh b/testing/otel/t1117-otel-serialized-metric.shindex 7b131dd8..657f4c67 100644--- a/testing/otel/t1117-otel-serialized-metric.sh+++ b/testing/otel/t1117-otel-serialized-metric.sh@@ -14,21 +14,14 @@ NAME=shirudo-test-serialized-metricLOAD="$FIXTURES/$NAME.upatch"UNLOAD="$FIXTURES/$NAME.unload.upatch"SERIALIZER_PIN="/run/shirudo/bpffs/upatches/$NAME/serializers/counters"-CONFIG=/etc/shirudo/shirudo.confWORK=$(mktemp -d)SERVER=""-CONFIG_EXISTED=0TIMER_WAS_ACTIVE=0[ -s "$LOAD" ] || test_skip_all "missing serialized metric fixture"[ -s "$UNLOAD" ] || test_skip_all "missing serialized metric unload fixture"systemctl cat shirudo-map-export.service >/dev/null 2>&1 || test_skip_all "map-export service is not installed"-if [ "${SHIRUDO_TEST_MODE:-legacy}" = verity ]; then- "$SHIRUDO_BIN" image update "$SHIRUDO_TEST_KEY_FIXTURES/config-otel"- export SHIRUDO_TEST_OTEL_PORT=5444-elif [ -e "$CONFIG" ]; then- cp "$CONFIG" "$WORK/config"- CONFIG_EXISTED=1-fi+"$SHIRUDO_BIN" image update "$SHIRUDO_TEST_KEY_FIXTURES/config-otel"+export SHIRUDO_TEST_OTEL_PORT=5444if systemctl is-active --quiet shirudo-map-export.timer; then TIMER_WAS_ACTIVE=1; firestore() {systemctl stop shirudo-map-export.timer >/dev/null 2>&1 || true@@ -36,9 +29,6 @@ restore() {[ -n "$SERVER" ] && kill "$SERVER" >/dev/null 2>&1 || true[ -n "$SERVER" ] && wait "$SERVER" 2>/dev/null || trueif [ -e "$SERIALIZER_PIN" ]; then "$SHIRUDO_BIN" upatch unload "$UNLOAD" --no-precheck >/dev/null 2>&1 || true; fi- if [ "${SHIRUDO_TEST_MODE:-legacy}" != verity ]; then- if [ "$CONFIG_EXISTED" -eq 1 ]; then cp "$WORK/config" "$CONFIG"; else rm -f "$CONFIG"; fi- fi[ "$TIMER_WAS_ACTIVE" -eq 1 ] && systemctl start shirudo-map-export.timer >/dev/null 2>&1 || truerm -rf "$WORK"}@@ -133,8 +123,6 @@ test_expect_success 'serialized multi-page metrics preserve peek and drain interi=0; while test ! -s "$WORK/service.port" && test "$i" -lt 100; do i=$((i+1)); sleep .1; done;test -s "$WORK/service.port" &&port=$(cat "$WORK/service.port") &&- { [ "${SHIRUDO_TEST_MODE:-legacy}" = verity ] ||- printf "%s\n" "map_export.otel_endpoint = http://127.0.0.1:$port" "map_export.otel_insecure = true" "map_export.otel_retries = 0" >"$CONFIG"; } &&if ! systemctl start shirudo-map-export.service; thensystemctl status shirudo-map-export.service --no-pager >&2 || truejournalctl -u shirudo-map-export.service --no-pager -n 100 >&2 || truediff --git a/testing/run-target-tests.sh b/testing/run-target-tests.shindex 298a98a7..f8ff0345 100755--- a/testing/run-target-tests.sh+++ b/testing/run-target-tests.sh@@ -1,55 +1,59 @@#!/bin/sh# SPDX-License-Identifier: BSD-2-Clause# Copyright (c) 2026 Authors of shirudo-#-# Run the complete target-side VM suite. All build/sign work is performed by-# the host bundle builder; target tests consume only prebuilt fixtures.set -eu-cd "$(dirname "$0")"--case "${SHIRUDO_TEST_MODE:-legacy}" in-legacy)- if mountpoint -q /run/shirudo/runtime; then- printf 'legacy suite refuses an active image runtime\n' >&2- exit 1- fi- ;;-verity) exec sh ./run-target-verity-tests.sh ;;-*) printf 'SHIRUDO_TEST_MODE must be legacy or verity\n' >&2; exit 2 ;;-esac--# The keyring substitution test deliberately destroys the trust anchor.-# It runs last.-fail=0+: "${SHIRUDO_BIN:?runtime command is required}"+: "${SHIRUDO_TEST_FIXTURES_DIR:?signed upatch fixtures are required}"+: "${SHIRUDO_TEST_KEY_FIXTURES:?signed image fixtures are required}"+: "${SHIRUDO_TEST_RESULTS:=/tmp/shirudo-verity-results}": "${SHIRUDO_TEST_SUITE_FAILURES_FILE:=}"+[ "$(id -u)" = 0 ] && [ -x "$SHIRUDO_BIN" ] &&+ [ -e /run/shirudo/bpffs/task_authority ] &&+ mountpoint -q /run/shirudo/runtime && mountpoint -q /run/shirudo/config || {+ printf 'image suite requires an initialized dm-verity target\n' >&2+ exit 1+}+for name in config-boot-keys config-live-new-key config-a config-b config-bad config-revoke \+ config-tree-stable config-tree-updated config-tree-deleted config-tree-restored \+ config-otel config-jsonl config-jsonl-bad config-interrupted; do+ for suffix in img verity roothash p7s; do+ [ -s "$SHIRUDO_TEST_KEY_FIXTURES/$name.$suffix" ] &&+ [ -s "/var/lib/shirudo/images/$name.$suffix" ] || {+ printf 'missing required image fixture: %s.%s\n' "$name" "$suffix" >&2+ exit 1+ }+ done+done+mkdir -p "$SHIRUDO_TEST_RESULTS"+export SHIRUDO_BIN SHIRUDO_TEST_KEY_FIXTURES+export SHIRUDO_TEST_CONFIG_RESULTS="$SHIRUDO_TEST_RESULTS/config"+export SHIRUDO_TEST_SIGNER_RESULTS="$SHIRUDO_TEST_RESULTS/signers"+export SHIRUDO_TEST_INTERRUPTION_RESULTS="$SHIRUDO_TEST_RESULTS/interruption"+export SHIRUDO_TEST_CLI_RESULTS="$SHIRUDO_TEST_RESULTS/cli"+export SHIRUDO_TEST_REVOKE_RESULTS="$SHIRUDO_TEST_RESULTS/revocation"+fail=0+# Boot assertions precede updates; the interruption leaves state pending.for t in \+ tamperproof/t1155-verity-boot-signers.sh \tamperproof/t1138-mode-objects.sh \t1200-target-fixtures.sh \- bpm/t1118-bpm-tree.sh \- bpm/t1119-bpm-tree-sequential.sh \- bpm/t1120-bpm-tree-delete.sh \- tpm/t1102-eventlog-full.sh \+ t1122-initrd.sh \+ tamperproof/t1105-siggate.sh \+ t1133-upatch-arena-serializer.sh \t1103-version-gate.sh \t1104-payload-mismatch.sh \t1107-load-unload.sh \tpm/t1108-tpm-chain.sh \t1111-upatch-get.sh \t1114-uprobe-multi.sh \+ bpm/t1118-bpm-tree.sh \+ bpm/t1119-bpm-tree-sequential.sh \+ bpm/t1120-bpm-tree-delete.sh \otel/t1115-map-export-all.sh \otel/t1116-otel-backend.sh \otel/t1117-otel-serialized-metric.sh \- t1122-initrd.sh \- t1123-keys.sh \- tamperproof/t1121-bpf-keyring.sh \- t1124-keys-add.sh \- t1126-keys-revoke.sh \- tamperproof/t1101-seal.sh \- tamperproof/t1132-seal-scratch.sh \- tamperproof/t1133-seal-init-xattr.sh \- tamperproof/t1134-seal-task.sh \- tamperproof/t1105-siggate.sh \tamperproof/t1110-lsm-deny.sh \tamperproof/t1112-prog-load-keyring-gate.sh \tamperproof/t1113-mount-lockdown.sh \@@ -58,21 +62,30 @@ for t in \tamperproof/t1136-tamper-counters.sh \tamperproof/t1130-map-lockdown.sh \tamperproof/t1131-pr-set-mm-identity.sh \- tamperproof/t1138-secure-exec.sh \- tamperproof/t1139-traced-exec.sh \+ tamperproof/t1132-seal-scratch.sh \tamperproof/t1125-key-permission.sh \- tamperproof/t1132-upatch-integrity.sh \- t1133-upatch-arena-serializer.sh \- tamperproof/t1106-keyring-swap.sh+ tamperproof/t1140-verity-authority.sh \+ tamperproof/t1150-verity-devices.sh \+ tamperproof/t1151-verity-process.sh \+ tamperproof/t1153-verity-hidden.sh \+ tamperproof/t1154-verity-config.sh \+ tamperproof/t1157-verity-cli.sh \+ tamperproof/t1156-verity-revocation.sh \+ tamperproof/t1158-verity-interruption.shdo- if sh "$t"; then- :- else+ log="$SHIRUDO_TEST_RESULTS/$(basename "$t").log"+ rc=0+ sh "$t" >"$log" 2>&1 || rc=$?+ cat "$log"+ if grep -q '^1\.\.0 # SKIP' "$log"; then+ printf 'required image suite was skipped: %s\n' "$t" >&2+ rc=1+ fi+ if [ "$rc" -ne 0 ]; thenfail=$((fail + 1))if [ -n "$SHIRUDO_TEST_SUITE_FAILURES_FILE" ]; then- printf '%s\n' "$t" >>"$SHIRUDO_TEST_SUITE_FAILURES_FILE" 2>/dev/null || :+ printf '%s\n' "$t" >>"$SHIRUDO_TEST_SUITE_FAILURES_FILE"fifidone--exit "$fail"+[ "$fail" -eq 0 ]diff --git a/testing/run-target-verity-tests.sh b/testing/run-target-verity-tests.shdeleted file mode 100755index c4e3b347..00000000--- a/testing/run-target-verity-tests.sh+++ /dev/null@@ -1,89 +0,0 @@-#!/bin/sh-# SPDX-License-Identifier: BSD-2-Clause-# Copyright (c) 2026 Authors of shirudo--set -eu-cd "$(dirname "$0")"-export SHIRUDO_TEST_MODE=verity-: "${SHIRUDO_BIN:?runtime command is required}"-: "${SHIRUDO_TEST_FIXTURES_DIR:?signed upatch fixtures are required}"-: "${SHIRUDO_TEST_KEY_FIXTURES:?signed image fixtures are required}"-: "${SHIRUDO_TEST_RESULTS:=/tmp/shirudo-verity-results}"-: "${SHIRUDO_TEST_SUITE_FAILURES_FILE:=}"-[ "$(id -u)" = 0 ] && [ -x "$SHIRUDO_BIN" ] &&- [ -e /run/shirudo/bpffs/task_authority ] &&- mountpoint -q /run/shirudo/runtime && mountpoint -q /run/shirudo/config || {- printf 'image suite requires an initialized image-mode target\n' >&2- exit 1-}-for name in config-boot-keys config-live-new-key config-a config-b config-bad config-revoke \- config-tree-stable config-tree-updated config-tree-deleted config-tree-restored \- config-otel config-jsonl config-jsonl-bad config-interrupted; do- for suffix in img verity roothash p7s; do- [ -s "$SHIRUDO_TEST_KEY_FIXTURES/$name.$suffix" ] &&- [ -s "/var/lib/shirudo/images/$name.$suffix" ] || {- printf 'missing required image fixture: %s.%s\n' "$name" "$suffix" >&2- exit 1- }- done-done-mkdir -p "$SHIRUDO_TEST_RESULTS"-export SHIRUDO_BIN SHIRUDO_TEST_KEY_FIXTURES-export SHIRUDO_TEST_CONFIG_RESULTS="$SHIRUDO_TEST_RESULTS/config"-export SHIRUDO_TEST_SIGNER_RESULTS="$SHIRUDO_TEST_RESULTS/signers"-export SHIRUDO_TEST_INTERRUPTION_RESULTS="$SHIRUDO_TEST_RESULTS/interruption"-export SHIRUDO_TEST_CLI_RESULTS="$SHIRUDO_TEST_RESULTS/cli"-export SHIRUDO_TEST_REVOKE_RESULTS="$SHIRUDO_TEST_RESULTS/revocation"-fail=0-# Boot assertions precede updates; the interruption leaves state pending.-for t in \- tamperproof/t1155-verity-boot-signers.sh \- tamperproof/t1138-mode-objects.sh \- t1200-target-fixtures.sh \- t1103-version-gate.sh \- t1104-payload-mismatch.sh \- t1107-load-unload.sh \- 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 \- tamperproof/t1135-pin-rename.sh \- tamperproof/t1137-bpf-cmd-deny.sh \- tamperproof/t1136-tamper-counters.sh \- tamperproof/t1130-map-lockdown.sh \- tamperproof/t1131-pr-set-mm-identity.sh \- tamperproof/t1132-seal-scratch.sh \- tamperproof/t1125-key-permission.sh \- tamperproof/t1140-verity-authority.sh \- tamperproof/t1150-verity-devices.sh \- tamperproof/t1151-verity-process.sh \- tamperproof/t1153-verity-hidden.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- sh "$t" >"$log" 2>&1 || rc=$?- cat "$log"- if grep -q '^1\.\.0 # SKIP' "$log"; then- printf 'required image suite was skipped: %s\n' "$t" >&2- rc=1- fi- if [ "$rc" -ne 0 ]; then- fail=$((fail + 1))- if [ -n "$SHIRUDO_TEST_SUITE_FAILURES_FILE" ]; then- printf '%s\n' "$t" >>"$SHIRUDO_TEST_SUITE_FAILURES_FILE"- fi- fi-done-[ "$fail" -eq 0 ]diff --git a/testing/t0015-test-vm-cli.sh b/testing/t0015-test-vm-cli.shindex a9875290..bb7e4bab 100755--- a/testing/t0015-test-vm-cli.sh+++ b/testing/t0015-test-vm-cli.sh@@ -39,7 +39,7 @@ test_expect_success 'test-vm prints an install command for missing dependencies'ln -s /bin/bash "$WORK/fake-bin/bash" &&ln -s /usr/bin/dirname "$WORK/fake-bin/dirname" &&for command_name in curl sha256sum awk qemu-system-x86_64 qemu-img \- swtpm timeout tee+ swtpm timeout tee dracut lsinitrd filedoln -s /bin/true "$WORK/fake-bin/$command_name" || return 1done &&@@ -59,7 +59,7 @@ test_expect_success 'test-vm requires the QEMU emulator of the host architectureln -s /bin/bash "$WORK/arm-bin/bash" &&ln -s /usr/bin/dirname "$WORK/arm-bin/dirname" &&for command_name in curl sha256sum awk qemu-system-x86_64 qemu-img \- swtpm timeout tee+ swtpm timeout tee dracut lsinitrd filedoln -s /bin/true "$WORK/arm-bin/$command_name" || return 1done &&@@ -93,7 +93,7 @@ test_expect_success 'TEST_VM_QEMU names another emulator' 'ln -s /bin/bash "$WORK/kvm-bin/bash" &&ln -s /usr/bin/dirname "$WORK/kvm-bin/dirname" &&for command_name in curl sha256sum awk qemu-kvm qemu-img swtpm \- cloud-localds timeout tee flock ssh-keygen ss+ cloud-localds timeout tee flock ssh-keygen ss dracut lsinitrd filedoln -s /bin/true "$WORK/kvm-bin/$command_name" || return 1done &&@@ -396,8 +396,7 @@ test_expect_success 'test-vm imports the host-built payload' 'grep -q "mount_tag=shirudo-bundle" ../contrib/test-vm.sh &&grep -q "importing host-built Shirudo payload" \../contrib/test-vm-guest.sh &&- grep -q "package_cert=\"\${TEST_VM_PACKAGE_CERT:-\$BUNDLE/fixtures/cert.der}\"" \- ../contrib/test-vm-guest.sh &&+ grep -q "mountpoint -q /run/shirudo/runtime" ../contrib/test-vm-guest.sh &&! grep -q "vmlinux.h" ../contrib/test-vm-guest.sh &&! grep -q "shirudo-build" ../contrib/test-vm-guest.sh &&! grep -Fq "make \"\${BPF_MAKE_ARGS[@]}\" check" \@@ -799,7 +798,7 @@ test_expect_success 'test-vm hands off an interactive BPM tree configuration' 'grep -q "mv -f \"\$temporary\" \"\$target\"" ../contrib/test-vm-guest.sh &&grep -q "systemctl start shirudo-bpm-tree-sync.service" ../contrib/test-vm-guest.sh &&grep -q "systemctl enable --now shirudo-bpm-tree-sync.timer" ../contrib/test-vm-guest.sh &&- test "$(grep -n "/usr/local/bin/shirudo init" ../contrib/test-vm-guest.sh | cut -d: -f1)" -lt \+ test "$(grep -n "SHIRUDO_BIN.* init" ../contrib/test-vm-guest.sh | cut -d: -f1)" -lt \"$(grep -n "systemctl start shirudo-bpm-tree-sync.service" ../contrib/test-vm-guest.sh | cut -d: -f1)" &&test "$(grep -n "systemctl start shirudo-bpm-tree-sync.service" ../contrib/test-vm-guest.sh | cut -d: -f1)" -lt \"$(grep -n "systemctl enable --now shirudo-bpm-tree-sync.timer" ../contrib/test-vm-guest.sh | cut -d: -f1)"@@ -829,20 +828,6 @@ test_expect_success 'test-vm validates BPM tree configuration mode and contents'"$WORK/test-bpm-tree.out"'- test_expect_success 'test-vm passes a public package certificate into the guest' '- grep -q "TEST_VM_PACKAGE_CERT" ../testing/Makefile &&- grep -q "TEST_VM_BUNDLE_INPUTS" ../testing/Makefile &&- grep -q "PACKAGE_CERT=\"\${TEST_VM_PACKAGE_CERT:-}\"" \- ../contrib/build-test-vm-bundle.sh &&- grep -q "package-cert.der" ../contrib/build-test-vm-bundle.sh &&- grep -q "export TEST_VM_PACKAGE_CERT=/mnt/shirudo-package-cert/package-cert.der" \- "$RUNNER" &&- grep -q "supported only for interactive make -C testing vm" "$RUNNER" &&- grep -q "TEST_VM_PACKAGE_CERT" ../contrib/test-vm-guest.sh &&- grep -q "install -m 0644 \"\$package_cert\"" \- ../contrib/test-vm-guest.sh-'-test_expect_success 'test-vm validates a custom package certificate before boot' 'printf kernel >"$WORK/package-cert-kernel" &&! TEST_VM_WORK_DIR="$WORK/missing-package-cert" \@@ -904,51 +889,23 @@ test_expect_success 'operator and target runners have disjoint explicit scopes'grep -q "bpm/t0\[0-9\]\[0-9\]\[0-9\]-\*.sh" ../testing/run-tests.sh &&grep -q "tpm/t0\[0-9\]\[0-9\]\[0-9\]-\*.sh" ../testing/run-tests.sh &&! grep -q "t1101" ../testing/run-tests.sh &&- for test_name in \- t1200-target-fixtures.sh \- bpm/t1118-bpm-tree.sh \- bpm/t1119-bpm-tree-sequential.sh \- bpm/t1120-bpm-tree-delete.sh \- tpm/t1102-eventlog-full.sh \- t1103-version-gate.sh \- t1104-payload-mismatch.sh \- t1107-load-unload.sh \- tpm/t1108-tpm-chain.sh \- t1111-upatch-get.sh \- t1114-uprobe-multi.sh \- otel/t1115-map-export-all.sh \- otel/t1116-otel-backend.sh \- otel/t1117-otel-serialized-metric.sh \- t1122-initrd.sh \- t1123-keys.sh \- t1124-keys-add.sh \- t1126-keys-revoke.sh \- tamperproof/t1101-seal.sh \- tamperproof/t1105-siggate.sh \- tamperproof/t1110-lsm-deny.sh \- tamperproof/t1112-prog-load-keyring-gate.sh \- tamperproof/t1113-mount-lockdown.sh \- tamperproof/t1130-map-lockdown.sh \- tamperproof/t1131-pr-set-mm-identity.sh \- tamperproof/t1121-bpf-keyring.sh \- tamperproof/t1125-key-permission.sh \- tamperproof/t1106-keyring-swap.sh+ for test_name in t1200-target-fixtures.sh t1107-load-unload.sh \+ bpm/t1118-bpm-tree.sh tamperproof/t1140-verity-authority.sh \+ tamperproof/t1154-verity-config.sh tamperproof/t1158-verity-interruption.shdogrep -q "$test_name" ../testing/run-target-tests.sh || return 1- done &&- forbidden=$(printf '%s%s' SHIRUDO_ INTEGRATION) &&- ! grep -R -q "$forbidden" ../testing/Makefile ../contrib ../testing+ done'test_expect_success 'test-vm rejects unknown policy modes before boot' '! TEST_VM_MODE=typo "$RUNNER" >"$WORK/policy-mode.out" 2>&1 &&- grep -q "TEST_VM_MODE must be legacy or verity" "$WORK/policy-mode.out"+ grep -q "TEST_VM_MODE must be verity" "$WORK/policy-mode.out"'test_expect_success 'image VM requires initrd enrollment and complete guards' '! TEST_VM_MODE=verity TEST_VM_INITRD=0 "$RUNNER" \>"$WORK/image-initrd.out" 2>&1 &&- grep -q "verity mode requires TEST_VM_INITRD=1" "$WORK/image-initrd.out" &&+ grep -q "dm-verity requires TEST_VM_INITRD=1" "$WORK/image-initrd.out" &&! TEST_VM_MODE=verity TEST_VM_INITRD=1 TEST_VM_SKIP_SEAL=1 "$RUNNER" \>"$WORK/image-seal.out" 2>&1 &&grep -q "TEST_VM_SKIP_SEAL=0" "$WORK/image-seal.out"@@ -957,13 +914,7 @@ test_expect_success 'image VM requires initrd enrollment and complete guards' 'test_expect_success 'image VM refuses an incompatible partial suite' '! TEST_VM_MODE=verity TEST_VM_INITRD=1 TEST_VM_SUITE=tree "$RUNNER" \>"$WORK/image-suite.out" 2>&1 &&- grep -q "verity mode requires the complete test suite" "$WORK/image-suite.out"-'--test_expect_success 'target runner refuses an unknown policy mode' '- ! SHIRUDO_TEST_MODE=typo sh ./run-target-tests.sh \- >"$WORK/target-mode.out" 2>&1 &&- grep -q "SHIRUDO_TEST_MODE must be legacy or verity" "$WORK/target-mode.out"+ grep -q "dm-verity requires the complete test suite" "$WORK/image-suite.out"'test_expect_success 'image target runner refuses missing fixture configuration' 'diff --git a/testing/t0036-gen-initrd-cli.sh b/testing/t0036-gen-initrd-cli.shindex 11bf78fc..304f5b93 100755--- a/testing/t0036-gen-initrd-cli.sh+++ b/testing/t0036-gen-initrd-cli.sh@@ -14,15 +14,8 @@ W=$(mktemp -d)trap 'rm -rf "$W"' EXITprintf 'not a certificate\n' >"$W/cert.der": >"$W/shirudo-target_0_amd64.deb"-printf "eventlog.max_bytes = 1048576\n" >"$W/ordinary.conf"-printf "runtime.image = /var/lib/shirudo/images/runtime\nruntime.root_hash = %064d\n" 0 >"$W/image.conf"--test_expect_success 'the generator prints the kernel parameter the initrd needs' '- [ "$(bash $G --bootstrap-conf "$W/ordinary.conf" --print-cmdline)" = "bpf.keyring_unsealed=1" ]-'--test_expect_success 'image bootstrap also enables boot enrollment in the dm-verity keyring' '- [ "$(bash $G --bootstrap-conf "$W/image.conf" --print-cmdline)" = "bpf.keyring_unsealed=1 dm_verity.keyring_unsealed=1" ]+test_expect_success 'the generator always enables boot enrollment in both keyrings' '+ [ "$(bash $G --print-cmdline)" = "bpf.keyring_unsealed=1 dm_verity.keyring_unsealed=1" ]'test_expect_success 'the generator refuses an unknown option' '@@ -42,10 +35,9 @@ test_expect_success 'the installer plans the package, the certificate and the ingrep -q "reboot\|production configuration" "$W/plan"'-test_expect_success 'the installer with --now plans to start the service' '- bash $I --dry-run --package "$W/shirudo-target_0_amd64.deb" \- --cert "$W/cert.der" --no-cmdline --no-initrd --now |- grep -q "systemctl start shirudo.service"+test_expect_success 'the installer refuses to start the removed root-only mode' '+ ! bash $I --dry-run --now >"$W/now" 2>&1 &&+ grep -q "unknown option" "$W/now"'test_expect_success 'the installer refuses an unknown option' 'diff --git a/testing/t0050-conditions.sh b/testing/t0050-conditions.shindex e15899e0..aa0a9940 100755--- a/testing/t0050-conditions.sh+++ b/testing/t0050-conditions.sh@@ -15,18 +15,7 @@ H=helper/test-conditionstest_expect_success 'the bpf keyring init froze is the production anchor' 'out=$(./$H 1 bpf 100 100 match) &&echo "$out" | grep -qx "status=ok" &&- echo "$out" | grep -qx "KeyringSealed OK serial=100 in the bpf keyring, pin matches"-'--test_expect_success 'a staged user keyring warns' '- out=$(./$H 1 user 200 200 match) &&- echo "$out" | grep -qx "status=ok" &&- echo "$out" | grep -q "^KeyringSealed WARN staging mode: serial=200 in the user keyring;"-'--test_expect_success 'a user keyring without the LSM is not called the bpf keyring' '- ./$H 0 user 300 0 none |- grep -qx "KeyringSealed OK serial=300 in the user keyring, no pin recorded"+ echo "$out" | grep -qx "KeyringSealed OK serial=100 in the BPF keyring, pin matches"'test_expect_success 'before init the keyring is pending, not tampered' '@@ -42,25 +31,18 @@ test_expect_success 'a swapped keyring is tampered' 'echo "$out" | grep -qx "KeyringSealed ALERT pin serial=100 != live serial=101 (swapped?)"'-test_expect_success 'a frozen user keyring that is gone is tampered' '- out=$(./$H 1 user -1 200 match) &&- echo "$out" | grep -qx "status=tampered" &&- echo "$out" | grep -qx "reason=the keyring init froze is gone" &&- echo "$out" | grep -qx "KeyringSealed ALERT pin serial=200, the user keyring is gone (removed?)"-'-test_expect_success 'a frozen bpf keyring that is gone is tampered' 'out=$(./$H 1 bpf -1 100 match) &&echo "$out" | grep -qx "status=tampered" &&- echo "$out" | grep -qx "KeyringSealed ALERT pin serial=100, the bpf keyring is gone (removed?)"+ echo "$out" | grep -qx "KeyringSealed ALERT pin serial=100, the BPF keyring is gone (removed?)"'test_expect_success 'with the LSM off a gone keyring is still tampered' '- ./$H 0 user -1 200 none | grep -qx "status=tampered"+ ./$H 0 bpf -1 200 none | grep -qx "status=tampered"'test_expect_success 'a register mismatch is the reason given first' '- ./$H 1 user -1 200 mismatch |+ ./$H 1 bpf -1 200 mismatch |grep -qx "reason=live register != eventlog replay"'diff --git a/testing/t0051-image-cli.sh b/testing/t0051-image-cli.shindex 1a49471a..051386df 100755--- a/testing/t0051-image-cli.sh+++ b/testing/t0051-image-cli.sh@@ -28,7 +28,7 @@ refused() {if "$H" "$ROOT" "$@" >"$WORK/output" 2>"$WORK/error"; thenreturn 1fi- grep -q "image mode:" "$WORK/error" &&+ grep -Eq "image mode:|target:|keys revoke:" "$WORK/error" &&grep -q "signed.*config" "$WORK/error"}diff --git a/testing/t0053-mode-objects.sh b/testing/t0053-mode-objects.shnew file mode 100755index 00000000..96ad41cf--- /dev/null+++ b/testing/t0053-mode-objects.sh@@ -0,0 +1,36 @@+#!/bin/sh+# SPDX-License-Identifier: BSD-2-Clause+# Copyright (c) 2026 Authors of shirudo++cd "$(dirname "$0")"+. ./test-lib.sh++H=${SHIRUDO_TEST_MODE_OBJECTS_HELPER:-./helper/test-mode-objects}+W=$(mktemp)+trap 'rm -f "$W"' EXIT HUP INT TERM++test_expect_success 'embedded admission and seal always include image enforcement' '+ "$H" >"$W" && python3 - "$W" <<"PYTEST"+import sys+from collections import defaultdict++inventory = defaultdict(lambda: defaultdict(set))+for line in open(sys.argv[1]):+ kind, selection, name = line.split()+ inventory[selection][kind].add(name)+assert set(inventory) == {"admission", "seal"}, inventory+maps = {"shirudo_bpffs_sb", "shirudo_tasks", "shirudo_tamper",+ "shirudo_devices", "shirudo_roots"}+for selection, blob in (("admission", "bpf2"), ("seal", "seal")):+ actual = inventory[selection]+ assert actual["blob"] == {blob}, actual+ assert maps <= actual["map"], actual+assert {"shirudo_lsm_bdev_setintegrity", "shirudo_lsm_bdev_free_security",+ "shirudo_lsm_file_ioctl", "shirudo_lsm_bprm_check_security"} <= inventory["admission"]["program"]+assert {"shirudo_seal_mmap_file", "shirudo_seal_file_mprotect",+ "shirudo_seal_bprm_check_security", "shirudo_seal_inode_setxattr"} <= inventory["seal"]["program"]+assert "bpf_real_data_inode" in inventory["seal"]["extern"]+PYTEST+'++test_donediff --git a/testing/t1122-initrd.sh b/testing/t1122-initrd.shindex 4585dcdb..537c9c20 100755--- a/testing/t1122-initrd.sh+++ b/testing/t1122-initrd.sh@@ -65,7 +65,7 @@ test_expect_success 'the pins and the identity live under /run and survived thegrep -q " /run/shirudo/bpffs bpf " /proc/self/mounts'-test_expect_success 'the root binary is an identity the bpffs guards admit' '+test_expect_success 'the runtime command can check initialization after switch-root' '"$SHIRUDO_BIN" init >/dev/null 2>&1 &&"$SHIRUDO_BIN" status --json >"$STATUS" 2>/dev/null &&[ "$(status_field tpm.bound_in)" = initrd ]diff --git a/testing/t1133-upatch-arena-serializer.sh b/testing/t1133-upatch-arena-serializer.shindex 61396210..adce5702 100644--- a/testing/t1133-upatch-arena-serializer.sh+++ b/testing/t1133-upatch-arena-serializer.sh@@ -12,16 +12,13 @@ FIXTURES=$SHIRUDO_TEST_FIXTURES_DIRNAME=shirudo-test-arena-treeLOAD="$FIXTURES/$NAME.upatch"UNLOAD="$FIXTURES/$NAME.unload.upatch"-PIN="/run/shirudo/bpffs/upatches/$NAME/link"SERIALIZER="/run/shirudo/bpffs/upatches/$NAME/serializers/tree_arena"WORK=/tmp/shirudo-upatch-arena-$$TREE_JSON=$WORK.txtCHECK=$WORK.pyrestore() {- if [ -e "$PIN" ]; then- "$SHIRUDO_BIN" upatch unload "$UNLOAD" --no-precheck \- >/dev/null 2>&1 || true- fi+ "$SHIRUDO_BIN" upatch unload "$UNLOAD" --no-precheck \+ >/dev/null 2>&1 || truerm -f "$TREE_JSON" "$CHECK"}trap restore EXIT@@ -65,6 +62,7 @@ test_expect_success 'loaded arena serializer returns all pages and records' '{if "$SHIRUDO_BIN" upatch map "$NAME" tree_error \>/dev/null 2>&1; then false; fi- }+ } &&+ "$SHIRUDO_BIN" upatch unload "$UNLOAD" --no-precheck >/dev/null 2>&1'test_donediff --git a/testing/t1300-installer-e2e.sh b/testing/t1300-installer-e2e.shdeleted file mode 100755index ba27ca06..00000000--- a/testing/t1300-installer-e2e.sh+++ /dev/null@@ -1,230 +0,0 @@-#!/bin/bash-# SPDX-License-Identifier: BSD-2-Clause-# Copyright (c) 2026 Authors of shirudo-#-# t1300 -- the installer, end to end: boot a stock Ubuntu cloud image in-# QEMU with a vTPM, install the bpf-next kernel packages, reboot into-# that kernel, run tools/gen-initrd/install.sh the way a user would with-# a local target package and the operator's certificate, reboot again-# and check that shirudo came up in the production configuration, bound-# from the initrd. Driven from the host (`make -C testing test-installer`); it-# needs KVM, qemu, swtpm, cloud-localds, the full kernel packages-# (`make -C testing bpf-next`), a target package (`make -C packaging bindeb-pkg-# PKG_ROLES=target`) and a bundle certificate (`make -C testing test-vm-bundle`).-#-# TEST_INSTALLER_KERNEL_DEBS directory with linux-image-*.deb-# TEST_INSTALLER_PACKAGE the shirudo-target .deb to install-# TEST_INSTALLER_CERT the certificate to install (cert.der)-# TEST_INSTALLER_ROOTFS the cloud image (default: the test VM's)-# TEST_INSTALLER_WORK_DIR scratch and logs (default: build/test-installer)-# TEST_INSTALLER_CPUS/MEMORY guest size (default: 4 and 4G)--ORIG_PWD=$PWD-cd "$(dirname "$0")" || exit 1-. ./test-lib.sh-REPO_ROOT=$(cd .. && pwd)--# Inputs come as paths relative to where the caller stood.-abs() {- case "$1" in- ""|/*) printf '%s\n' "$1" ;;- *) printf '%s/%s\n' "$ORIG_PWD" "$1" ;;- esac-}--ROOTFS_NAME=ubuntu-26.04-server-cloudimg-amd64.img-ROOTFS_URL=${TEST_VM_ROOTFS_URL:-https://cloud-images.ubuntu.com/releases/server/26.04/release/$ROOTFS_NAME}-KERNEL_DEBS=$(abs "${TEST_INSTALLER_KERNEL_DEBS:-$REPO_ROOT/artifacts/bpf-next-kernel-debs}")-PACKAGE=$(abs "${TEST_INSTALLER_PACKAGE:-$(ls -t "$REPO_ROOT"/shirudo-target_*.deb 2>/dev/null | head -1)}")-CERT=$(abs "${TEST_INSTALLER_CERT:-$(ls "$REPO_ROOT"/build/test-vm*/host-bundle/fixtures/cert.der 2>/dev/null | head -1)}")-WORK=$(abs "${TEST_INSTALLER_WORK_DIR:-$REPO_ROOT/build/test-installer}")-CPUS=${TEST_INSTALLER_CPUS:-4}-MEMORY=${TEST_INSTALLER_MEMORY:-4G}-ROOTFS=$(abs "${TEST_INSTALLER_ROOTFS:-$(ls "$REPO_ROOT"/build/test-vm*/cache/rootfs/$ROOTFS_NAME 2>/dev/null | head -1)}")--for tool in qemu-system-x86_64 qemu-img swtpm cloud-localds ssh ssh-keygen ss; do- command -v "$tool" >/dev/null 2>&1 || test_skip_all "$tool not found"-done-[ -r /dev/kvm ] && [ -w /dev/kvm ] || test_skip_all "/dev/kvm is not usable"-image_deb=-for f in "$KERNEL_DEBS"/linux-image-[0-9]*.deb; do- case "$f" in *-dbg*) continue ;; esac- [ -e "$f" ] && { image_deb=$f; break; }-done-[ -n "$image_deb" ] || test_skip_all "no linux-image package in $KERNEL_DEBS (make -C testing bpf-next)"-[ -s "$PACKAGE" ] || test_skip_all "no shirudo-target package (make -C packaging bindeb-pkg PKG_ROLES=target)"-[ -s "$CERT" ] || test_skip_all "no certificate to install (TEST_INSTALLER_CERT)"-KREL=$(basename "$image_deb" | sed -n 's/^linux-image-\([^_]*\)_.*/\1/p')-[ -n "$KREL" ] || test_skip_all "cannot tell the kernel release from $image_deb"--mkdir -p "$WORK"-if [ ! -s "$ROOTFS" ]; then- ROOTFS=$WORK/$ROOTFS_NAME- if [ ! -s "$ROOTFS" ]; then- echo "# downloading $ROOTFS_URL" >&2- curl -fsSL -o "$ROOTFS.tmp" "$ROOTFS_URL" &&- curl -fsSL -o "$WORK/SHA256SUMS" "${ROOTFS_URL%/*}/SHA256SUMS" &&- (cd "$WORK" && grep " \*$ROOTFS_NAME\$" SHA256SUMS |- sed "s|\\*$ROOTFS_NAME|$ROOTFS_NAME.tmp|" | sha256sum -c --quiet -) &&- mv "$ROOTFS.tmp" "$ROOTFS" || test_skip_all "cannot fetch the cloud image"- fi-fi--RUN=$WORK/run.$$-mkdir -p "$RUN/tpm"-SSH_KEY=$RUN/id_ed25519-ssh-keygen -q -t ed25519 -N '' -f "$SSH_KEY" >/dev/null-SSH_PORT=-for p in $(seq 22100 22199); do- ss -ltn 2>/dev/null | grep -q ":$p " || { SSH_PORT=$p; break; }-done-[ -n "$SSH_PORT" ] || test_skip_all "no free ssh port"-SSH_OPTS=(-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null- -o ConnectTimeout=5 -o LogLevel=ERROR -o BatchMode=yes- -i "$SSH_KEY" -p "$SSH_PORT")-QEMU_PID=-SWTPM_PID=--# -n: a caller may drive this test with a script on stdin.-vm_ssh() {- ssh -n "${SSH_OPTS[@]}" [email protected] "$@"-}--vm_scp() {- scp -q "${SSH_OPTS[@]/-p/-P}" "$@"-}--vm_wait_ssh() {- local _- for _ in $(seq 1 120); do- vm_ssh true 2>/dev/null && return 0- sleep 5- done- return 1-}--vm_wait_down() {- local _- for _ in $(seq 1 60); do- kill -0 "$QEMU_PID" 2>/dev/null || return 0- sleep 2- done- return 1-}--vm_start() {- local tag=$1-- swtpm socket --tpmstate "dir=$RUN/tpm" --tpm2 --daemon \- --ctrl "type=unixio,path=$RUN/tpm/sock" \- --pid "file=$RUN/tpm/pid" --log "file=$RUN/tpm/log,level=5" || return 1- SWTPM_PID=$(cat "$RUN/tpm/pid")- qemu-system-x86_64 -enable-kvm -cpu host -machine q35 -smp "$CPUS" -m "$MEMORY" \- -drive "file=$RUN/disk.qcow2,if=virtio,format=qcow2" \- -drive "file=$RUN/seed.img,if=virtio,format=raw,readonly=on" \- -netdev "user,id=net0,hostfwd=tcp:127.0.0.1:$SSH_PORT-:22" \- -device virtio-net-pci,netdev=net0 \- -chardev "socket,id=chrtpm,path=$RUN/tpm/sock" \- -tpmdev emulator,id=tpm0,chardev=chrtpm -device tpm-tis,tpmdev=tpm0 \- -display none -serial "file:$RUN/console-$tag.log" \- -pidfile "$RUN/qemu.pid" -daemonize || return 1- QEMU_PID=$(cat "$RUN/qemu.pid")- vm_wait_ssh-}--# A reboot keeps QEMU and the TPM state: the vTPM resets with the guest.-vm_reboot() {- vm_ssh reboot >/dev/null 2>&1 || true- sleep 15- vm_wait_ssh-}--vm_stop() {- [ -n "$QEMU_PID" ] && kill -0 "$QEMU_PID" 2>/dev/null && {- vm_ssh poweroff >/dev/null 2>&1 || true- vm_wait_down || kill "$QEMU_PID" 2>/dev/null || true- }- [ -n "$SWTPM_PID" ] && kill "$SWTPM_PID" 2>/dev/null- QEMU_PID=- SWTPM_PID=-}--cleanup() {- vm_stop- [ "${KEEP_RUN:-0}" = 1 ] || rm -rf "$RUN/disk.qcow2" "$RUN/seed.img" "$RUN/tpm"-}-trap cleanup EXIT--qemu-img create -q -f qcow2 -F qcow2 -b "$ROOTFS" "$RUN/disk.qcow2" 20G ||- test_skip_all "cannot create the disk overlay"-cat >"$RUN/user-data" <<EOF-#cloud-config-disable_root: false-ssh_pwauth: false-users:- - name: root- ssh_authorized_keys:- - $(cat "$SSH_KEY.pub")-growpart:- mode: auto- devices: ['/']-EOF-printf 'instance-id: shirudo-installer-%s\nlocal-hostname: shirudo-installer\n' "$$" >"$RUN/meta-data"-cloud-localds "$RUN/seed.img" "$RUN/user-data" "$RUN/meta-data" >/dev/null 2>&1 ||- test_skip_all "cloud-localds failed"--test_expect_success 'the stock cloud image boots and answers over ssh' '- vm_start boot1-'--test_expect_success 'the bpf-next kernel packages install and grub lists the kernel' '- vm_scp "$KERNEL_DEBS"/linux-image-[0-9]*.deb [email protected]:/root/ &&- vm_ssh "DEBIAN_FRONTEND=noninteractive dpkg -i /root/linux-image-*.deb >/root/kernel-install.log 2>&1 || { tail -20 /root/kernel-install.log; exit 1; }" &&- vm_ssh "grep -q \"$KREL\" /boot/grub/grub.cfg"-'--test_expect_success 'the guest reboots into the bpf-next kernel' '- vm_reboot &&- [ "$(vm_ssh uname -r)" = "$KREL" ] &&- vm_ssh test -c /dev/tpmrm0-'--test_expect_success 'the installer installs the package, the certificate, the command line and the initrd' '- vm_scp "$PACKAGE" [email protected]:/root/shirudo-target.deb &&- vm_scp "$CERT" [email protected]:/root/cert.der &&- vm_scp "$REPO_ROOT/tools/gen-initrd/install.sh" [email protected]:/root/install.sh &&- vm_ssh "bash /root/install.sh --package /root/shirudo-target.deb --cert /root/cert.der --switch-to-dracut >/root/install.log 2>&1 || { tail -30 /root/install.log; exit 1; }" &&- vm_ssh "grep -q bpf.keyring_unsealed=1 /boot/grub/grub.cfg" &&- vm_ssh "shirudo-gen-initrd --check /boot/initrd.img-$KREL >/dev/null" &&- vm_ssh "systemctl is-enabled shirudo.service >/dev/null"-'--test_expect_success 'the guest reboots into the production configuration' '- vm_reboot &&- vm_ssh "grep -q -w bpf.keyring_unsealed=1 /proc/cmdline" &&- vm_ssh "shirudo status --json" >"$RUN/status.json" &&- python3 - "$RUN/status.json" <<"PY"-import json, sys-d = json.load(open(sys.argv[1], encoding="utf-8"))-assert d["mode"] == "production", d["mode"]-assert d["tpm"]["bound_in"] == "initrd", d["tpm"]-assert d["keyring_mode"] == "bpf", d["keyring_mode"]-PY-'--test_expect_success 'the initrd unit completed init and the root adopted its record' '- vm_ssh "journalctl -b -u shirudo-initrd.service --no-pager | grep -q \"init: complete\"" &&- vm_ssh "systemctl is-active shirudo.service >/dev/null" &&- vm_ssh "test ! -e /run/shirudo/eventlog.pending" &&- vm_ssh "grep -q \"\\\"bound_in\\\":\\\"initrd\\\"\" /var/lib/shirudo/eventlog"-'--test_expect_success 'the initrd target test passes on the installed system' '- vm_ssh "mkdir -p /root/testing" &&- vm_scp test-lib.sh integration-lib.sh t1122-initrd.sh [email protected]:/root/testing/ &&- vm_ssh "cd /root/testing && SHIRUDO_BIN=/usr/bin/shirudo sh ./t1122-initrd.sh" >"$RUN/t1122.log" 2>&1 &&- ! grep -q "^not ok" "$RUN/t1122.log" &&- grep -q "^ok 1" "$RUN/t1122.log"-'--test_donediff --git a/testing/tamperproof/t1131-pr-set-mm-identity.py b/testing/tamperproof/t1131-pr-set-mm-identity.pyindex b7d42324..78718e39 100644--- a/testing/tamperproof/t1131-pr-set-mm-identity.py+++ b/testing/tamperproof/t1131-pr-set-mm-identity.py@@ -20,14 +20,10 @@ libc.prctl.restype = ctypes.c_intlibc.syscall.restype = ctypes.c_longctypes.set_errno(0)-mode_result = libc.prctl(0x53520001, 0, 0, 0, 0)-mode_errno = ctypes.get_errno()-assert mode_result == -1 and mode_errno in (errno.EINVAL, 1001, 1002), \- ("Shirudo mode query", mode_result, mode_errno)-IMAGE_MODE = mode_errno == 1002+result = libc.prctl(0x53520001, 0, 0, 0, 0)+assert result == -1 and ctypes.get_errno() == 1002, "enforcement missing"SHIRUDO = os.path.abspath(os.environ.get("SHIRUDO_TEST_RUNTIME_BIN",- RUNTIME + "/usr/bin/shirudo")) \- if IMAGE_MODE else SHIRUDO_COMMAND+ RUNTIME + "/usr/bin/shirudo"))SHIRUDO_ID = os.stat(SHIRUDO).st_dev, os.stat(SHIRUDO).st_inoOTHER = next(os.path.realpath(path) for path in("/bin/true", "/usr/bin/true", sys.executable)@@ -73,25 +69,15 @@ class MapInfoPrefix(ctypes.Structure):class ShirudoIdentity(ctypes.Structure):_fields_ = [("sb_dev", ctypes.c_uint32),- ("exe_dev", ctypes.c_uint32),- ("exe_ino", ctypes.c_uint64),+ ("run_dev", ctypes.c_uint32),("keyring_serial", ctypes.c_int32),("keyring_type", ctypes.c_uint32),- ("alt_exe_dev", ctypes.c_uint32),- ("pad", ctypes.c_uint32),- ("alt_exe_ino", ctypes.c_uint64),("n_keys", ctypes.c_uint32),- ("pad2", ctypes.c_uint32),- ("key_serials", ctypes.c_int32 * 16)]---class ShirudoImageIdentity(ShirudoIdentity):- _fields_ = [("runtime_mode", ctypes.c_uint32),- ("run_dev", ctypes.c_uint32),+ ("key_serials", ctypes.c_int32 * 16),("runtime_root", ctypes.c_uint8 * 32)]-def assert_frozen_executable_identity():+def assert_frozen_runtime():path = b"/run/shirudo/bpffs/identity\0"name = ctypes.create_string_buffer(path)get_attr = ObjGetAttr(ctypes.addressof(name), 0, BPF_F_RDONLY)@@ -119,24 +105,12 @@ def assert_frozen_executable_identity():finally:os.close(fd)value = ShirudoIdentity.from_buffer_copy(buffer.raw)- if IMAGE_MODE:- assert info.value_size >= ctypes.sizeof(ShirudoImageIdentity), \- ("image identity extension missing", info.value_size)- image = ShirudoImageIdentity.from_buffer_copy(buffer.raw)- assert image.runtime_mode == 1 and any(image.runtime_root), \- ("frozen image trust mode", image.runtime_mode)- executable = os.path.realpath(SHIRUDO)- runtime = os.path.realpath(RUNTIME)- assert os.path.commonpath((executable, runtime)) == runtime, executable- assert os.stat(executable).st_dev == os.stat(runtime).st_dev, executable- return- if info.value_size >= ctypes.sizeof(ShirudoImageIdentity):- image = ShirudoImageIdentity.from_buffer_copy(buffer.raw)- assert image.runtime_mode == 0, ("legacy trust mode", image.runtime_mode)- st = os.stat(SHIRUDO)- expected_dev = (os.major(st.st_dev) << 20) | os.minor(st.st_dev)- assert (value.exe_dev, value.exe_ino) == (expected_dev, st.st_ino), \- ((value.exe_dev, value.exe_ino), (expected_dev, st.st_ino))+ assert info.value_size == ctypes.sizeof(ShirudoIdentity), info.value_size+ assert any(value.runtime_root), "runtime hash missing"+ executable = os.path.realpath(SHIRUDO)+ runtime = os.path.realpath(RUNTIME)+ assert os.path.commonpath((executable, runtime)) == runtime, executable+ assert os.stat(executable).st_dev == os.stat(runtime).st_dev, executableclass PrctlMmMap(ctypes.Structure):@@ -227,7 +201,7 @@ def mm_map_result(path):assert after == before, (before, after)-assert_frozen_executable_identity()+assert_frozen_runtime()assert child_succeeds(lambda: exe_file_result(SHIRUDO)), \"PR_SET_MM_EXE_FILE was allowed for a non-Shirudo caller"diff --git a/testing/tamperproof/t1132-seal-scratch.sh b/testing/tamperproof/t1132-seal-scratch.shindex 21f40c53..cf29ff41 100644--- a/testing/tamperproof/t1132-seal-scratch.sh+++ b/testing/tamperproof/t1132-seal-scratch.sh@@ -16,10 +16,7 @@ for c in python3 mkfs.ext4 debugfs; docommand -v "$c" >/dev/null 2>&1 || test_skip_all "no $c"done-case "${SHIRUDO_TEST_MODE:-legacy}" in-verity) STATE=/var/lib/shirudo/eventlog ;;-*) STATE=/var/lib/shirudo/keys/cert.der ;;-esac+STATE=/var/lib/shirudo/eventlog[ -e "$STATE" ] || test_skip_all "no labelled state at $STATE"WORK=$(mktemp -d) || test_skip_all "cannot make a scratch directory"MNT=$WORK/mntdiff --git a/testing/tamperproof/t1134-seal-task.sh b/testing/tamperproof/t1134-seal-task.shindex c21fa329..2a313e6b 100755--- a/testing/tamperproof/t1134-seal-task.sh+++ b/testing/tamperproof/t1134-seal-task.sh@@ -3,7 +3,7 @@# Copyright (c) 2026 Authors of shirudo## t1134 -- the seal's task hooks (bpf/seal.c ptrace_access_check and-# perf_event_alloc): a task that runs the labelled shirudo binary can+# perf_event_alloc): a task that runs the runtime shirudo binary can# neither be ptrace-attached nor have a perf event bound to it, even by# root. The task is a shirudo blocked on opening a fifo, released at# the end. Non-destructive.diff --git a/testing/tamperproof/t1138-mode-objects.sh b/testing/tamperproof/t1138-mode-objects.shindex cf683121..6e94bbfa 100755--- a/testing/tamperproof/t1138-mode-objects.sh+++ b/testing/tamperproof/t1138-mode-objects.sh@@ -6,19 +6,11 @@ cd "$(dirname "$0")/..". ./integration-lib.shtarget_guard-mode_pins() {- for pin in devices config_roots file_ioctl_link \- bdev_integrity_link bdev_free_link seal_mmap_link seal_mprotect_link; do- case "${SHIRUDO_TEST_MODE:-legacy}" in- verity) [ -e "/run/shirudo/bpffs/$pin" ] || return 1 ;;- legacy) [ ! -e "/run/shirudo/bpffs/$pin" ] || return 1 ;;- *) return 1 ;;- esac+test_expect_success 'device, memory and config-root guards are pinned' '+ for pin in devices config_roots file_ioctl_link bdev_integrity_link \+ bdev_free_link seal_mmap_link seal_mprotect_link; do+ [ -e "/run/shirudo/bpffs/$pin" ] || return 1done-}--test_expect_success 'only image mode pins image device and executable guards' '- mode_pins'test_donediff --git a/testing/tamperproof/t1153-verity-hidden.sh b/testing/tamperproof/t1153-verity-hidden.shindex 6bd4b0d8..834bcfee 100755--- a/testing/tamperproof/t1153-verity-hidden.sh+++ b/testing/tamperproof/t1153-verity-hidden.sh@@ -15,7 +15,7 @@ mountpoint -q /run/shirudo/runtime && [ -x "$SHIRUDO_TEST_RUNTIME_BIN" ] ||verity_required "requires the executable from the runtime image"command -v python3 >/dev/null 2>&1 || verity_required "no python3"-test_expect_success 'hidden bpffs cannot make an image executable initialize legacy state' '+test_expect_success 'hidden bpffs cannot make an image executable fall back to writable host settings' 'python3 tamperproof/t1153-verity-hidden.py "$SHIRUDO_TEST_RUNTIME_BIN"'diff --git a/testing/tamperproof/t1157-verity-cli.py b/testing/tamperproof/t1157-verity-cli.pyindex 4f6a7350..b3eb7563 100644--- a/testing/tamperproof/t1157-verity-cli.py+++ b/testing/tamperproof/t1157-verity-cli.py@@ -31,7 +31,7 @@ def main():config.run(label, *arguments, success=mode == "help")if mode != "help":error = (config.RESULTS / (label + ".stderr")).read_text()- config.require("image mode:" in error and "signed" in error,+ config.require(any(prefix in error for prefix in ("image mode:", "target:", "keys revoke:")) and "signed" in error,"missing image-mode guidance: " + error)wanted = "reboot" if mode == "enrollment" else "shirudo image update"config.require(wanted in error, "missing recovery action: " + error)