Test a upatch on a target#
Load a upatch on a real target before it ships, read what it records,
and unload it again. The test VM in a shirudo checkout is such a target:
it boots the dm-verity runtime image and a signed config image from a
dracut initrd, with a software TPM, and runs shirudo init there as a
production target does. This page uses it, and the commands on the target
are the same elsewhere.
Before you begin#
A shirudo checkout built with
makeandmake shirudo-buildA Linux host with KVM, root, and the host packages the test VM needs, listed in Run and write tests
A upatch and its unload directive, built as in From a kernel fix to a upatch, or one of the signed fixtures below
Boot the test VM#
Boot an interactive VM from the checkout’s root:
# make -C testing vm VM_NAME=upatch-dev
VM_NAMEis optional and names the VM for the commands below. The VM boots a bpf-next kernel by default.KERNEL=7.4, or a later release, boots that release instead. The first run builds the kernel and the bundle of signed images and fixtures, which takes a while. The command returns once the VM is ready.Open a shell on it:
# make -C testing vm-ssh VM_NAME=upatch-dev
Without
VM_NAME,vm-sshopens the most recently started VM.Check that enforcement is up:
target# shirudo-runtime status Host: upatch-dev Roles: target Status: ok ...
The
Status:line readsok. In the VM, run every shirudo command asshirudo-runtime. It executes shirudo from the verified runtime image, and only a process started from that image has shirudo’s runtime authority. The plainshirudoin the VM,/usr/local/bin/shirudo, is the same binary outside the runtime image. Every command of it that reads shirudo’s state stops withshirudo: image state: Permission denied.
Get the upatch into the VM#
Sign the upatch and its unload directive with the key the VM enrolled. The bundle keeps it outside the checkout, which the VM can read, in
/tmp/shirudo-test-vm-private-<uid>/operator-keys/keys, where<uid>is your user ID, or underTEST_VM_HOST_PRIVATE_DIRwhen you set it. Pass that directory toshirudo build --keys-dir, as root: the bundle belongs to the user who built the VM.Put both files under the checkout, for example under
build/. The VM sees the checkout read-only at/mnt/shirudo-src, sobuild/rpl-shield/cve-2026-63984-rpl.upatchon the host is/mnt/shirudo-src/build/rpl-shield/cve-2026-63984-rpl.upatchin the VM.
Load and observe it#
Load the upatch and keep the report:
target# shirudo-runtime upatch load --report=/tmp/load.json \ /mnt/shirudo-src/<path>.upatch
<path>is the upatch’s path in the checkout. The command exits with 0 on success, 2 when an attach target is missing or the command line is wrong, and 1 on any other failure. The report’scategorysays why, and Debug a failed load goes through each one. To refuse the load unless the measurement register still holds a value you read before, add--expect-chain=<chain>, with<chain>thetpm.chainfield ofshirudo-runtime status --json.List what is loaded and archived:
target# shirudo-runtime upatch list
Show where the upatch attached, its program source lines and its maps:
target# shirudo-runtime upatch get <name>
<name>is the upatch name, whichshirudo upatch infoshows on the operator host.Run the workload or the reproducer that should reach the hooked code, then read a map without draining it:
target# shirudo-runtime upatch map <name> <map> --peek
shirudo-runtime upatch map <name>lists the upatch’s maps. A map with a serializer is rendered by it, and--peekasks the serializer to leave the records for the exporter. Add--jsonto see what the map’s decoder returns. For a map without a decoder,--jsonfails withupatch map: print JSON: No data available.
Unload it#
Apply the unload directive:
target# shirudo-runtime upatch unload --report=- \ /mnt/shirudo-src/<path>.unload.upatch
The report shows category
ok.already_unloaded, with exit status 0, means nothing of that name was loaded.payload_mismatch, with exit status 1, means the directive was built for another build of the upatch, and the upatch stays loaded.Verify that the upatch is gone and the target is still healthy:
target# shirudo-runtime upatch list target# shirudo-runtime status
The upatch is not listed, and
statusstill readsok. Every load and unload moved the measurement register forward.Leave the VM shell, and stop the VM on the host when you are done:
# make -C testing vm-stop VM_NAME=upatch-dev
Without
VM_NAME,vm-stopstops every VM it tracks. The VM’s state stays underbuild/test-vm/vms/.
Use the signed fixtures#
The bundle carries upatches signed with the same key, in the VM at
/mnt/shirudo-bundle/fixtures/, those below with an .unload.upatch
beside them. Their sources are in testing/fixtures/. They are handy for
trying the commands above or for comparing your upatch with a known good
one.
Fixture |
What it shows |
|---|---|
|
an |
|
two maps, one with a log decoder and one with a metric decoder |
|
log and metric decoders for the OTLP export |
|
a serializer over an array map, with a metric decoder |
|
a binary tree in an arena, rendered by a serializer |
|
|
|
|
|
|
|
sleepable |
|
|
|
the upatch of the |
The test VM’s kernel configuration has no kprobes, so the kprobe fixture
fails there with attach_target_missing, which shows what that
category looks like.
Next steps#
Debug a failed load when a load fails
Publish a package once the upatch works
Run and write tests for the automated tests that boot the same VM