Skip to content

eBPF-based security platform

docs: describe dm-verity as the target setup

KP Singhaa2b9087a159
diff --git a/AGENTS.md b/AGENTS.md
index 341e7434..5f6acfa2 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -196,33 +196,14 @@ one usually still compiles and passes tests.
userspace calls are filtered.
- **The operator never touches the kernel keyring or the TPM; the
target never touches the private key.**
-- **The bpf keyring is the trust anchor.** In ordinary mode, the user
- keyring provides staging. `init` enrols the trusted set in the kernel's
- `.bpf` keyring and seals it, which needs the kernel booted with `bpf.keyring_unsealed=1`
- and `init` run from the initrd; a kernel that sealed it empty at boot
- makes `init` stage the primary certificate alone in a sealed
- `shirudo` user keyring until the next reboot. The set (`util/keys.c`)
- is `cert.der` plus every `trusted/<fingerprint>.der` with a vouch
- beside it that verifies under a member, less what `revoked/` names;
- a file without a vouch is not a member, so the set extends itself
- only on the word of a key already in it (`keys vouch` on the
- operator, `keys add` on the target). The kind and serial of the
- keyring `init` sealed, and the serials of its keys, live in the
- identity map it freezes and pins in the bpffs; a load names the
- keyring that record says, `lsm/bpf_prog_load` admits only that kind,
- and for a staged user keyring only that serial (the kernel records
- none for its own bpf keyring), and `lsm/key_permission` lets shirudo
- alone write, unlink or revoke the keyring and its keys. Staging has a
- reproduced invalidation exception through possessed `KEY_NEED_SEARCH`
- references.
- `keys revoke` is the ordinary authorized revocation path: marker in
- `revoked/` first, then the unlink, the measured `key_revoke` event
- and the purge of everything the key signed. There is no file pin to
- forge or lose. Image mode requires the `.bpf` keyring and refuses
- staging. It enrols the verified config's signer set at boot. Live
- signed config activation can revoke an enrolled signer and purge its
- upatches, but cannot enrol a new signer. Local `keys add` and
- `keys revoke` are refused in image mode.
+- **The bpf keyring is the trust anchor.** Every target requires the kernel
+ `.bpf` keyring. Boot with `bpf.keyring_unsealed=1`; init verifies the runtime
+ and signed config, enrolls the initial certificate and vouched boot signer
+ set, then seals the ring. No user-keyring staging is supported. The frozen
+ record and BPF admission checks enforce that ring. Live signed config can
+ revoke an enrolled key and purge its upatches, but cannot enroll a new key.
+ Target-local key changes are refused. BPF upatches always require signed
+ loaders; a signed config does not authorize unsigned BPF.
- **The operator is stateless.** It writes only the keypair (`genkey`)
and the artifacts or reports the caller names. No hidden caches,
state files, logs or staging directories; `--expect-chain` comes
@@ -256,33 +237,20 @@ one usually still compiles and passes tests.
value the target wrote about itself is not a check.
- **Pin the bpf_link before anything else fallible** in `shirudo init`,
or a crash leaves an attached, unowned link that the kernel detaches.
-- **init runs twice in production.** In ordinary mode, the
- initrd run (`shirudo-initrd.service`, detected by `/etc/initrd-release`
- with the root at `/sysroot`) enrols the initrd's own
- `/etc/shirudo/keys/cert.der`, attaches the LSM with its pins under
- `/run/shirudo/bpffs`, records the root's binary as the lasting
- identity beside its own, restores the archived upatches read through
- a read-only bind of `/sysroot/var/lib/shirudo`, binds the register
- and leaves the init record at `/run/shirudo/eventlog.pending`. The
- root run labels the tree and adopts that record. Anything else the
- initrd would write to the root is wrong: the root is read-only there,
- and `/run` is the only thing systemd carries across switch-root
- besides the API file systems. Image mode instead requires writable
- persistent state during initrd startup, binds it writable and labels
- it before attaching enforcement. Config activation writes its durable
- image cache and pending selection there. The initrd enrolls the config
- certificate into the kernel's .dm-verity keyring and seals it; built-in
- dm-verity trust remains accepted. Executable authority comes from a task
- mark committed after successful exec from the trusted runtime image;
- the authenticated bootstrap task has temporary authority to complete
- initialization. Non-systemd initrds are unsupported.
-- **Seal labels mark targets, not caller authority.** Ordinary mode
- authorizes the frozen executable device/inode or its initrd copy; image
- mode authorizes the committed task mark. A copied label grants neither.
- Only an authorized caller may set the exact seal xattr. The seal checks
- labelled targets on write open, unlink, both rename endpoints, setattr
- and xattr changes. Ordinary mode allows replacing the recorded primary
- executable for upgrades without granting its replacement authority.
+- **init runs twice in production.** The authenticated systemd initrd binds
+ persistent state writable, verifies runtime and config, enrolls and seals the
+ `.bpf` and `.dm-verity` keyrings, labels state, attaches all guards, restores
+ signed upatches and binds the register. Mounts and pins live under `/run`
+ across switch-root. The root service uses the verified runtime and adopts
+ the pending initrd event. Missing images or settings are errors. No mode
+ selector, executable inode identity or unsealed fallback may be added.
+- **Seal labels mark targets, not caller authority.** Only successful exec
+ from the authenticated runtime grants the committed task mark. Fork inherits
+ it, successful exec re-evaluates it and failed exec preserves it. Writable
+ state retains its seal xattrs; runtime and config files use dm-verity. Only
+ an authorized caller may set the exact seal xattr. Both rename endpoints,
+ write open, unlink, setattr and xattr changes are checked. There is no
+ executable replacement exception.
Label read errors require authority except ENODATA, EOPNOTSUPP, EACCES
and EPERM; scratch allocation failure also requires authority. The seal
labels new inodes during creation when the parent has a cached directory
@@ -362,11 +330,9 @@ one usually still compiles and passes tests.
`make -C testing SANITIZE=address,undefined test-op` runs it under ASan and
UBSan (CI does too); `make -C testing test-tgt` runs the target suite in the
QEMU/swtpm VM (`make -C testing help` lists the VM target groups).
-- `make -C testing test-tgt TEST_VM_INITRD=1` boots the guest from a dracut initrd
- that runs `shirudo-initrd.service`; CI runs `test-tgt` both ways through
- `.github/scripts/target-tests.sh`. `make -C testing test-installer` runs
- `testing/t1300-installer-e2e.sh`, the installer end to end in a QEMU
- guest with a vTPM, two reboots included.
+- `sudo make -C testing test-tgt` always boots the dm-verity runtime and signed
+ config from a dracut initrd. CI runs that same required suite through
+ `.github/scripts/target-tests.sh`; the old root-only installer suite is gone.
- `make -C testing fuzz [FUZZ_SECONDS=60]` runs the libFuzzer targets in
`testing/fuzz/` for the parsers of input from outside the host, under
ASan and UBSan, on their seed corpora; CI runs them too. A parser that
diff --git a/Documentation/architecture.rst b/Documentation/architecture.rst
index cb9db071..d2bc5f4c 100644
--- a/Documentation/architecture.rst
+++ b/Documentation/architecture.rst
@@ -161,16 +161,14 @@ parameterised with the target name and the expected payload digest.
Load. ``shirudo upatch load fix.upatch`` on the target:
1. runs the pre-flight: the kernel exposes the signed-loader ABI, the
- keyring ``init`` pinned is there (the bpf keyring, or while staging
- the ``shirudo`` keyring whose serial equals the pin), the
+ kernel BPF keyring matches the serial ``init`` froze, the
enforcement link is pinned, the eventlog has room, the binary's
version identity matches ``--expect-version-id`` when given, and
the register is the one ``init`` bound and equals ``--expect-chain``
when given;
2. parses and bounds-checks the container;
3. loads the signed loader with ``BPF_PROG_LOAD``, naming that keyring
- as ``attr.keyring_id`` (``KEY_SPEC_BPF_KEYRING``, or the staged
- keyring's serial); the kernel verifies the CMS signature here;
+ as ``attr.keyring_id`` (``KEY_SPEC_BPF_KEYRING``); the kernel verifies the CMS signature here;
4. runs the loader under ``BPF_PROG_TEST_RUN``; it creates the maps and
loads the payload program, which the kernel checks against the
loader's ``excl_prog_hash``;
@@ -208,20 +206,17 @@ target ELF's GNU build ID. The format specification has the encoding.
6) Enforcement in the kernel
----------------------------
-The ordinary installation uses the executable identities and seal described
-below. The opt-in dm-verity mode uses an authenticated executable image
-and committed task authority instead; its differences follow at the end of
-this section and in `config-images <config-images.rst>`__.
-
-The binary embeds a pair of BPF objects for each mode. Ordinary mode uses
-``bpf/bpf2.c`` for BPF admission and bpffs protection, and ``bpf/seal.c`` for
-file labels and process protection. Image mode uses ``bpf/bpf2_verity.c``
-and ``bpf/seal_verity.c`` instead. Its objects add verified-device tracking,
-DM ioctl restrictions, runtime exec authority and executable-mapping checks.
-``shirudo init`` opens and loads only the selected pair. The common admission
-and seal programs live in ``bpf/admission.h`` and ``bpf/seal.h``; each mode
-supplies its own caller check through its policy header. Writable state keeps
-the same xattr protection in both modes.
+The target requires an authenticated runtime image and a signed config image.
+The runtime is mounted at ``/run/shirudo/runtime`` and the config at
+``/run/shirudo/config`` with ``noexec``. Neither replaces the host root.
+Every runtime executable is eligible for task authority after successful exec.
+
+The binary embeds ``bpf/bpf2.c`` for admission, device and mount protection,
+and ``bpf/seal.c`` for writable-state labels and process protection.
+``bpf/admission.h`` and ``bpf/seal.h`` contain the checks shared by their
+programs; ``bpf/verity_policy.h`` supplies runtime-device and task lookups.
+Initialization always loads this pair and all its hooks. There is no mode
+selector, executable inode identity or user-keyring staging path.
These are bootstrap objects, not signed upatch-loader artifacts. In the
production boot flow their provenance comes from the authenticated initrd.
@@ -238,16 +233,12 @@ kernel context and false for userspace. Kernel-context calls are
allowed; they come from a loader the kernel has already verified.
Userspace ``BPF_PROG_LOAD`` is allowed only for ``BPF_PROG_TYPE_SYSCALL``
with a non-zero ``signature_size``. Userspace ``BPF_PROG_TEST_RUN`` is
-restricted to the executable recorded at ``init``; kernel-context calls
-from verified loaders remain allowed. This lets shirudo run loaders and
-serializers while preventing root from invoking a serializer to drain
-its maps. Allowed without a signature are the commands
-that cannot introduce code: map create only from the executable
-``init`` recorded as shirudo (signed-loader map creation runs in kernel
-context and is already allowed), map update and freeze only from
-shirudo's executable, and object pin, link create and raw tracepoint open
-only from shirudo's executable. In image mode these operations require
-committed task authority instead. The read-only commands (``*_GET_FD_BY_ID``,
+restricted to tasks authorized by successful exec from the runtime image;
+kernel-context calls from verified loaders remain allowed. This lets Shirudo
+run loaders and serializers while preventing root from invoking a serializer
+to drain its maps. Map creation, update and freeze, object pin, link creation
+and raw tracepoint open also require that task authority.
+The read-only commands (``*_GET_FD_BY_ID``,
``*_GET_NEXT_ID``, ``OBJ_GET_INFO_BY_FD``,
``MAP_LOOKUP_ELEM``, ``MAP_LOOKUP_BATCH``, ``MAP_GET_NEXT_KEY``,
``PROG_QUERY``, ``TASK_FD_QUERY``) keep
@@ -257,20 +248,15 @@ Everything else, including
``LINK_DETACH``, ``LINK_UPDATE``, ``PROG_ATTACH``/``PROG_DETACH``,
``BTF_LOAD`` and every map delete variant, is denied with ``-EACCES``.
-``lsm/bpf_map`` denies writable map file descriptors when the caller's
-executable identity is not shirudo. Root can retrieve read-only map fds
-for observation, but direct map updates and writable mappings of arena
-maps are denied. The ``task_prctl`` hook denies
-``PR_SET_MM_EXE_FILE`` and ``PR_SET_MM_MAP`` to callers whose executable
-identity is not the frozen Shirudo executable or its initrd copy. This
-also denies these two operations to checkpoint and restore tools. A
-process that directly executes the recorded Shirudo binary is still
-identified as Shirudo; its command interface is the authorization
-boundary for those operations.
+``lsm/bpf_map`` denies writable map descriptors to tasks without authority.
+Root can retrieve read-only map descriptors for observation, but direct map
+updates and writable arena mappings require an authorized task. Device records
+are private because they contain kernel pointers. ``task_prctl`` denies
+``PR_SET_MM_EXE_FILE`` and ``PR_SET_MM_MAP`` to untrusted tasks. Rewriting
+``mm->exe_file`` never creates task authority.
``lsm/bprm_check_security`` keeps that boundary from being stepped
-around through the environment: every exec of the recorded executable
-or its initrd copy runs in secure-exec mode (``AT_SECURE``), as a
+around through the environment: every exec from the runtime image runs in secure-exec mode (``AT_SECURE``), as a
set-user-ID program does. The dynamic loader then ignores
``LD_PRELOAD``, ``LD_AUDIT``, ``LD_LIBRARY_PATH`` and the other
variables glibc treats as unsafe, and libraries ignore what they read
@@ -285,24 +271,21 @@ on every binary handler pass, so a script that names shirudo as its
interpreter gets the same.
``lsm/bpf_prog_load`` runs after the kernel's signature check and admits
-a program only when the verdict is ``BPF_SIG_VERIFIED`` and the
-signature was resolved from the keyring whose kind shirudo froze into
-its identity map at init: the kernel's own bpf keyring, which the kernel
-resolves itself and records without a serial, or in staging mode the
-user keyring whose serial was frozen alongside. A certificate planted
-anywhere else in the caller's keyrings does not count.
-
-bpffs and keyring guards. The identity map (the bpffs ``s_dev``,
-shirudo's executable ``(dev, ino)``, the keyring kind and serial, and
-the serials of the keys the keyring holds) is written and
-``BPF_MAP_FREEZE``'d before any link is created, so userspace cannot
-change it for the rest of the boot. Writable map fds, map updates,
-link creation, raw tracepoint opens and pins are restricted by the
-same executable-identity gate.
+a program only when the verdict is ``BPF_SIG_VERIFIED`` and the signature
+was resolved from the kernel's BPF keyring. The kernel normally records no
+serial for this singleton; a nonzero serial must match the frozen record.
+A certificate in another caller keyring cannot authorize a load.
+
+bpffs and keyring guards. The identity map contains the bpffs and run-device
+numbers, runtime root hash, BPF keyring kind and serial, and enrolled key
+serials. It is written and frozen before the admission gates attach.
+The task map is seeded with the authenticated bootstrap task, then frozen
+against userspace writes. Runtime exec and fork hooks maintain its marks.
+Expected config roots remain writable only by trusted tasks preparing a
+mapping. Other device records are maintained by the kernel hooks.
``lsm/inode_unlink``, ``lsm/inode_rename``,
``lsm/inode_setxattr`` and ``lsm/inode_removexattr`` on shirudo's bpffs
-allow the operation only when the calling task's ``mm->exe_file`` is
-shirudo's binary: root ``rm`` cannot drop a pin, ``mv`` cannot replace
+allow the operation only for a task with runtime authority: root ``rm`` cannot drop a pin, ``mv`` cannot replace
one (the VFS unlinks a rename's victim without ``inode_unlink``), and
nobody else can forge the payload xattr. ``lsm/key_permission`` applies the same test
to the trust anchor in the kernel's keyrings: write, setattr and unlink
@@ -311,7 +294,7 @@ search ``keyctl invalidate`` uses to reach a key by serial, are denied
to every task but shirudo, while viewing, listing and the possessed
search the kernel verifies signatures with stay open. Sealing stops
keys from being added; this stops root from taking them away, so that
-unlinking a key is ``shirudo keys revoke`` and nothing else.
+signer removal happens through signed config activation.
``lsm/sb_umount``, ``lsm/move_mount``,
``lsm/sb_mount`` and ``lsm/sb_remount`` deny unconditionally, for every
caller including shirudo, direct unmount, relocation, mount-over and
@@ -322,18 +305,16 @@ The pins are the only thing
keeping the enforcement programs alive, and one ``umount`` would
otherwise detach everything. Named refusal points increment counters in
a frozen map pinned beside the identity map
-(``bpf/lib/shirudo_tamper.h``); ``shirudo status`` reads it back. Image-only
-device, parent-mount and process checks do not yet have counters. A refusal
+(``bpf/lib/shirudo_tamper.h``); ``shirudo status`` reads it back. Device, parent-mount and process checks do not yet have counters. A refusal
at an earlier image check therefore need not increment a shared counter.
Filesystem seal. Initialization labels existing state under
-``/var/lib/shirudo/`` and, in ordinary mode, the installed binary with
-``security.bpf.shirudo``. The fixed 64-byte label marks a protected target;
-its public value does not identify an authorized caller. The ``file_open``
-(for write), ``inode_unlink``, ``inode_rename``, ``inode_setattr``,
-``inode_setxattr`` and ``inode_removexattr`` hooks require the ordinary
-caller's executable to match the frozen ``(dev, ino)`` identity or its
-initrd copy. Image mode instead requires committed task authority.
+``/var/lib/shirudo/`` with ``security.bpf.shirudo``. The fixed 64-byte label
+marks a protected target; its public value does not authorize a caller.
+The ``file_open`` (for write), ``inode_unlink``, ``inode_rename``,
+``inode_setattr``, ``inode_setxattr`` and ``inode_removexattr`` hooks require
+the caller's committed task authority. Runtime and config files use dm-verity
+and receive no seal writes.
Only an authorized caller may set the exact seal xattr, including on an
unlabelled inode. A binary carrying a copied label gains no authority.
@@ -342,9 +323,7 @@ except for ``ENODATA``, ``EOPNOTSUPP``, ``EACCES`` and ``EPERM``. The latter
two exceptions preserve write-only opens and unlinking unreadable files:
the xattr kfunc checks the caller's read permission. Failure to allocate
scratch storage also requires caller authority. Rename checks both the
-source and an existing destination. Ordinary mode permits replacement of
-the recorded primary executable for package upgrades; its replacement has
-no authority until a later initialization records it. ``inode_setattr``
+source and an existing destination. ``inode_setattr``
covers truncate, chmod, chown and timestamp changes to labelled targets.
``inode_init_security`` uses ``bpf_inode_init_xattr()`` to give a new inode
@@ -358,14 +337,10 @@ link or rename can introduce an existing unlabelled inode. This does not
authorize every directory-entry change against the parent or revoke
existing writable descriptors and mappings.
-In ordinary mode, ``bprm_check_security`` and ``bprm_committed_creds`` mark
-tasks that successfully exec a labelled binary, and ``task_alloc`` inherits
-the mark. These marks protect processes from observation and do not grant
-filesystem mutation authority. ``ptrace_access_check`` and
-``perf_event_alloc`` deny against tasks already marked when those hooks
-run. The perf allocation check is not serialized with the exec transition;
-the separate `perf/exec race investigation <https://github.com/shirudo-dev/shirudo/issues/11>`__
-records the source-derived limitation.
+``ptrace_access_check`` and ``perf_event_alloc`` deny against tasks already
+marked when those hooks run. The perf allocation check is not serialized with
+exec; the separate `perf/exec race investigation
+<https://github.com/shirudo-dev/shirudo/issues/11>`__ records this limitation.
Process hardening. ``util/harden.c`` runs at startup on the target:
``PR_SET_DUMPABLE`` off, ``PR_SET_NO_NEW_PRIVS``, ``PR_SET_PTRACER`` to
@@ -378,7 +353,7 @@ either; ``/etc/hosts`` and ``/etc/resolv.conf``, a local resolver stub
included, still apply. The zeroing allocator in ``util/malloc.c``
wipes freed memory; the libc allocators are poisoned project-wide.
-Image-mode enforcement. The UKI authenticates a runtime image mounted at
+Runtime and config enforcement. The UKI authenticates a runtime image mounted at
``/run/shirudo/runtime``; signed configuration is mounted separately at
``/run/shirudo/config`` with ``noexec``. Neither is the host root filesystem.
Every executable on the runtime image is equally eligible for authority.
@@ -396,7 +371,7 @@ for that mapping. ``bdev_free_security`` attempts cleanup, but upstream
can omit the notification.
The ``file_ioctl`` hook denies untrusted
callers mutating device-mapper control operations, including through old or
-inherited FDs. This restriction applies to all DM devices in image mode.
+inherited FDs. This restriction applies to all DM devices on the target.
Trusted image tasks retain control access. These checks use existing LSM
hooks. Direct keyring access additionally requires the upstream
``KEY_SPEC_DM_VERITY_KEYRING`` API described in the requirements.
@@ -406,7 +381,7 @@ protection remains unestablished. ``mmap_file`` and
executable pages. Existing ptrace and process-memory checks still apply.
Writable state keeps its seal xattrs, while neither image receives seal
-writes. Image mode uses the task mark for writable-state and bpffs access.
+writes. The task mark authorizes writable-state and bpffs access.
The authorized BPF signing keys are enrolled at boot and the ``.bpf``
keyring then receives the existing reject-all restriction. A live config
update refuses a candidate requiring a signer absent from that sealed
@@ -440,69 +415,34 @@ deferred TPM writer limitation.
7) Target state
---------------
-The sequence below describes the ordinary installation. Image mode first
-verifies and measures the selected config, uses the runtime image's initial
-BPF certificate and the config image's vouched keys, and keeps the state
-filesystem writable in the initrd for its durable activation journal.
-
-``shirudo init`` is idempotent and runs on every boot from
-``systemd/shirudo.service`` (``Type=oneshot``, ``KeyringMode=inherit``,
-extra arguments from ``/etc/shirudo/init.env``), from the initrd in
-the production configuration: after the ``enter-initrd`` phase is
-measured, before the switch to the root file system, with
-``/etc/shirudo`` and ``/var/lib/shirudo`` at their usual paths.
-Installed in the root file system it runs before ``sysinit.target``
-instead, and the target stays in staging. It does, in order:
-
-1. the pre-flight: root, BPF LSM active, bpffs mountable, the
- signed-loader kernel ABI, ``cert.der`` present and ML-DSA-87, the
- kernel able to parse that certificate (``CONFIG_CRYPTO_MLDSA``),
- the kernel's bpf keyring present, embedded loaders present, TPM 2.0
- reachable. Every
- check is hard; all failures are reported together as
- ``init_prereqs_missing`` and nothing is touched. ``shirudo init
- --check-only`` stops here. In the initrd, told by
- ``/etc/initrd-release``, ``init`` also binds the root's
- ``/var/lib/shirudo`` read-only at its usual path and reads the
- trusted set from the initrd's own ``/etc/shirudo/keys``;
-2. mounts the private bpffs at ``/run/shirudo/bpffs`` with
- ``mode=0700,nosuid,nodev,noexec``;
-3. removes state left behind by features that no longer exist;
-4. enrols the trusted set in the kernel's bpf keyring and seals it
- with ``KEYCTL_RESTRICT_KEYRING`` so nothing can be linked into it
- for the rest of the boot. The set is ``cert.der`` plus every
- ``trusted/<fingerprint>.der`` with a vouch beside it that verifies
- under the primary or under a member admitted before it, less the
- fingerprints the ``revoked/`` directory names (the `key-lifecycle
- <key-lifecycle.rst>`__ guide). A keyring found sealed is reused
- when it holds exactly that set, which ``init`` tells by the
- descriptions the kernel gives the certificates, and refused when it
- holds anything else. That needs the kernel booted with
- ``bpf.keyring_unsealed=1`` and ``init`` run from the initrd. A
- kernel that sealed the bpf keyring empty at boot makes ``init``
- stage the primary certificate alone instead: a ``shirudo`` keyring
- in the user keyring, sealed with ``KEYCTL_SETPERM`` to view, read
- and search only, until the next reboot;
-5. labels ``/var/lib/shirudo/`` with ``security.bpf.shirudo`` and
- appends the record an initrd run left under ``/run`` to the
- eventlog; the initrd run itself skips both, its root being
- read-only;
-6. loads the embedded bpf2 object and, unless ``--no-seal``, seal during
- trusted bootstrap, before attaching the BPF admission gates;
- freezes and pins the identity map (the bpffs, the executable that
- keeps running the target, from the initrd also the initrd's own
- copy for that run, the keyring kind and serial, and the serials of
- the keys it holds), creates the links and pins each one before
- doing anything else fallible;
-7. re-applies every ``.upatch`` under ``/var/lib/shirudo/upatches/`` in
- sorted name order, all or nothing;
-8. binds this boot's measurement register and extends it once with
- ``SHA256("shirudo-init\0" || cert_sha256 || set_digest ||
- tree_root)``, where ``cert_sha256`` covers the enrolled
- certificates (one digest, or the SHA-256 over the sorted digests of
- several), ``set_digest`` is the SHA-256 of the sorted listing of the
- restored set and ``tree_root`` the upatch tree's projection root
- (zeros without a tree), and appends the event.
+The authenticated initrd runs ``shirudo init`` before untrusted workloads.
+The root service runs it again using the packaged runtime interpreter and
+libraries. Both runs use the same enforcement and records; no fallback mode
+exists. Initialization performs these steps:
+
+1. Load authenticated bootstrap settings, including the runtime image root,
+ then run prerequisite checks. Missing image settings are an error.
+ ``--check-only`` stops before changing kernel state.
+2. Bind ``/sysroot/var/lib/shirudo`` writable at its usual path in the initrd,
+ so config selection and recovery can be recorded durably. Mount the private
+ bpffs under ``/run/shirudo``.
+3. Verify the runtime and selected config, enroll the config verification
+ certificate in ``.dm-verity``, and seal it. Enroll the initial BPF certificate
+ plus vouched config signers, less config revocations, in ``.bpf`` and seal it.
+ Both enrollment boot parameters are required. A sealed empty BPF ring is an
+ error, rather than a reason to stage keys in a user keyring.
+4. Label writable state. Load both bootstrap BPF objects, populate and freeze
+ their shared maps, seed bootstrap authority, attach device, mount and seal
+ hooks, then attach the map-access and BPF admission gates last.
+5. Mount the runtime under those guards, verify and measure the config
+ selection, apply its revocations, and label state again to populate the
+ inode protection cache. All image files stay read-only.
+6. Restore the archived signed upatches in sorted order. Any failure leaves
+ config completion pending and blocks changes and config attestation.
+7. Bind this boot's upatch register and extend it once with
+ ``SHA256("shirudo-init\0" || cert_sha256 || set_digest || tree_root)``.
+ Append its event and mark config startup complete. The root service later
+ adopts the pending initrd eventlog record without another extension.
Boot-restore extends the register by exactly one event however many
upatches it restores. The register starts from zero at every boot, so
@@ -580,22 +520,13 @@ the tree root, or an ``--expect-chain`` the operator computed from
those plus the events since boot. ``attest`` touches only the
target's TPM; ``verify`` and ``predict`` touch no TPM at all.
-Files. Under ``/var/lib/shirudo/``: ``keys/cert.der`` (and
-``keys/signing_key.pem`` on an operator), ``keys/trusted/`` (the
-further certificates with their vouches), ``keys/revoked/``,
-``eventlog``, ``upatches/`` (installed artifacts), ``incoming/``
-(staging), ``locks/`` and ``bpm/`` (registry indexes, packages, tree
-state). Under ``/run/shirudo/``, per boot: the ``bpffs/`` mount with
-``lsm_link``, the ``bpf2_*_link`` and ``seal_*_link`` pins, the frozen
-``identity`` map and ``upatches/<name>/``, and ``eventlog.pending``
-between the initrd run and the root's; it lives under ``/run``
-because that is what
-systemd carries from the initrd into the root file system, so pins
-made before the switch keep their links. Under
-``/etc/shirudo/``: ``shirudo.conf``, ``init.env``, ``map-export.env``,
-``node.labels`` and ``bpm/`` (``registries.d/``, ``keys/``,
-``upatch-tree.conf``, ``environment``). ``shirudo config`` prints the
-effective configuration with a comment on every key.
+Files. Writable state under ``/var/lib/shirudo`` includes archived upatches,
+eventlogs, locks, downloaded packages, tree state, cached images and the config
+activation record. Initial BPF keys and bootstrap settings live in the runtime;
+repository definitions, node labels, export settings, additional signer vouches
+and revocations live in config. The operator keeps its private signing key
+outside both images. Per-boot mounts and pins live under ``/run/shirudo``;
+``eventlog.pending`` bridges the initrd and root service runs.
8) Packages and registries
--------------------------
@@ -612,9 +543,8 @@ the registry's detached-CMS-signed index at
``shirudo/bpm-index:stable``. Published versions are immutable; an
index that already lists a version with other digests is refused.
-In the ordinary installation, ``shirudo bpm config register add <name> oci://host
---key-file cert.der`` records the registry and the certificate that
-must sign its index. ``shirudo bpm repo update`` fetches and verifies
+Repository definitions and index verification certificates are prepared on the
+operator and shipped in the signed config image. ``shirudo bpm repo update`` fetches and verifies
the index; ``shirudo bpm install <name>/<pkg>[@ver]`` (or an ``oci://``
reference) pulls, verifies, unpacks and loads; ``upgrade`` moves
installed packages to the newest indexed version; ``uninstall`` loads
@@ -624,7 +554,7 @@ to a different one while a key is active. The ``repo update`` and
``tree sync`` timers (60 s) and the map-export and keepalive timers
(5 s) are the only always-on infrastructure.
-In image mode, repository definitions and verification certificates come
+Repository definitions and verification certificates come
from the signed config. Local repository and key mutations refuse with
instructions for config activation or boot-time signer enrollment. The
package and tree update commands remain available. Repository ``key_file``
diff --git a/Documentation/config-images.rst b/Documentation/config-images.rst
index 16cca912..f134d319 100644
--- a/Documentation/config-images.rst
+++ b/Documentation/config-images.rst
@@ -5,10 +5,11 @@
Executable and configuration images
===================================
-Image mode puts Shirudo's executable and configuration on two separate
-read-only dm-verity filesystems. It keeps the host root filesystem and
-retains live signed upatch updates. Authenticated bootstrap settings
-explicitly select this mode; the ordinary installation remains available.
+Shirudo puts its executable and configuration on separate read-only dm-verity
+filesystems. The host root filesystem stays in place. Writable Shirudo state
+keeps its xattr protection. BPF upatches still use signed loaders verified by
+the kernel BPF keyring, including when config itself has a valid signature.
+There is one target policy; authenticated bootstrap settings are required.
The executable image is fixed for the boot. Configuration updates install
another signed immutable image while the system runs. They do not write
@@ -215,8 +216,7 @@ Image mode needs writable ``/var/lib/shirudo`` available during the initrd
run: the image cache and pending activation record must be durable before a
PCR extension. If that directory resides on a separate filesystem, mount
it under the initrd's system root before Shirudo starts. A separate state
-filesystem is not required. The ordinary installation's read-only state
-bind is unchanged.
+filesystem is not required.
The mounts under ``/run`` survive switch-root.
Boot verifies the selected cached config, validates its mapping and
@@ -293,7 +293,7 @@ and attestation remain target operations under the active image policy.
Operator build, publish and vouch commands remain operator operations.
Signed upatch load and unload checks continue to apply. Signed config
-revocations reuse the ordinary key unlink, measured key-revoke and live
+revocations reuse the existing key unlink, measured key-revoke and live
upatch unload operations. Startup removes archives signed by revoked keys
before restoring upatches. There is no separate purge journal or same-boot
purge recovery.
@@ -356,37 +356,17 @@ config evidence. This remains subject to the direct-writer limitation.
6) Enforcement and tests
------------------------
-The binary embeds a separate BPF object pair for each mode. Initialization
-loads only the selected pair; ordinary installations do not load image
-metadata hooks, DM ioctl restrictions or executable-mapping restrictions.
-
-.. list-table:: BPF objects selected at initialization
- :header-rows: 1
- :widths: 20 35 45
-
- * - Mode
- - Objects
- - Caller authority
- * - Ordinary
- - ``bpf/bpf2.c`` and ``bpf/seal.c``
- - The executable device/inode recorded at init, or its initrd copy.
- * - dm-verity
- - ``bpf/bpf2_verity.c`` and ``bpf/seal_verity.c``
- - A task mark committed after successful exec from the runtime image.
-
-``bpf/admission.h`` supplies the shared BPF command, signature, keyring and
-bpffs checks. ``bpf/seal.h`` supplies writable-state xattr checks, label
-inheritance, and ptrace/perf checks. The selected policy header determines
-caller authority. Both modes share the same checks without testing the mode
-inside each running BPF program.
-
-The seal label marks a protected target. It never grants the caller write
-access. Ordinary mode labels its executable and state; image mode uses
-dm-verity for executable/config files and labels writable state only.
-Ordinary-mode exec marks protect labelled processes from observation but do
-not authorize BPF operations or file writes.
-
-Image mode marks tasks after successful exec from the approved runtime
+The binary embeds one BPF object pair: ``bpf/bpf2.c`` and ``bpf/seal.c``.
+Initialization always loads both. ``bpf/admission.h`` supplies BPF command,
+signature, keyring and bpffs checks. ``bpf/seal.h`` supplies writable-state
+xattr checks, label inheritance and ptrace/perf checks. The device and task
+helpers live in ``bpf/verity_policy.h``.
+
+The seal label marks a protected writable target. It never grants the caller
+write access. Runtime and config files use dm-verity, while writable state
+continues to use seal xattrs. Caller authority comes from runtime exec.
+
+Shirudo marks tasks after successful exec from the approved runtime
device, inherits the mark on fork and re-evaluates it on every successful
exec. Exec outside the runtime clears authority. Failed exec preserves
the running image's mark. Changing ``mm->exe_file`` cannot grant authority.
@@ -398,7 +378,7 @@ of an earlier proposed exec-time snapshot check. Neither has a runtime
reproduction in this work.
Do not add a systemd syscall filter to the runtime
invocation: caller-controlled seccomp could otherwise spoof the kernel
-mode query used to keep commands inside image policy.
+enforcement query used to detect hidden bpffs pins.
The LSM observes dm-verity metadata through the existing
``bdev_setintegrity`` hook. Lookup checks the block-device pointer, device
@@ -407,7 +387,7 @@ bootstrap value. A config root must match the expected root staged by the
trusted task creating that mapping. An unrelated mapping made by a trusted
task is not a config device.
-Expected roots live in image-only task storage. The hook reads the preparing
+Expected roots live in task storage. The hook reads the preparing
task's entry and consumes it when the kernel reports the matching root.
Creation clears it on every exit and reports an error if cleanup fails. A
remaining valid entry blocks another preparation until cleared or task exit.
@@ -477,61 +457,34 @@ The target tamperproof tests exercise executable authority, fork and exec,
executable mappings, direct and inherited DM controls, mount namespaces,
ptrace, ``/proc/<pid>/mem``, ``process_vm_writev`` and perf observers.
Observer tests do not establish that concurrent perf attachment is excluded.
-Run the existing target suite on an ordinary installation and the
-image-mode fixtures on an image installation. The final interruption case
-leaves pending state and ends the VM run; it does not automate a reboot. A skipped fixture is not evidence that its protection
-passed.
+The target suite runs against an image-backed installation. The final
+interruption case leaves pending state and ends the VM run; it does not
+initiate a reboot. A skipped required fixture fails the run.
-7) Run both policy modes
--------------------------
+7) Run the target suite
+-----------------------
The standard harness builds and signs fixtures on the operator and deploys
-only public artifacts. Run the complete target suites separately::
-
- make -C testing test-tgt TEST_VM_MODE=legacy
- sudo make -C testing test-tgt TEST_VM_MODE=verity
-
-Image mode defaults to ``TEST_VM_INITRD=1`` and requires dracut and root on
-the host. It refuses disabled sealing and partial suite selections. The
-legacy initrd path can also be tested explicitly::
-
- sudo make -C testing test-tgt TEST_VM_MODE=legacy TEST_VM_INITRD=1
-
-The two modes use separate host bundle caches. Image mode seeds all signed
-images into the disposable guest and selects ``config-boot-keys`` for its
-initial boot. The runtime test image contains the authority probe and a test-only
-interrupted-activation executable. Do not ship these helpers in a deployment
-runtime: every runtime executable is eligible for authority.
-
-.. list-table::
- :header-rows: 1
- :widths: 27 36 37
-
- * - Coverage
- - Legacy mode
- - Image mode
- * - Upatch lifecycle, version and payload checks, TPM replay, uprobes,
- maps and keyring controls
- - Existing target suites
- - Shared target suites using the runtime command
- * - Tree selection, sequential sync, delete and restore
- - Writable fixture configuration
- - Signed tree config activation between publications
- * - OTLP maps, timer service and serializer output
- - Writable fixture configuration
- - Signed telemetry config and runtime service invocation
- * - Local key and repository mutations
- - Existing mutation suites
- - Explicit refusal and guidance; boot enrollment and signed revocation
- * - Executable and config integrity
- - Existing seal and executable-identity suites
- - Task authority, executable mappings, device controls, observers,
- hidden bpffs, signed A/B activation and measured revocation/purge
- * - Interrupted activation
- - Existing host journal tests
- - One exit after PCR measurement; further mutations and attestation
- refuse, then the VM run ends
+only public artifacts. Run the suite with::
+
+ sudo make -C testing test-tgt
+
+The harness requires dracut, initrd boot and all seal hooks. It rejects
+``TEST_VM_INITRD=0`` and ``TEST_VM_SKIP_SEAL=1``. The only accepted value of
+the old ``TEST_VM_MODE`` setting is ``verity``; no selection is needed.
+CI uses this same required suite and reports its failures.
+
+The guest boots with ``config-boot-keys``. The runtime fixture includes an
+authority probe and an interrupted-activation helper; these test executables
+have full authority and must never ship in a deployment runtime.
+
+The suite checks signed upatch load and unload, foreign signature rejection,
+TPM replay, uprobes, map and arena serialization, tree updates, OTLP services,
+keyring controls, runtime exec authority, executable mappings, device controls,
+process observers, hidden bpffs, signed config updates and measured revocation.
+After the final interrupted update it checks that changes and attestation
+refuse while the node continues running.
Required image fixtures and helpers are failures when absent. A whole suite
that skips in image mode fails the runner. Test ordering matters:
@@ -544,7 +497,6 @@ For an already provisioned disposable image-mode VM, install the complete
public fixture set and cache every config bundle under
``/var/lib/shirudo/images``, then run::
- export SHIRUDO_TEST_MODE=verity
export SHIRUDO_BIN="$PWD/testing/helper/image-shirudo"
export SHIRUDO_TEST_FIXTURES_DIR=/path/to/public-upatch-fixtures
export SHIRUDO_TEST_KEY_FIXTURES=/path/to/public-image-fixtures
diff --git a/Documentation/getting-started.rst b/Documentation/getting-started.rst
index 4e00e84a..07d600b3 100644
--- a/Documentation/getting-started.rst
+++ b/Documentation/getting-started.rst
@@ -15,13 +15,11 @@ development-tree commit with the signed-loader ABI, BPF LSM, BTF and ML-DSA
support. A release number alone is not enough. For local development one
host can play both roles.
-The target setup and writable configuration examples below describe the
-ordinary installation. For image mode, use `config-images
-<config-images.rst>`__: authenticated bootstrap selects runtime and config
-images, and services and commands invoke the packaged runtime interpreter.
-Target-local signer and repository mutations are refused in that mode;
-configuration changes arrive as signed images. Signed upatch load/unload,
-package updates, tree sync, export and attestation remain available.
+Targets require runtime and signed config images. Follow
+`config-images <config-images.rst>`__ for generation and authenticated boot.
+Writable state keeps its xattr protection and all BPF upatches remain signed.
+The target commands below denote the generated runtime loader invocation;
+operator commands use the ordinary host executable.
1) Build
--------
@@ -90,15 +88,11 @@ is no other key type. ``keys`` prints the algorithm and fingerprints
of the material on disk and, on a target, the state of the kernel
keyring.
-Copy ``cert.der`` to the target through the organisation's normal
-provisioning path, into ``/var/lib/shirudo/keys/cert.der``. Never
-copy ``signing_key.pem`` to a target; nothing on the target can use
-it, and the threat model assumes it is not there. A target can trust
-several keys: a further certificate joins the set with ``shirudo keys
-add <cert.der> --vouch <file>``, the vouch coming from ``shirudo keys
-vouch`` on an operator the target already trusts, and leaves it with
-``shirudo keys revoke <fingerprint>``. The `key-lifecycle
-<key-lifecycle.rst>`__ guide covers both.
+Put the initial public certificate in the runtime image. Never put
+``signing_key.pem`` on a target or in either image. Additional BPF signers
+need vouches in the signed config selected for boot; enrolling them requires
+a reboot. Signed config can revoke an already enrolled signer at runtime.
+See `key-lifecycle <key-lifecycle.rst>`__.
3) Build a signed upatch
------------------------
@@ -135,75 +129,28 @@ upatch, decoders, serializers and the release workflow.
4) Initialise a target
----------------------
-On a target with network access the installer under
-``tools/gen-initrd`` does the whole setup in one go: it installs the
-release package, places the certificate, puts the kernel parameter the
-bpf keyring needs on the boot command line and rebuilds the initrd with
-shirudo inside, so that the next reboot comes up in the production
-configuration::
-
- curl -fsSL https://raw.githubusercontent.com/shirudo-dev/shirudo/main/tools/gen-initrd/install.sh |
- sudo bash -s -- --cert https://example.com/shirudo/cert.der --now
-
-``--now`` starts enforcement right away, staged until that reboot; the
-``initrd`` document describes the installer's parts and what it needs
-from the system. By hand instead: install the target package, place
-``cert.der``, then::
-
- sudo shirudo init --check-only
- sudo shirudo init
- sudo shirudo status
-
-``--check-only`` runs the pre-flight and reports every missing
-prerequisite at once without touching the kernel: root, BPF LSM active,
-bpffs mountable, the signed-loader kernel ABI, the certificate present
-and ML-DSA-87, the kernel able to parse it, the kernel's bpf keyring
-present, the embedded enforcement programs present, a TPM 2.0
-reachable. All of
-them are hard; there is no unmeasured mode. A machine without a TPM
-can use a software one for development::
-
- contrib/swtpm.sh start # prints the SHIRUDO_TPM_TCTI line
- contrib/swtpm.sh env
-
-Either export that variable or set ``tpm.tcti`` in
-``/etc/shirudo/shirudo.conf``. A TPM whose owner hierarchy has a
-password needs ``tpm.owner_auth`` (or ``SHIRUDO_TPM_OWNER_AUTH``) to
-define the measurement register, once and again whenever the PCR 9 or
-PCR 11 value at binding changes.
-
-``init`` mounts the private bpffs, enrols the certificate in the
-kernel's bpf keyring and seals it, labels ``/var/lib/shirudo`` with the
-sealing xattr, attaches the enforcement programs, re-applies any
-installed upatches, binds this boot's measurement register and extends
-it once. It is idempotent and safe to re-run.
-
-The production configuration runs it from the initrd first. Boot the
-kernel with ``bpf.keyring_unsealed=1``, which leaves the bpf keyring
-open until ``init`` seals it, and give the initrd the target binary,
-``shirudo-initrd.service`` and a copy of the certificate at
-``/etc/shirudo/keys/cert.der``; the ``initrd`` document describes that run,
-what ``shirudo.service`` then finishes from the root file system, and
-the dracut module and installer under ``tools/gen-initrd`` that set a
-target up that way. The register then binds while PCR 11 holds a
-value no later process can bring back, and the keyring is the kernel's
-own. Started from the root file system alone, ``init`` finds the bpf
-keyring sealed empty, stages the certificate in a sealed ``shirudo``
-user keyring until the next reboot, and binds the register with the
-post-initrd PCR 11 value; ``status`` reports ``mode: staging`` and
-``bound_in: root``, and the verifier can refuse both. Extra arguments
-go in
-``/etc/shirudo/init.env`` as ``SHIRUDO_INIT_ARGS``. Enable the unit
-and the timers you want::
-
- sudo systemctl enable --now shirudo.service
+Build and provision runtime and config images, install the generated runtime
+service drop-in, and build an authenticated UKI as described in
+`config-images <config-images.rst>`__ and `initrd <initrd.rst>`__.
+Bootstrap settings name the expected runtime root and the reserved config PCR.
+Boot with ``bpf.keyring_unsealed=1 dm_verity.keyring_unsealed=1`` and make
+writable state available in the initrd. Missing settings or images stop init;
+there is no root-only staging configuration.
+
+The initrd verifies the images, seals the keyrings, labels writable state,
+attaches every enforcement hook, restores signed upatches and measures startup.
+The root service uses the verified runtime to check that state and adopt the
+initrd eventlog record. After boot, using the runtime invocation::
+
+ sudo shirudo status --json
+ sudo shirudo image status
sudo systemctl enable --now shirudo-bpm-repo-update.timer
sudo systemctl enable --now shirudo-keepalive.timer shirudo-map-export.timer
-``status`` shows the roles, the four conditions, the keyring serial
-against its pin, the register against this boot's eventlog replay and
-its anchor, and the assets on disk; ``--json`` emits the same as a
-document.
+Check ``mode: production``, ``keyring_mode: bpf``, ``tpm.bound_in: initrd``,
+consistent config state and an upatch register matching its eventlog. A TPM is
+mandatory. For a development software TPM, put ``tpm.tcti`` in authenticated
+runtime configuration; target environment overrides are refused.
5) Load and unload a local artifact
-----------------------------------
@@ -277,12 +224,9 @@ material, adds the version to the registry's signed index at
or ``DOCKER_CONFIG``; ``BPM_OCI_CA_FILE`` adds a CA and
``BPM_OCI_SCHEME=http`` allows a cleartext local registry.
-On the target, register the repository once with the operator's
-certificate, then install by hand or let the timer refresh and
-upgrade::
+Put repository definitions and their index certificates in the signed config
+image. After activation, install packages or let the timer refresh them::
- sudo shirudo bpm config register add example oci://quay.io \
- --key-file cert.der
sudo shirudo bpm repo update
sudo shirudo bpm install example/kernel-obs
sudo shirudo bpm list
@@ -304,7 +248,8 @@ selectors, so a fleet of mixed kernels pulls only what applies::
shirudo bpm tree append ./kernel-obs-1.0.0.bee \
oci://quay.io/example/tree --keys-dir /var/lib/shirudo/keys --op delete
-A target follows a tree when ``/etc/shirudo/bpm/upatch-tree.conf``
+A target follows a tree when its signed config's
+``etc/shirudo/bpm/upatch-tree.conf``
names it (``endpoint=`` and ``reference=``); ``shirudo bpm tree sync
[--dry-run]`` applies the matching operations, and
``shirudo-bpm-tree-sync.timer`` runs it every minute. Node labels for
@@ -321,7 +266,8 @@ logs and metrics::
--otel-endpoint=https://collector.example:4318
sudo shirudo status --otel --include-system
-Set ``map_export.otel_endpoint`` in ``/etc/shirudo/shirudo.conf`` and
+Set ``map_export.otel_endpoint`` in the signed config's
+``etc/shirudo/shirudo.conf`` and
enable ``shirudo-map-export.timer`` and ``shirudo-keepalive.timer`` to
push map snapshots and a status keepalive every five seconds.
`telemetry <telemetry.rst>`__ describes the records, the decoders and
diff --git a/Documentation/index.rst b/Documentation/index.rst
index 5048ae38..985354d9 100644
--- a/Documentation/index.rst
+++ b/Documentation/index.rst
@@ -42,8 +42,8 @@ Deploying shirudo
and publishing packages to a registry.
Using executable and config images
- `config-images <config-images.rst>`__ describes the opt-in dm-verity
- mode: separate runtime and config images, operator generation,
+ `config-images <config-images.rst>`__ describes the required dm-verity
+ layout: separate runtime and config images, operator generation,
bootstrap trust, live config and key updates, static-PCR measurements,
interrupted activation, manual reboot, enforcement and current limitations.
diff --git a/Documentation/initrd.rst b/Documentation/initrd.rst
index 3505efc9..262912aa 100644
--- a/Documentation/initrd.rst
+++ b/Documentation/initrd.rst
@@ -5,262 +5,133 @@
Bringing shirudo up from the initrd
===================================
-The production configuration of a target brings enforcement up before
-the root file system runs anything: ``shirudo init`` runs inside the
-initrd. This document describes what that run does, what the root
-file system's run finishes afterwards, what an initrd needs to contain
-and how the pieces survive the switch from one to the other. The
-``threat-model`` document says why it matters; ``tpm`` describes the
-register the initrd binds.
-
-The opt-in dm-verity mode keeps the same systemd handoff, with two
-additional image mounts under ``/run/shirudo``. It requires the runtime image
-hash and startup settings in authenticated boot, and writable state available
-inside the initrd for the config activation journal. See
-`config-images <config-images.rst>`__ for image generation and activation.
-The read-only state bind and inode identities below describe the ordinary
-installation.
-
-1) Two runs of init
+Every target starts enforcement from an authenticated systemd initrd before
+untrusted workloads. The initrd verifies a runtime image and a separate signed
+config image. The host root filesystem stays in place; there is no root pivot.
+See `config-images <config-images.rst>`__ for the image contents and generation
+commands, `architecture <architecture.rst>`__ for the LSM flow and
+`tpm <tpm.rst>`__ for measurement and attestation.
+
+1) What boot needs
-------------------
-``shirudo init`` is one command that runs twice per boot in production:
-
-The initrd run
- Starts from ``shirudo-initrd.service`` after the root file system is
- mounted at ``/sysroot`` and after ``systemd-pcrphase-initrd.service``
- has measured ``enter-initrd`` into PCR 11, and finishes before the
- switch to the root file system. It enrols the initrd's own copy of
- the certificate, ``/etc/shirudo/keys/cert.der``, in the kernel's bpf
- keyring and seals it, which needs the kernel booted with
- ``bpf.keyring_unsealed=1``; mounts the private bpffs at
- ``/run/shirudo/bpffs`` and attaches the enforcement programs with
- their pins in it; re-applies the upatches archived under
- ``/sysroot/var/lib/shirudo/upatches``; binds the measurement
- register under PCRs 9 and 11 and extends it by the init event; and
- writes the ``init`` record to ``/run/shirudo/eventlog.pending``.
-
-The root file system's run
- Starts from ``shirudo.service`` inside the sysinit phase. It finds
- the keyring sealed around the certificate, the LSM attached, the
- upatches loaded and the register bound, and does what the initrd
- could not do on a root file system that was still read-only: it
- labels the state tree and the binary with the sealing xattr and
- appends the pending record to ``/var/lib/shirudo/eventlog``, exactly
- once. Then it stops. ``status`` reports ``mode: production`` and
- ``bound_in: initrd``.
-
-Without an initrd that runs the first half, the root file system's run
-does everything itself. The kernel sealed the bpf keyring empty at
-boot, so the certificate is staged in a ``shirudo`` keyring under the
-user keyring until the next reboot, and the register binds after
-``leave-initrd`` moved PCR 11. That is the staging configuration:
-``status`` says ``mode: staging`` and ``bound_in: root``, the keepalive
-condition warns, and a verifier can refuse the evidence with
-``--require-initrd`` or by pinning PCR 11.
-
-2) What survives the switch to the root file system
----------------------------------------------------
-
-systemd's switch-root carries ``/dev``, ``/sys``, ``/proc`` and ``/run``
-from the initrd into the root file system and lazily detaches every
-other mount of the initrd. A BPF link stays attached only while
-something holds it, and in an agentless design the only holders are
-the pins in the bpffs; a bpffs mounted anywhere the switch detaches
-dies with the old root and takes enforcement with it. That is why the
-private bpffs lives at ``/run/shirudo/bpffs``: a mount under ``/run``
-is carried across, is never shadowed by a later mount of ``/var``, and
-needs nothing from the root file system.
-
-The kernel keyring is kernel state and survives by itself; so do the
-TPM's NV index and PCRs. The init record cannot be written to the
-root's eventlog while the root is read-only, so it waits under ``/run``
-in the same tmpfs, in ``/run/shirudo``, which ``init`` labels with the
-sealing xattr so that the record is sealed from the instant it is
-created, and the eventlog readers treat it as part of this boot's log
-until the root file system's run appends it and removes the file.
-
-The bpffs guards admit the executable recorded at init. From the
-initrd the running binary is the initrd's copy, which is gone after
-the switch; the identity that lasts is the root's binary at the same
-path, ``/sysroot`` plus the path the initrd ran shirudo from, and the
-initrd's copy is recorded beside it for the rest of that one run. The
-root file system therefore needs shirudo installed at the path the
-initrd runs it from, which the dracut module guarantees by copying the
-installed binary.
-
-3) What the initrd needs
-------------------------
+* An authenticated UKI containing the bootstrap binary and configuration.
+ ``runtime.image`` names the cached runtime bundle and ``runtime.root_hash``
+ gives its exact expected SHA-256 root. Missing image settings are an error.
+* The runtime image contains Shirudo, its ELF interpreter and libraries,
+ initial BPF certificate, config-verification certificate and bootstrap TPM
+ settings. The initial config bundle is signed by an accepted config key.
+* Boot parameters ``bpf.keyring_unsealed=1 dm_verity.keyring_unsealed=1``.
+ The initrd enrolls the trust anchors and seals both kernel keyrings. There
+ is no fallback to a user keyring when the BPF ring is sealed empty.
+* A TPM 2.0, the required BPF and dm-verity kernel interfaces, and a reserved
+ static SHA-256 PCR for config measurements. See
+ `requirements <requirements.rst>`__ for the exact kernel requirements,
+ including disabled 32-bit compatibility.
+* ``/sysroot/var/lib/shirudo`` mounted writable before Shirudo starts. If
+ state is on a separate filesystem, mount it in the initrd too. Config
+ selections and cached bundles must be durable before PCR extension.
+* ``systemd-pcrphase-initrd.service`` and its ``enter-initrd`` measurement
+ before Shirudo binds its upatch register. A direct QEMU kernel/initrd boot
+ tests the handoff but does not establish a measured UKI or the PCR 11 phase
+ distinction. Non-systemd initrds are unsupported.
+
+2) The initrd run
+-----------------
+
+``shirudo-initrd.service`` runs after the root filesystem is available at
+``/sysroot`` and before switch-root. Shirudo binds writable state at
+``/var/lib/shirudo``, verifies the images and determines the boot signer set.
+The initial BPF certificate comes from the runtime; additional certificates
+need valid vouches from the selected config. Config revocations exclude keys
+from enrollment. The config verification certificate is enrolled in
+``.dm-verity`` and the BPF trust set in ``.bpf``; both keyrings are sealed.
+
+Initialization labels writable state, loads the two embedded bootstrap BPF
+objects and freezes their shared state before attaching admission gates.
+The authenticated bootstrap task has temporary authority to finish startup.
+It mounts the runtime under the device and mount guards, measures config,
+applies revocations before restoring signed upatches, and binds the upatch
+measurement register. Runtime and config files receive no seal xattrs;
+writable state keeps them. All BPF upatches still require signed loaders.
+
+The mounts live below ``/run/shirudo`` so systemd carries them through
+switch-root: ``runtime`` is ``ro,nodev,nosuid``, ``config`` is
+``ro,nodev,nosuid,noexec``, and ``bpffs`` holds the links and maps. Kernel
+keyrings and TPM state survive independently. The initrd eventlog record
+waits in ``/run/shirudo/eventlog.pending`` for the root service to adopt.
+
+3) The root service
+--------------------
-* The target binary at its installed path. It is fully static PIE,
- including the C library, and needs no ELF interpreter or shared
- libraries to start.
-* ``/etc/shirudo/keys/cert.der``, a copy of ``/var/lib/shirudo/keys/cert.der``,
- and ``/etc/shirudo/keys/trusted/`` with the further certificates and
- their vouches. These copies are measured with the initrd, so a
- verifier that pins PCR 11 knows which certificates were enrolled.
- ``init`` warns when the root's set differs, which means an initrd
- that was not regenerated after a certificate was added or revoked;
- the initrd's copies are the anchor either way, less the certificates
- the root's ``keys/revoked`` names, which ``init`` reads through its
- bind.
-* ``/etc/shirudo/shirudo.conf`` when the TPM has an owner password
- (``tpm.owner_auth``).
-* ``shirudo-initrd.service``, enabled in ``initrd.target``.
-* A TPM 2.0 reachable as ``/dev/tpmrm0``: the TPM driver and the
- device node. dracut's ``tpm2-tss`` module provides both.
-* ``systemd-pcrphase-initrd.service``, so that PCR 11 holds the
- ``enter-initrd`` value when the register binds and moves at
- ``leave-initrd``. dracut's ``systemd-pcrextend`` module (called
- ``systemd-pcrphase`` before dracut 103) provides it. systemd runs
- the unit only for a measured UKI boot (``ConditionSecurity=
- measured-uki``); a kernel and initrd loaded by grub or passed to QEMU
- directly leave PCR 11 at its boot value, ``init`` warns that no phase
- was measured, and the binding then has the PCR 9 anchor but not the
- PCR 11 distinction between an initrd and a later binding. The
- production configuration is therefore a UKI boot; the rest of the
- design holds without it.
-* The root file system mounted at ``/sysroot`` with
- ``/var/lib/shirudo`` on it. When ``/var`` is a separate file system
- it must be mounted in the initrd (``x-initrd.mount`` in fstab), or
- the initrd run refuses with a message that says so and the root's
- run falls back to the staging configuration.
-* The kernel booted with ``bpf.keyring_unsealed=1``. The parameter is
- read-only after boot, so the only way to open the keyring is the
- measured command line.
+Generate a systemd drop-in with ``shirudo-gen-runtime --unit-output`` and
+install it at ``/etc/systemd/system/shirudo.service.d/verity.conf``. It invokes
+the runtime's ELF interpreter with its host cache disabled and library paths
+inside the image, then starts the runtime binary. The loader and executable
+both come from the verified runtime, not from the host root filesystem.
-The ``tools/gen-initrd`` directory holds the dracut module that
-installs all of this, a generator that drives dracut and verifies the
-result, and the installer; the ``getting-started`` document shows how
-they are used. Non-systemd initrds (initramfs-tools, busybox) are
-not supported: without the phase measurements an initrd binding is no
-stronger than a late one.
+The service re-runs ``init``, checks the existing guards and measurements,
+and adopts the initrd eventlog record without another extension. Successful
+exec from the runtime grants the task mark needed for these operations.
+There are no lasting executable inode identities or root-only bootstrap
+fallback. Do not apply caller-controlled seccomp to this invocation.
4) Building the initrd
----------------------
-``tools/gen-initrd`` holds three pieces; the target package installs
-the first two.
-
-The dracut module
- ``module-setup.sh``, installed as
- ``/usr/lib/dracut/modules.d/90shirudo``, copies the installed
- binary at its own path, the certificate as ``/etc/shirudo/keys/cert.der``
- with the trusted set and its vouches beside it,
- ``shirudo.conf`` when there is one and ``shirudo-initrd.service``,
- enables the unit in ``initrd.target`` and depends on dracut's
- ``tpm2-tss`` and ``systemd-pcrphase`` modules. It includes itself
- whenever a certificate is installed, so once shirudo is set up
- every initrd dracut builds, for a kernel update or by hand, carries
- it. A ``dracut.conf(5)`` file can point it at other files
- (``shirudo_binary``, ``shirudo_binary_path``, ``shirudo_cert``,
- ``shirudo_trusted_dir``, ``shirudo_conf``, ``shirudo_unit``), which
- is how the test VM
- builds an initrd from a bundle.
-
-The generator
- ``shirudo-gen-initrd`` drives dracut for one kernel and checks the
- result::
-
- sudo shirudo-gen-initrd # the running kernel
- sudo shirudo-gen-initrd --kver <kernel-release> --output /boot/initrd-shirudo.img
- shirudo-gen-initrd --check /boot/initrd-shirudo.img
- shirudo-gen-initrd --print-cmdline # bpf.keyring_unsealed=1
-
- Run from a checkout it installs the module into dracut's directory
- first. ``--binary``, ``--binary-path``, ``--cert`` and ``--unit``
- build from files other than the installed ones; everything after
- ``--`` goes to dracut. The check reads the initrd with
- ``lsinitrd`` and refuses one that lacks the binary, the
- certificate, the unit, its enablement or the phase measurement.
-
-The installer
- ``install.sh`` does the whole setup of a target in one go, as
- ``curl ... | bash -s -- <options>``: it fetches the release package
- for the host's package format and architecture from the GitHub
- release assets, verifying ``SHA256SUMS`` when the release publishes
- one, installs it, places the certificate given with ``--cert`` (a
- file or a URL), adds ``bpf.keyring_unsealed=1`` to the boot
- command line through ``grubby``, ``update-grub`` or
- ``/etc/kernel/cmdline`` and the loader entries, and rebuilds the
- initrd of the running kernel through the generator. ``--now``
- starts enforcement right away, staged until the reboot; ``--dry-run``
- prints the plan; ``--package`` installs a local package instead of
- downloading one. On a system that builds its initrd with
- initramfs-tools the installer stops before the initrd unless told
- ``--switch-to-dracut``, because an initrd without systemd has no
- phase measurements for the binding to lean on.
-
-Unified kernel images take the command line from their ``.cmdline``
-section and the initrd from their build; on such systems the module
-does its work when ``kernel-install`` or ``ukify`` runs dracut, and the
-parameter goes into ``/etc/kernel/cmdline`` before the image is
-rebuilt.
-
-5) Checking a target
---------------------
-
-On the target::
-
- shirudo status --json | python3 -c \
- 'import json,sys; d=json.load(sys.stdin); print(d["mode"], d["bound_in"])'
-
-prints ``production initrd`` when both runs did their part. The
-eventlog's ``init`` record carries ``bound_in: initrd`` and the PCR 11
-value the register was bound under; ``shirudo attest verify
---require-initrd --expect-bind-pcr=11=<enter-initrd value>`` checks
-both against the evidence, with the value computed from the UKI or
-initrd by ``systemd-measure`` or ``systemd-pcrlock``. No pending
-record remains under ``/run/shirudo`` once the root's run has adopted
-it; a target where it lingers is one whose ``shirudo.service`` has not
-run.
-
-The test VM exercises the whole path: ``make -C testing test-tgt TEST_VM_INITRD=1``
-builds an initrd from the bundle with the generator, boots the guest
-from it and runs the target suite, where ``t1122`` checks the
-configuration above and the rest of the suite runs against enforcement
-the initrd brought up. It needs dracut and root on the host.
-``make -C testing test-installer`` goes one step further and runs
-``testing/t1300-installer-e2e.sh``: a stock cloud image booted in QEMU
-with a vTPM gets the bpf-next kernel packages, reboots into them, runs
-``install.sh`` with a local target package and certificate, reboots
-again and must come up in the production configuration, with ``t1122``
-passing on the installed system.
-
-6) Image-mode boot
-------------------
-
-The authenticated initrd first verifies the runtime root and selected
-config to determine the authorized boot signer set. It enrolls and seals that
-set, attaches device and task protection, mounts the runtime under those
-guards and completes measured config activation and upatch restore. The root
-filesystem's service invokes the image binary through its packaged ELF
-interpreter and libraries; ``shirudo-gen-runtime --unit-output`` writes that
-invocation. The config is mounted ``ro,nodev,nosuid,noexec``; runtime
-is ``ro,nodev,nosuid``. The host root filesystem is not replaced.
-
-Image mode must be able to persist the config bundle and activation record
-before extending the PCR. Make ``/var/lib/shirudo`` writable and available
-in the initrd, including a separate state filesystem when used. The ordinary
-installation continues to use its read-only state bind. Config and runtime
-mounts live under ``/run`` to survive switch-root, as bpffs does.
-
-The selected config is checked again at every boot. After a TPM reset it
-receives a fresh BOOT measurement. A same-boot repeat of init does not add
-another config event. An interrupted activation is completed from its saved
-record; the target cannot silently use an invalid candidate and report
-success. Updating the runtime image or config verification certificate
-requires rebuilding authenticated boot and rebooting.
-
-An existing activation journal selects its cached config prefix before the
-runtime's initial ``config.image`` default. A live update requiring a new
-BPF signer is refused before measurement; it is not queued for reboot.
-Provision the signed boot selection through the authenticated boot rollout.
-The current CLI has no separate next-boot staging command; changing only the
-bootstrap default cannot replace a journaled selection. See the operational
-limitation in `config-images <config-images.rst>`__.
-
-The standard image-mode integration run is ``sudo make -C testing test-tgt
-TEST_VM_MODE=verity``. It requires the initrd and seeds a disposable target
-with public fixtures. A direct QEMU kernel/initrd boot tests the handoff but
-does not establish a measured UKI boot or its PCR 11 phase distinction.
+The target package installs ``tools/gen-initrd/module-setup.sh`` as dracut
+module ``90shirudo`` and installs ``shirudo-gen-initrd``. The module includes
+the bootstrap binary, a preflight certificate copy, authenticated
+``/etc/shirudo/shirudo.conf``, the enabled initrd service, TPM support and the
+image drivers. Actual BPF enrollment uses the verified image's trust set.
+
+After building and provisioning the images, generate an initrd with::
+
+ sudo shirudo-gen-initrd --bootstrap-conf bootstrap.conf \
+ --kver <kernel-release> --output /boot/initrd-shirudo.img
+ shirudo-gen-initrd --check /boot/initrd-shirudo.img
+ shirudo-gen-initrd --print-cmdline
+
+``--binary`` and ``--binary-path`` select the authenticated bootstrap copy;
+``--cert``, ``--trusted-dir`` and ``--unit`` select preflight material and the
+service. Arguments after ``--`` go to dracut. The archive check requires the
+binary, bootstrap config, certificate, service, enablement and phase unit.
+A dracut configuration can provide the same inputs through ``shirudo_binary``,
+``shirudo_binary_path``, ``shirudo_cert``, ``shirudo_trusted_dir``,
+``shirudo_conf`` and ``shirudo_unit``.
+
+Build and authenticate the UKI with this initrd and both enrollment boot
+parameters. Do not start an unprotected target from the host filesystem and
+expect image setup to repair earlier writable references. The package
+installer can install files and prepare dracut; it does not provision the
+images or authorize their runtime hash, and its old ``--now`` mode is removed.
+
+5) Checks, updates and recovery
+-------------------------------
+
+Using the configured runtime invocation, check::
+
+ shirudo status --json
+ shirudo image status
+
+The status must report ``mode: production``, ``keyring_mode: bpf`` and
+``tpm.bound_in: initrd``. The config status must be consistent with no pending
+activation, and the upatch register must match this boot's eventlog.
+Attestation verification should require the approved UKI measurements,
+``--require-initrd`` and the expected config root and PCR.
+
+Live config updates activate another signed immutable image. BPF upatches
+continue to use their signed-loader path. A new runtime, config verification
+key or BPF signer requires the appropriate authenticated boot rollout and
+reboot. The existing activation record takes precedence over the initial
+``config.image`` default; the CLI has no separate next-boot selection command.
+
+If activation is interrupted after pending state is recorded, further changes
+and config attestation refuse. The node continues running and Shirudo never
+reboots automatically. The operator chooses when to reboot; trusted startup
+re-verifies the selected image, records a fresh BOOT event and finishes init.
+It does not retry the previous boot's PCR extension.
+
+The standard disposable VM run is ``sudo make -C testing test-tgt``. It
+exercises this initrd handoff, signed config and upatch updates, task and
+writable-state protection, TPM checks and interrupted activation.
diff --git a/Documentation/key-lifecycle.rst b/Documentation/key-lifecycle.rst
index c851c75d..fc29bb81 100644
--- a/Documentation/key-lifecycle.rst
+++ b/Documentation/key-lifecycle.rst
@@ -13,10 +13,6 @@ in protection, and what to do when one is compromised. The
`threat-model <threat-model.rst>`__ says why the mechanisms are shaped
the way they are; this document says what to do.
-The procedures below describe the ordinary installation. Image mode uses
-signed config images for boot-time key enrollment and live revocation; its differences
-are in section 8 and `config-images <config-images.rst>`__.
-
1) The keys in the system
-------------------------
@@ -63,276 +59,8 @@ member's voucher, and the kernel keyring that holds it once ``init``
has run. Two roles may share a host for development; production
operators and targets do not.
-2) The trusted set on a target
-------------------------------
-
-A target trusts a set of certificates, kept under
-``/var/lib/shirudo/keys``:
-
-``cert.der``
- The primary. The installer's ``--cert`` puts it there; so does
- ``shirudo bpm key add <cert.der>``, which stores certificates
- under ``keys/<fingerprint>.der`` and points ``cert.der`` at the
- first one it installs. ``bpm key add`` refuses to point
- ``cert.der`` at a different certificate while one is active, and
- ``bpm key list`` shows what it installed. The primary needs no
- vouch: it is the root the rest of the set chains to, and it gets
- onto a target by the organisation's provisioning path, not through
- shirudo.
-
-``trusted/<fingerprint>.der`` and ``trusted/<fingerprint>.vouch``
- The further members, each beside the vouch that admits it. A
- vouch is a detached CMS signature by a key already in the set over
- the certificate's DER (and a fixed prefix); the loader admits a
- certificate only with a vouch that verifies under the primary or
- under a member admitted before it, in rounds, so a chain of
- vouches works. A file under ``trusted/`` without a valid vouch is
- not a member, whoever put it there: ``shirudo status`` counts it
- as unvouched and ``init`` leaves it out. ``shirudo keys add
- <cert.der> --vouch <file>`` is the only way shirudo itself writes
- here.
-
-``revoked/<fingerprint>.der``
- The certificates ``shirudo keys revoke`` has withdrawn. A key
- named here is never enrolled again and ``keys add`` refuses it
- however well vouched.
-
-The set is the same on every reader: ``init`` enrols it, ``status``
-and ``keys`` report it, the pre-flight checks every member's
-algorithm, and the digest the ``init`` event carries is the one
-certificate's digest for a set of one and the SHA-256 over the sorted
-digests for a larger set, which is what ``shirudo attest predict
---cert=... --cert=...`` computes from the same files in any order.
-
-``/etc/shirudo/keys`` in the initrd
- The production configuration enrols the initrd's copies. dracut's
- shirudo module copies ``cert.der`` and ``trusted/`` with the
- vouches into the initrd when it is built, so the enrolment is done
- by measured code with a measured set: a verifier that pins PCR 11
- to the UKI knows exactly which certificates the keyring holds.
- The revoked directory stays on the root, where ``init`` reads it
- through its bind. The copies are taken at build time, so **a
- changed set needs the initrd rebuilt** (``shirudo-gen-initrd``);
- until then ``init`` enrols the old set and warns that the root's
- differs. The `initrd <initrd.rst>`__ document describes that run.
-
-Repositories registered with ``shirudo bpm config register add <name>
-<endpoint> --key-file <cert.der>`` keep their own reference to the
-certificate that must sign the repository's index, under
-``/etc/shirudo/bpm``; a tree publication is verified the same way.
-Registering a repository with a certificate the keyring does not hold
-is possible and pointless: its packages would verify in userspace and
-fail at the kernel.
-
-The kernel does not check a certificate's validity period when it
-verifies a signature, and shirudo adds no date check of its own. The
-ten years are a statement of intent and the trigger for rotation, not
-a cut-off a target enforces.
-
-3) What the design fixes
-------------------------
-
-Three facts shape every operation below:
-
-* **The keyring takes keys at boot only.** ``init`` enrols the set
- and seals the keyring; nothing can be added for the rest of the
- boot. A certificate added with ``keys add`` is on disk at once and
- in the kernel after the next boot with a rebuilt initrd. Removal is
- the exception: ``keys revoke`` unlinks a key from the sealed keyring
- there and then, which the ``key_permission`` hook in the enforcement
- programs lets shirudo alone do.
-* **Boot-restore is all or nothing.** On every boot ``init`` reloads
- the archived upatches under ``/var/lib/shirudo/upatches``. An
- archive signed by a key the set no longer covers fails verification,
- the restore stops, and the target comes up with the LSM active but
- nothing loaded and no register bound (``degraded``) until the
- archive is cleaned up. Revocation purges what the revoked key
- signed for that reason; a key that merely disappears from the set
- does not.
-* **The archive is sealed.** Only shirudo removes an archived upatch:
- through a signed unload directive the keyring accepts, or through
- ``keys revoke`` for everything the revoked key signed. An archive
- signed by a key that left the set any other way can only be left
- behind by a reinstall of the state directory.
-
-Together these make adding a key cheap and removing one deliberate,
-and they make the order of a rotation matter.
-
-4) Adding a key
----------------
-
-A new key joins the fleet vouched for by one it already trusts.
-
-On the operator holding the trusted key::
-
- shirudo keys vouch new-cert.der --keys-dir /var/lib/shirudo/keys
-
-writes ``new-cert.der.vouch`` beside the certificate (``-o`` names
-another file) and prints the new certificate's fingerprint. A key
-cannot vouch for its own certificate. Distribute the certificate and
-the vouch together; neither is secret.
-
-On each target::
-
- sudo shirudo keys add new-cert.der --vouch new-cert.der.vouch
- sudo shirudo-gen-initrd
-
-``keys add`` verifies the vouch under the members of the set, requires
-the vouching certificate to be in the bpf keyring this boot, refuses a
-revoked key, and writes the vouch and then the certificate under
-``trusted/``. It prints the fingerprint and is idempotent. The kernel
-learns of the new key at the next boot; ``shirudo status`` shows the
-set on disk as ``certs`` and the keyring's count as ``certs_enrolled``
-so the two can be told apart meanwhile. Reboot the waves at the
-fleet's own pace; the old keys keep working throughout.
-
-Record the new set's ``init_event`` from ``shirudo attest predict
---cert=old.der --cert=new.der`` for the verifiers: a target that has
-rebooted with the new set measures that value, one that has not still
-measures the old.
-
-5) Rotating a key
------------------
-
-With a second key enrolled, rotation is a sequence of ordinary steps
-with no window in which the fleet is unprotected or unenforced.
-
-1. Add the new key to every target (section 4) and let the fleet
- reboot into the enlarged set. Nothing changes for the packages:
- the old key still signs them.
-2. On the operator, rebuild the packages the fleet carries with the
- new key, as new versions (published versions are immutable), and
- publish them::
-
- shirudo bpm build ./example-shields --version 1.1.0 \
- --keys-dir /var/lib/shirudo/keys.next
- shirudo bpm push ./example-shields-1.1.0.bee oci://.../example-shields \
- --keys-dir /var/lib/shirudo/keys.next
-
- The registry's index is signed by whichever key ``push`` is given.
- Re-register the repositories on the targets with the new
- certificate first (``bpm config register remove`` and ``add
- --key-file``), or publish the new versions into a second repository
- and switch the targets over, so that no target is left with an
- index it cannot verify.
-3. For a fleet that follows a tree, start a new tree (``--tree-id``)
- or a new reference published with the new key and point the targets
- at it; a tree cannot change keys mid-sequence, because a target
- verifies every publication against the certificate it registered
- and accepts a ``delete`` only for an id it loaded from the same
- tree.
-4. Upgrade the packages on the targets, or let ``bpm tree sync`` pull
- the new tree. Each upgrade unloads the old key's artifacts under
- the old key's own directives and loads the new key's; both keys are
- in the keyring, so every step verifies.
-5. When ``shirudo upatch list`` on every target shows nothing signed by
- the old key, withdraw it: ``shirudo keys revoke <old fingerprint>``
- on each target (section 6), or, when the old key is the primary,
- ``--promote <new fingerprint>`` makes the new one ``cert.der``.
- Rebuild the initrd and reboot at the next opportunity so the next
- boot enrols the smaller set and its ``init`` event matches the
- verifiers' new expectation.
-
-When the old pair is no longer needed anywhere, shred the private key
-and keep the certificate: old evidence and old eventlogs name its
-digest, and verifying them later needs it.
-
-6) Revocation
--------------
-
-A upatch
- Withdrawing a shield is a signed unload: ``bpm tree append --op
- delete`` for a fleet following a tree, ``bpm uninstall`` for a
- package installed by name, or ``upatch unload`` with the
- directive. Every unload is measured, so an operator can tell from
- the evidence which nodes have acted.
-
-A key
- ``shirudo keys revoke <fingerprint>`` on the target, from this
- moment and for good. In order it: writes the certificate to
- ``keys/revoked/`` so no later boot enrols it; unlinks the key from
- the bpf keyring, so the kernel accepts nothing signed by it from
- that point; measures the revocation into the register as a
- ``key_revoke`` event; unloads, unpins and unarchives every archived
- upatch whose signer is that certificate, each loaded one measured
- as an ``upatch_unload`` with ``reason: key_revoke``; and removes
- the certificate and its vouch from ``trusted/``. Loads signed by
- the other keys keep working throughout. Rebuild the initrd
- afterwards; until the reboot the initrd's copy of the set still
- carries the key, and ``init`` leaves it out because the root's
- revoked directory names it.
-
- Two constraints. Revocation needs the set enrolled in the bpf
- keyring; a target in the staging configuration holds the primary
- alone and rotates instead. And the primary leaves only with an
- heir: ``--promote <fingerprint>`` makes another member
- ``cert.der``. Members the revoked key vouched for stay enrolled
- for the rest of the boot, since that trust was established when
- the boot enrolled them, but they are unvouched from then on and
- need a new vouch under a remaining member (``keys add`` again)
- before the next boot, or they leave the set with it. The last
- certificate goes only with ``--force``, which leaves the target
- verifying nothing until a reboot with a new one.
-
- ``bpm`` keeps its own record of installed packages; a package
- whose upatches a revocation purged still appears in ``bpm list``
- until ``bpm uninstall`` or the next ``bpm upgrade`` reconciles it.
-
- Revocation is per target and reaches a target only when run there.
- Deliver it through the organisation's configuration management,
- the same way the installer and the certificate got there; shirudo
- has no push channel. ``shirudo attest verify
- --allow-runtime-events`` accepts the ``key_revoke`` record, and
- ``shirudo attest predict --event=revoke:<fingerprint>=<cert
- sha256>`` predicts the register it leaves, so the fleet's evidence
- says which nodes have revoked.
-
-A compromised key
- The adversary holding the key is the operator, as far as a target
- can tell: whatever they sign loads and measures as authorised,
- until the key is revoked. Detection is by content, not by
- signature: ``shirudo attest verify`` against ``shirudo attest
- predict`` fails for any node whose register certifies a set the
- operator did not publish, and the eventlog names each load.
- Response is the revocation above on every target, as fast as the
- fleet can be reached, then a review of every artifact the key
- signed and of the registry's index and tree publications for
- entries the operator did not make, and of the vouches the key made
- for other certificates. Where the compromised key is the only
- one enrolled, the response is the rotation of section 5 compressed
- into the time the fleet allows: add a new key, reboot, re-sign,
- revoke. A target whose binary or state is in doubt is reinstalled,
- not repaired; the `operations <operations.rst>`__ guide covers
- both.
-
-7) Custody
-----------
-
-* The signing key belongs on a host with the controls of a certificate
- authority: offline or isolated, with access limited to the people
- who publish. The operator role needs no network beyond the registry
- it pushes to.
-* The key is a PEM file protected by file permissions; shirudo does
- not use PKCS#11 or an HSM. Keep the directory on an encrypted
- volume and back it up encrypted, with the certificate beside it.
-* Keep separate pairs for development, staging and production fleets
- with ``--keys-dir``, and never enrol a development certificate on a
- production target. The test suites generate throwaway pairs of
- their own.
-* A vouch extends the trust of every target that holds the vouching
- key. Treat ``keys vouch`` like a signing operation: run it on the
- operator host, for a certificate whose holder you have verified out
- of band, and keep the vouch with the certificate it is for; it is
- useless for any other.
-* Record each certificate's fingerprint and the ``init_event`` of the
- sets the fleet runs (``status --json`` on a target, ``attest
- predict`` on the operator), and check them wherever a certificate is
- copied: into the initrd, into a registry registration, into an
- inventory.
-* Treat a key that left the operator host, even once, as compromised.
-
-8) Keys in image mode
----------------------
+2) Enrollment, revocation and rotation
+--------------------------------------
The initial BPF certificate is inside the authenticated runtime image.
Additional certificates and their existing vouch signatures are in the
@@ -340,7 +68,7 @@ config image's ``keys/trusted/``; revocation records are in
``keys/revoked/``. A config signature approves that filesystem but does not
replace the BPF trust chain: a new BPF key still needs a valid vouch.
-Image mode enrolls the authorized BPF trust set at boot, then installs the
+Shirudo enrolls the authorized BPF trust set at boot, then installs the
existing reject-all keyring restriction. That restriction cannot be replaced
or bypassed by trusted image callers. There is no live key enrollment and
no new keyring restriction or key-lifetime kernel hooks are required.
@@ -353,7 +81,7 @@ it does not accept that candidate as pending enrollment. To revoke a key,
include its certificate under ``keys/revoked/<fingerprint>.der`` in a new
signed config. Activation unlinks it and purges affected upatches. The config
PCR records the selected trust settings and the NV register records each
-purged upatch's unload. Image-mode ``keys add``, ``bpm key add`` and
+purged upatch's unload. Target ``keys add``, ``bpm key add`` and
``keys revoke`` are refused; there is no target-local override. Removing
a certificate file alone is not a revocation.
@@ -380,7 +108,58 @@ an updated authenticated boot hash and reboot. Provide a config that the
new certificate verifies before rebooting. A config update cannot rotate
its own verification key.
-Image mode accepts older correctly signed config images. Revocation
+Shirudo accepts older correctly signed config images. Revocation
freshness therefore depends on selecting the intended config; neither its
signature nor its PCR measurement prevents rollback. This is a deferred
policy, not permanent local revocation storage.
+
+3) Preparing a new signer
+-------------------------
+
+Generate the new key on its operator and have an already trusted operator
+vouch for its public certificate::
+
+ shirudo genkey --keys-dir new-operator-keys
+ shirudo keys vouch new-operator-keys/cert.der \
+ --keys-dir current-operator-keys -o new-cert.vouch
+ shirudo bpm key fingerprint new-operator-keys/cert.der
+
+Put the certificate and vouch at ``keys/trusted/<fingerprint>.der`` and
+``keys/trusted/<fingerprint>.vouch`` in the config source. Build and sign the
+image, then provision it as part of the authenticated boot rollout. A running
+target refuses live config requiring an unenrolled signer. It must reboot
+with the intended boot selection before accepting BPF from that key.
+
+Keep both keys while rolling out newly signed upatches and repository
+certificates. Once the new key is enrolled and its upatches replace the old
+ones, deliver a config with the old certificate at
+``keys/revoked/<fingerprint>.der``. Activation removes the old live key and
+purges upatches it signed. Preserve earlier vouches needed to validate the
+chain. Check the expected config root and predicted upatch register in
+attestation, not just the target's local status.
+
+4) Custody
+----------
+
+* The signing key belongs on a host with the controls of a certificate
+ authority: offline or isolated, with access limited to the people
+ who publish. The operator role needs no network beyond the registry
+ it pushes to.
+* The key is a PEM file protected by file permissions; shirudo does
+ not use PKCS#11 or an HSM. Keep the directory on an encrypted
+ volume and back it up encrypted, with the certificate beside it.
+* Keep separate pairs for development, staging and production fleets
+ with ``--keys-dir``, and never enrol a development certificate on a
+ production target. The test suites generate throwaway pairs of
+ their own.
+* A vouch extends the trust of every target that holds the vouching
+ key. Treat ``keys vouch`` like a signing operation: run it on the
+ operator host, for a certificate whose holder you have verified out
+ of band, and keep the vouch with the certificate it is for; it is
+ useless for any other.
+* Record each certificate's fingerprint and the ``init_event`` of the
+ sets the fleet runs (``status --json`` on a target, ``attest
+ predict`` on the operator), and check them wherever a certificate is
+ copied: into the initrd, into a registry registration, into an
+ inventory.
+* Treat a key that left the operator host, even once, as compromised.
diff --git a/Documentation/operations.rst b/Documentation/operations.rst
index 34c017b0..e697cbef 100644
--- a/Documentation/operations.rst
+++ b/Documentation/operations.rst
@@ -13,9 +13,10 @@ The `getting-started <getting-started.rst>`__ document brings a target
up; the `initrd <initrd.rst>`__ document describes the production
configuration; this one is about the time after that.
-For the opt-in image mode, see `config-images <config-images.rst>`__
-and section 8 below. The ordinary installation's paths and executable-upgrade
-procedure remain as documented here.
+Every target uses runtime and signed config images. See
+`config-images <config-images.rst>`__ for generation, boot and activation.
+Writable state keeps its seal xattrs; BPF upatches still require signed loaders.
+Commands here denote the configured runtime interpreter and binary invocation.
1) The moving parts
-------------------
@@ -36,8 +37,8 @@ systemd:
module built.
* - ``shirudo.service``
- ``shirudo init`` from the root file system, before
- ``sysinit.target``: finishes the initrd run (labels, eventlog
- record) or does everything itself in the staging configuration.
+ ``sysinit.target``: checks the image-backed initialization and
+ adopts its pending eventlog record.
* - ``shirudo-keepalive.timer``
- ``shirudo status --otel --include-system`` every 5 seconds: the
conditions below and the system facts as an OTLP keepalive.
@@ -52,7 +53,9 @@ systemd:
- ``shirudo bpm tree sync`` every 60 seconds when
``/etc/shirudo/bpm/upatch-tree.conf`` exists.
-The keepalive and map-export units read ``/etc/shirudo/map-export.env``
+Persistent export settings and tree/repository inputs come from the signed
+config image. Host paths below describe their layout; editing a host copy
+does not change the selected config. The keepalive and map-export units read ``/etc/shirudo/map-export.env``
and the ``map_export.*`` keys of ``/etc/shirudo/shirudo.conf``; the
`telemetry <telemetry.rst>`__ document covers what they send and how
to receive it. ``shirudo config`` prints every effective setting with
@@ -80,8 +83,7 @@ machine-readable one. The fields that matter day to day:
``mode``
``production`` (certificate in the kernel's bpf keyring, enforcement
- up), ``staging`` (enforcement up, certificate in the user keyring
- until the next reboot) or ``inactive`` (``init`` has not run).
+ up) or ``inactive`` (enforcement has not been initialized).
``tpm.reachable``
Whether a TPM answered on the TCTI, which the human report names on
@@ -104,10 +106,10 @@ Conditions
- ``ALERT``: the ``lsm/bpf`` link is not pinned; enforcement
is off and the target has not been initialised this boot.
* - ``KeyringSealed``
- - ``WARN`` while staging or before ``init``; ``ALERT`` when
+ - ``WARN`` before ``init``; ``ALERT`` when
the live keyring is not the one ``init`` froze into the
identity map or is gone (every load refuses ``tampered``).
- The detail names the kind of keyring, ``bpf`` or ``user``.
+ The only supported trust anchor is the kernel BPF keyring.
* - ``ChainIntact``
- ``ALERT`` when replaying this boot's eventlog does not
reproduce the live register: something extended it that
@@ -174,27 +176,17 @@ means.
3) Upgrading shirudo
--------------------
-The bpffs guards admit the executable whose inode ``init`` recorded at
-boot. A package upgrade replaces the binary with a new inode, so until
-the next boot the new binary can run read-only commands but cannot
-load, unload or set the payload xattr on a pin: those report
-``tampered`` or a permission error from the LSM. An upgrade is
-therefore::
+Build a new runtime image containing the new binary and its complete library
+closure. Update the runtime root in authenticated bootstrap configuration,
+install the generated service drop-in and rebuild the UKI with its initrd.
+Reboot when the operator chooses. The old runtime remains authorized for its
+boot; replacing a host-root binary does not replace the trusted executable.
- sudo apt install ./shirudo-target_<version>_amd64.deb # or dnf, or the tarball
- sudo shirudo-gen-initrd
- sudo reboot
-
-The second step matters: the initrd carries its own copy of the binary,
-and ``init`` warns at boot when the root's binary differs from it.
-Kernel package updates rebuild the initrd through dracut's hooks, so
-the module's copy follows the binary installed at that time; a shirudo
-upgrade alone does not trigger a rebuild. The pending eventlog record
-and the seal label are the same across versions, so an upgrade needs no
-state conversion. When shirudo is installed on a target for the first
-time, the package enables ``shirudo.service`` for the next boot and
-nothing more; ``systemctl start shirudo.service`` brings enforcement up
-immediately, in the staging configuration until the reboot.
+A new runtime or config verification certificate requires this boot rollout.
+Config and signed upatch updates remain live. Missing runtime files or an
+incorrect authenticated root stop initialization rather than choosing a
+host-root fallback. Installing a target package alone does not provision the
+images or start enforcement.
4) Kernel updates
-----------------
@@ -202,7 +194,7 @@ immediately, in the staging configuration until the reboot.
A new kernel package makes dracut build an initrd for it, and the
shirudo module includes itself whenever a certificate is installed, so
the production configuration carries over without action. The kernel
-parameter ``bpf.keyring_unsealed=1`` lives in the boot loader's
+parameters ``bpf.keyring_unsealed=1 dm_verity.keyring_unsealed=1`` live in the boot loader's
configuration, which the installer wrote once.
The upatches do not carry over by themselves. ``init`` restores the
@@ -311,34 +303,23 @@ The register is gone before the next reboot
the reset count on the record lets ``init`` tell apart. Reboot,
and read the eventlog of the boot it happened in.
-``KeyringSealed`` warns ``staging``
- The kernel sealed the bpf keyring empty at boot, so ``init`` staged
- the certificate in the user keyring. The kernel parameter is
- missing, the initrd has no shirudo in it, or ``shirudo-initrd.service``
- failed; ``journalctl -b -u shirudo-initrd.service`` and the
- `initrd <initrd.rst>`__ document say what to check. Enforcement
- is up either way.
-
-The initrd copy differs
- ``init`` warns when the root's binary or trusted set differs from
- the initrd's: the initrd was not rebuilt after an upgrade, a
- ``keys add`` or a ``keys revoke``. Run ``shirudo-gen-initrd`` and
- reboot at the next opportunity.
+Initialization cannot enroll the BPF keys
+ Check both enrollment boot parameters, authenticated runtime settings and
+ selected image files. A sealed empty BPF keyring is an error. Read the
+ journal of ``shirudo-initrd.service`` and verify the UKI was regenerated.
+ Shirudo cannot open an already sealed keyring at runtime.
``certs_unvouched`` is not zero
- A file under ``keys/trusted`` has no vouch that verifies under a
- member, so it is not enrolled: something other than ``shirudo keys
- add`` put it there, or the key that vouched for it was revoked.
- Remove it, or re-vouch it from an operator holding a remaining key
- and run ``keys add`` again.
+ A config signer certificate lacks a valid vouch. Prepare the certificate
+ and vouch on the operator and deliver them in the intended signed config.
+ Invalid config trust material is refused before activation. New signer
+ enrollment requires reboot; see `key-lifecycle <key-lifecycle.rst>`__.
A key is compromised
- ``shirudo keys revoke <fingerprint>`` on every target the key is
- enrolled on, then ``shirudo-gen-initrd``; the `key-lifecycle
- <key-lifecycle.rst>`__ guide gives the order and what the command
- does to the archive. A target that cannot be reached keeps
- trusting the key until it is; the evidence of the ones that have
- revoked carries the ``key_revoke`` event.
+ Deliver a signed config containing its revocation record. Activation
+ removes the live key and purges its upatches. A node that has not received
+ the config still trusts the key. Require the intended config root in
+ attestation. Local ``keys revoke`` is disabled.
A pending record lingers
``/run/shirudo/eventlog.pending`` is the initrd run's record until
@@ -422,8 +403,8 @@ success, ``1`` on any refusal or failure and ``2`` on a usage error;
- An error without a closer category; errno is in the report.
- Read the report.
-8) Operating image mode
------------------------
+9) Config updates
+------------------
Use ``shirudo image status`` to inspect the active config root hash, PCR,
TPM reset and restart counts, event sequence and pending state. Ordinary target commands
diff --git a/Documentation/requirements.rst b/Documentation/requirements.rst
index 4386ae6e..685b4ce5 100644
--- a/Documentation/requirements.rst
+++ b/Documentation/requirements.rst
@@ -74,9 +74,9 @@ fixture.
and sealed it. The kernel is booted with
``bpf.keyring_unsealed=1`` so that the keyring takes the
certificate from the initrd; booted without, it is sealed
- empty. Ordinary installations then stage the certificate in a
- ``shirudo`` user keyring until the next reboot. Image mode
- refuses initialization instead of staging.
+ empty. Shirudo refuses initialization until reboot with the
+ enrollment parameter; it has no user-keyring fallback.
+
* - ``CONFIG_X509_CERTIFICATE_PARSER``,
``CONFIG_PKCS7_MESSAGE_PARSER``,
``CONFIG_SYSTEM_DATA_VERIFICATION``
@@ -122,7 +122,7 @@ Image mode supports 64-bit userspace only. Disable 32-bit compatibility
``CONFIG_X86_X32_ABI``. Device-mapper restrictions use the native
``file_ioctl`` hook and do not cover compat ioctls.
-The opt-in dm-verity mode additionally requires ``CONFIG_BLK_DEV_DM``,
+Every target also requires ``CONFIG_BLK_DEV_DM``,
``CONFIG_DM_VERITY``, ``CONFIG_BLK_DEV_LOOP`` and ``CONFIG_EXT4_FS``. Runtime
and config mappings use verity format 1, SHA-256, 4096-byte blocks and a
standard verity superblock. ``CONFIG_DM_VERITY_VERIFY_ROOTHASH_SIG`` is
@@ -139,8 +139,7 @@ UKI-authenticated root; config-signing trust does not authorize executables.
Image enforcement uses existing upstream LSM hooks. Existing hooks do not establish every desired protection against
hostile device-mapper controls or mount-tree changes; see the limitations in
`config-images <config-images.rst>`__. BPF signing keys are enrolled at boot
-before reject-all keyring sealing. Ordinary installations do not enable
-image mode implicitly.
+before reject-all keyring sealing. Missing image settings stop initialization.
Production image mode requires authenticated measured UKI boot, the
runtime root hash in authenticated bootstrap settings, a reserved static
diff --git a/Documentation/telemetry.rst b/Documentation/telemetry.rst
index 7cc11b15..4dbfe8f7 100644
--- a/Documentation/telemetry.rst
+++ b/Documentation/telemetry.rst
@@ -18,14 +18,12 @@ that give a record its shape, the documents on the wire, the transport
and its configuration, and how to land the data in the OpenTelemetry
Collector, ClickHouse, Splunk or a collector of your own.
-In image mode, persistent ``map_export.*`` settings belong in
-``etc/shirudo/shirudo.conf`` inside the signed config image. Build and activate
-that config with ``shirudo image update``; editing the host's file does not
-change image-mode settings. Configure the export and keepalive services to
-invoke the runtime binary through its packaged interpreter and libraries.
-The map, serializer, decoder and OTLP flows below are shared by both modes.
-Bootstrap TPM and trust-path environment overrides are refused in image
-mode; ordinary export options do not authorize changes to those inputs.
+Persistent ``map_export.*`` settings belong in ``etc/shirudo/shirudo.conf``
+inside the signed config image. Activate that config with ``shirudo image
+update``; editing the host's copy does not change the effective settings.
+Services invoke the runtime interpreter and binary with image libraries.
+Bootstrap TPM and trust-path environment overrides are refused; export command
+options do not authorize changes to those inputs.
1) The pipeline
---------------
diff --git a/Documentation/threat-model.rst b/Documentation/threat-model.rst
index 60e4a74e..33cc5909 100644
--- a/Documentation/threat-model.rst
+++ b/Documentation/threat-model.rst
@@ -30,7 +30,7 @@ The assets, in the order an attacker would want them:
- the private signing key on the operator;
- the certificate on the target and the sealed bpf keyring it is
- enrolled in, or the sealed ``shirudo`` user keyring that stages it;
+ enrolled in;
- the enforcement links and the identity map pinned in the private
bpffs: losing them means losing enforcement;
- the loaded upatches, their pins and the payload xattrs that bind a
@@ -51,23 +51,13 @@ which the measured boot records in PCRs 9 and 11. Every other process
on the target, including root with every capability, is outside the
TCB and constrained by it.
-Ordinary installations have two configurations and ``status`` names them.
-In production the
-kernel is booted with ``bpf.keyring_unsealed=1`` and ``init`` runs from
-the initrd: the certificate goes into the kernel's bpf keyring, which
-``init`` seals and nothing can replace, and the register binds while
-PCR 11 holds the ``enter-initrd`` phase, which nothing that runs later
-can bring back. Staging is what a target gets when ``init`` runs from
-the root file system on a kernel that sealed the bpf keyring empty at
-boot: the certificate sits in a ``shirudo`` keyring under the user
-keyring, sealed, and the register binds under the post-initrd phase
-value. The mechanisms below apply to both; the residual risks describe
-staging weaknesses, including certificate invalidation, and the
-verifier can refuse staged evidence outright.
-
-The opt-in image mode requires production initialization and refuses
-user-keyring staging. It adds authenticated runtime and config images to
-this boundary. The UKI supplies the runtime root hash, and the runtime image
+Every target boots with authenticated runtime and config images. The initrd
+initializes enforcement before untrusted workloads, enrolls its trust anchors
+and seals the kernel BPF and dm-verity keyrings. Missing image settings or a
+sealed empty BPF keyring stop initialization. There is no user-keyring staging
+or executable-inode fallback.
+
+Authenticated images are part of this boundary. The UKI supplies the runtime root hash, and the runtime image
supplies the config verification certificate, initial BPF anchors and TPM
settings. The config signature authorizes that image's contents; it does not
replace BPF signatures or vouch requirements. Every executable on the runtime
@@ -118,14 +108,9 @@ T1 Loading unsigned BPF
``lsm/bpf`` admits a userspace ``BPF_PROG_LOAD`` only for a
``BPF_PROG_TYPE_SYSCALL`` program that carries a signature. The
kernel verifies that signature against the sealed bpf keyring
- named as ``attr.keyring_id`` (or, while the certificate is staged,
- the sealed ``shirudo`` keyring's serial), before the verifier runs,
- and ``lsm/bpf_prog_load`` then requires the verdict
- ``BPF_SIG_VERIFIED`` from exactly that keyring kind and, while
- staging, that serial (the kernel records none for its own bpf
- keyring). Userspace ``BPF_MAP_CREATE`` is restricted to the
- executable ``init`` recorded as shirudo in ordinary mode, or a
- trusted task in image mode. Image task authority is committed after
+ named as ``attr.keyring_id = KEY_SPEC_BPF_KEYRING`` before the verifier
+ runs. ``lsm/bpf_prog_load`` requires ``BPF_SIG_VERIFIED`` from that kernel
+ keyring. Userspace map creation requires task authority committed after
successful exec from the runtime device; the authenticated bootstrap
task has temporary authority during initialization. Signed loader map
creation runs in kernel context. The payload is hash-locked to the loader by
@@ -137,8 +122,7 @@ T2 Detaching or replacing enforcement
``lsm/bpf`` denies ``LINK_DETACH``, ``LINK_UPDATE``,
``PROG_ATTACH``, ``PROG_DETACH`` and ``BTF_LOAD`` from userspace,
and leaves ``LINK_CREATE``, ``RAW_TRACEPOINT_OPEN`` and ``OBJ_PIN``
- to Shirudo authority: the recorded executable in ordinary mode or a
- trusted task in image mode. Root cannot re-attach a vetted program
+ to a task authorized by successful runtime exec. Root cannot re-attach a vetted program
at a site its signer never meant it for, nor pin objects of its own.
The links are kept alive by pins in the private bpffs;
``inode_unlink`` and ``inode_rename`` there require that authority.
@@ -154,26 +138,19 @@ T2 Detaching or replacing enforcement
authority too; kernel-context loader calls remain allowed. Root therefore cannot invoke a signed
serializer to drain or clear map state. Root may inspect pinned maps
but cannot alter serializer arrays or writable-mmap arena state
- through the syscall interface. In ordinary mode, the initrd records
- the root's binary as the executable that lasts and the initrd's
- own copy beside it for that one run; the copy is gone with the
- initrd, and its inode is on a file system nothing can reach after
- the switch.
+ through the syscall interface.
T3 Tampering with shirudo's files and process
Initialization labels existing files under ``/var/lib/shirudo`` with
``security.bpf.shirudo``. For labelled targets, the seal checks write
open, unlink, both ends of rename, attribute and xattr changes.
- Ordinary mode authorizes the frozen executable identity or its initrd
- copy, by device and inode; image mode uses the trusted task mark.
+ The trusted task mark authorizes the caller.
Only an authorized caller may set the exact label, including on an
unlabelled inode. A copied label marks a target, not caller authority.
Any label size or read error requires authority except ``ENODATA``,
``EOPNOTSUPP``, ``EACCES`` and ``EPERM``; the permission exceptions
preserve operations on files the caller cannot read. Scratch allocation
- failure also requires authority. Ordinary mode permits replacing the
- recorded primary executable, but its replacement gains no authority
- until a later initialization records it.
+ failure also requires authority.
New inodes inherit their parent's label in the creation transaction
when the parent has a cached seal mark. Shirudo's writers hold the
parent directory open to populate and retain that mark. Directory
@@ -182,21 +159,16 @@ T3 Tampering with shirudo's files and process
Ptrace and perf allocation checks deny against tasks already marked
when those hooks run. Concurrent perf attachment and exec remain a
separate, untested `race investigation <https://github.com/shirudo-dev/shirudo/issues/11>`__.
- Recorded Shirudo executables reject traced callers and run in
+ Runtime executables reject traced callers and run in
secure-exec mode, so the loader ignores unsafe environment variables.
The process drops dumpability, forbids new privileges and locks
sensitive buffers. The bpf keyring is sealed with
``KEYCTL_RESTRICT_KEYRING`` so no key can be linked into it for the
rest of the boot, ``lsm/key_permission`` leaves writing, unlinking,
revoking, invalidating and re-permissioning it and the keys it
- holds to shirudo's own executable, and the kernel then refuses
- every caller-supplied
- keyring for signature verification; a staged ``shirudo`` keyring is
- sealed with ``KEYCTL_SETPERM``. The kind and serial of the keyring
- ``init`` sealed are frozen into the identity map, pinned in the
- bpffs and read back by every later command, so a swapped same-name
- keyring makes every load refuse ``tampered``. Staged certificates have
- a separate invalidation exception described in residual risk 6.
+ holds to tasks with runtime authority. The kernel refuses caller-supplied
+ keyrings for signature verification. The BPF ring serial and enrolled key
+ serials are frozen into the pinned identity map and checked by later loads.
T4 Substituting artifacts
The signature covers the loader instructions and data, so the kernel
@@ -375,22 +347,14 @@ Each of these is known, documented and bounded; none is silent.
honest substitution; closing this fully needs an in-kernel detach so
the compare runs against signed ``.rodata``.
-2. ``CAP_SYS_RESOURCE`` can rewrite ``mm->exe_file``. Shirudo's
- ``task_prctl`` LSM hook denies ``PR_SET_MM_EXE_FILE`` and
- ``PR_SET_MM_MAP`` to every caller outside the frozen Shirudo
- executable identity, preventing a root process from impersonating
- Shirudo through these operations. This also denies those two
- operations to checkpoint and restore tools. A process that directly
- executes the recorded Shirudo binary is still identified as Shirudo,
- so its command interface remains the authorization boundary. That
- process runs in secure-exec mode, so ``LD_PRELOAD``, ``LD_AUDIT``
- and the like cannot put the caller's code into it, and a traced
- task cannot start it at all. The loader still reads
- ``/etc/ld.so.preload`` and the shared libraries the binary names,
- which root controls; a statically linked executable would close
- that. Bound
- ``CAP_SYS_RESOURCE`` out of untrusted contexts with
- ``CapabilityBoundingSet=`` and container capability profiles.
+2. ``CAP_SYS_RESOURCE`` can rewrite ``mm->exe_file``. The task mark is
+ independent of that field, and ``task_prctl`` denies those operations to
+ untrusted callers. Successful runtime exec grants authority; failed exec
+ preserves the old mark and outside-image exec clears it. Runtime programs
+ run with secure-exec, reject tracing and existing seccomp, and cannot map
+ executable host or anonymous pages. Their command interface remains the
+ authorization boundary. The authenticated initrd bootstrap binary and
+ trusted runtime process memory remain in the TCB.
3. A lazy unmount of a mount above ``/run/shirudo/bpffs``, such as
``umount -l /run``, can detach the bpffs with it. The kernel calls
@@ -423,25 +387,13 @@ Each of these is known, documented and bounded; none is silent.
Restricting measurement writers and handling operation/measurement
ordering remain separate work; no IMA integration is added.
-5. In the ordinary installation, executable integrity before init belongs
- to the distribution and authenticated boot. Image mode authenticates
- and verifies runtime files, including their loader and libraries, but
- still trusts the UKI, kernel and its own trusted process memory.
- ``SHIRUDO_VERSION_ID`` remains a skew guard, not authentication.
-
-6. While the certificate is staged in the user keyring, a keyring
- swap degrades to denial of service. Root can unlink the sealed
- ``shirudo`` keyring and create a fake one with the same name; the
- serial frozen in the identity map turns that into a fail-closed
- refusal, for the rest of the boot, instead of a
- bypass. The bpf keyring, the production anchor, can be neither
- unlinked nor substituted, and the kernel refuses every other
- keyring once it is sealed. A fresh upstream VM also reproduced root
- invalidating its possessed staged certificate through ``keyctl``.
- The key-permission hook permits possessed ``KEY_NEED_SEARCH``
- references, which the kernel also uses for invalidation. This removes
- the certificate despite the mutation guards. Image mode refuses
- user-keyring staging.
+5. Authenticated boot must verify the expected runtime root. dm-verity
+ verifies runtime files but still trusts the UKI, kernel and trusted process
+ memory. ``SHIRUDO_VERSION_ID`` is a skew guard, not authentication.
+
+6. There is no user-keyring staging fallback. Boot without the required
+ enrollment parameters, authenticated settings or valid images fails
+ initialization. A failed init does not create a protected target.
7. The boot window before ``init`` has run. Run from the initrd it
is the initrd itself, which the measured boot records in PCRs 9 and
@@ -494,22 +446,13 @@ Each of these is known, documented and bounded; none is silent.
7, and the binding then carries a PCR 11 value the verifier can
reject.
-13. Revocation reaches a target only when run there. ``shirudo keys
- revoke`` unlinks the key from the running kernel and keeps it out
- of every later boot, but a target the operator cannot reach keeps
- verifying against the revoked key until it is reached; shirudo has
- no push channel by design. Evidence tells the two apart: a
- revoked node's register carries the ``key_revoke`` event, and
- ``attest predict --event=revoke:...`` names the value to expect.
- The production set is guarded by ``key_permission`` checks against
- unlink, clear, revoke and invalidate. User-keyring staging has the
- reproduced invalidation exception in residual risk 6.
- Image mode instead receives revocations through a signed config. Its
- config PCR records the selection, and purged upatches have their unload
- events in the NV register. It has no local ``keys revoke`` override and
- still depends on delivery and activation of the intended config.
-
-14. Image mode accepts an older config when its signature is valid. A
+13. Revocation reaches a target only when its signed config is delivered
+ and activated. A node that has not received it can still verify BPF signed
+ by the old key. The config PCR records activation, and revoked signers'
+ upatches receive unload events in the NV register. There is no local
+ ``keys revoke`` override or push channel.
+
+14. Shirudo accepts an older config when its signature is valid. A
config PCR extension records the selection but does not enforce
freshness. Replaying an older config can restore its older trust and
revocation settings. Rollback prevention is deferred. The config
@@ -563,11 +506,10 @@ directory the moment its dentry is bound (residual risk 15).
Keep the signing key on a host with the controls of a certificate
authority and never on a target. Boot targets with
-``bpf.keyring_unsealed=1`` and run ``init`` from the initrd; a target
-whose ``status`` says ``staging`` has its trust anchor in a user
-keyring and its register bound after the initrd, and a fleet check
-that passes ``--require-initrd`` and ``--expect-bind-pcr=11`` with the
-UKI's ``enter-initrd`` value does not accept it. Give ``challenge``
+``bpf.keyring_unsealed=1 dm_verity.keyring_unsealed=1`` and run ``init``
+from the authenticated initrd with valid runtime and config images. Check
+``--require-initrd`` and ``--expect-bind-pcr=11`` against the UKI's measured
+``enter-initrd`` value. Give ``challenge``
the manufacturer's issuers with ``--ek-ca`` wherever the TPM has a
certificate. Treat ``tampered`` as an incident to understand, not a
condition to retry. Verify ``shirudo status`` after
diff --git a/Documentation/upatch-spec.rst b/Documentation/upatch-spec.rst
index 1f9b4b34..9b097c6d 100644
--- a/Documentation/upatch-spec.rst
+++ b/Documentation/upatch-spec.rst
@@ -139,7 +139,7 @@ A detached CMS/PKCS#7 signature over ``loader_insns || data``, produced
by the vendored ``util/sign.c`` on the operator. On the target, the
kernel's ``bpf_prog_verify_signature()`` checks it against the
certificate in the sealed bpf keyring, named as ``attr.keyring_id``
-(while staging, the sealed ``shirudo`` keyring's serial), before the
+(``KEY_SPEC_BPF_KEYRING``), before the
verifier and the LSM hooks run.
The container is algorithm-agnostic: the SignerInfo names the key
diff --git a/Documentation/upatch.rst b/Documentation/upatch.rst
index 598e0b7b..d6027b9b 100644
--- a/Documentation/upatch.rst
+++ b/Documentation/upatch.rst
@@ -15,15 +15,13 @@ load path and the registry formats, and the `telemetry
<telemetry.rst>`__ document covers decoders and the export pipeline in
depth. This guide is the workflow that ties them together.
-Operator build, sign and publish commands are the same for both target
-policy modes. The writable repository-registration examples below describe
-the ordinary installation. Image-mode targets instead receive repository
-definitions, public verification certificates, the tree subscription and node
-labels in a signed config image. Local ``bpm config register`` mutations and
-``bpm key add`` are refused there. Package installation, upgrades and tree
-sync still run on the target; they read the selected authenticated config.
-New BPF signers require boot enrollment, while signed revocation configs and
-upatch updates remain live. See `config-images <config-images.rst>`__.
+Operator build, sign and publish commands prepare artifacts on the operator.
+Targets receive repository definitions, public verification certificates, tree
+subscriptions and node labels in a signed config image. Local repository and
+key mutations are refused. Examples that prepare these files belong on the
+operator before image generation; target package and tree commands read the
+selected config. BPF programs still require signed loaders and vouched boot
+enrollment. See `config-images <config-images.rst>`__.
1) What an upatch is
--------------------
diff --git a/bpf/seal.h b/bpf/seal.h
index a7df2462..0d36f527 100644
--- a/bpf/seal.h
+++ b/bpf/seal.h
@@ -69,8 +69,8 @@ int bpf_inode_init_xattr(struct xattr *xattrs, int *xattr_count__ctx_out,
const struct bpf_dynptr *value_p) __ksym;
/*
- * Labels identify protected targets in both modes. Caller authority comes from
- * the selected executable policy, never from a label on the caller's binary.
+ * Labels identify protected writable targets. Caller authority comes from
+ * successful runtime exec, never from a label on the caller's binary.
*/
static __always_inline int seal_caller(enum shirudo_tamper_point point)
{
diff --git a/contrib/verity-vm/README.md b/contrib/verity-vm/README.md
index a25b5423..5c0e0005 100644
--- a/contrib/verity-vm/README.md
+++ b/contrib/verity-vm/README.md
@@ -4,7 +4,7 @@ The configs, service units and guest scripts used by the image tests live
here. The calling scripts copy these files and substitute the values named
between `@` characters in `.in` templates.
-`seed-root.sh` installs the ordinary boot files in the initrd. Image mode
-also runs `seed-images.sh`. `install-guest.sh` finishes the manual VM setup.
+`seed-root.sh` installs the boot files in the initrd and `seed-images.sh`
+installs the runtime and signed config fixtures. `install-guest.sh` finishes the manual VM setup.
The runtime service template used by the operator is kept separately in
`tools/gen-image/runtime-service.conf.in`.
diff --git a/tools/gen-image/README.md b/tools/gen-image/README.md
index 29a86d52..bf434223 100644
--- a/tools/gen-image/README.md
+++ b/tools/gen-image/README.md
@@ -91,8 +91,7 @@ this bootstrap file carries `runtime.image` and `runtime.root_hash`, while
the file inside the runtime image carries config verification settings.
The initrd's first invocation still uses its authenticated bootstrap binary.
The state filesystem at `/sysroot/var/lib/shirudo` must be mounted writable
-in the initrd for durable pending config selection; the legacy mode keeps
-its existing read-only bind. Image mode is bootstrapped exclusively by the
+in the initrd for durable pending config selection. Shirudo is bootstrapped by the
trusted initrd before untrusted workloads start. It does not migrate a
running unprotected system: pre-existing writable mappings and held file
descriptors would fall outside that bootstrap guarantee. State entries must
diff --git a/tools/gen-initrd/install.sh b/tools/gen-initrd/install.sh
index d1df9a92..834f2e51 100755
--- a/tools/gen-initrd/install.sh
+++ b/tools/gen-initrd/install.sh
@@ -7,7 +7,7 @@
# keyring needs on the boot command line and rebuild the initrd with
# shirudo inside, so that the next reboot comes up in the production
# configuration (Documentation/initrd.rst). Runtime and signed config
-# starts right away in the staging configuration until that reboot.
+# images must be provisioned separately before the authenticated UKI is rebuilt.
#
# curl -fsSL https://raw.githubusercontent.com/shirudo-dev/shirudo/main/tools/gen-initrd/install.sh |
# bash -s -- --cert https://example.com/shirudo/cert.der
diff --git a/util/identity.h b/util/identity.h
index 4b60791a..56909254 100644
--- a/util/identity.h
+++ b/util/identity.h
@@ -40,7 +40,7 @@ struct shirudo_device_authority {
__u64 diskseq;
};
-/* Image-only task storage for one config mapping preparation. */
+/* Task storage for one config mapping preparation. */
struct shirudo_expected_root {
__u8 root[32];
__u32 valid;
diff --git a/util/seal.h b/util/seal.h
index ab2c7a54..fd1ffd09 100644
--- a/util/seal.h
+++ b/util/seal.h
@@ -14,7 +14,8 @@
/*
* The label value: SHA-256 of the xattr name, 64 hex characters, the
* same for every build. bpf/seal.c takes the label, whatever its value,
- * as marking a protected inode; the identity map says who may touch it.
+ * as marking a protected inode. A runtime task mark authorizes the caller;
+ * copying this public label never grants authority.
*/
#define SHIRUDO_SEAL_LABEL \
"94442b45cfcdc59aabc2a91364ed2ae129418e05a5c1985231b9c032e673f469"
@@ -23,8 +24,8 @@
int seal_label(const char *path);
/*
- * Before the seal attaches, so the bulk setxattr is not gated; best
- * effort per entry.
+ * Label writable state before attaching the seal. Refuse non-file entries
+ * and stop on the first failed label; partial sealing is an init failure.
*/
int seal_label_tree(void);