TellWorldAI World Archive

Home›Practice›Practice

Practice

Shirudo quickstart: installing it and loading your first live patch on Linux

Install shirudo on Linux and run one full cycle in a test VM: build it, boot a protected target, sign and load your first upatch, verify it with the TPM, then unload it.

Who this is for and what you will get

This guide is for developers who want to try BPF live patches on Linux, starting in a virtual machine. By the end you will have built shirudo from a checkout, booted a protected test target, signed and loaded your first upatch (a signed BPF program), checked with the TPM that it is running, and unloaded it. Installing on real hosts comes after that.

What shirudo is

shirudo is a BPF security platform for Linux. It delivers BPF programs, which it calls upatches, to running machines without a reboot. It also restricts the bpf() system call so that the kernel accepts BPF from userspace only inside a loader signed with the operator's key[1]. Every change to the loaded set is measured into a TPM register, and the TPM can sign that record on request[1]. There are two roles: the operator holds the private key and builds, signs and verifies, while a target holds only public certificates and enforces the policy[1].

Requirements

The quickstart needs an x86-64 or arm64 Linux host where /dev/kvm is readable and writable. On a Mac, the docs recommend a Lima VM as the Linux host[1]. The shirudo binaries refuse to run unless the locked-memory limit (ulimit -l) is unlimited. Root is not required, because the test VM builds its initrd with dracut as the current user[1].

Building needs clang and LLVM 23 with the BPF target, installed as /usr/bin/clang, plus OpenSSL 3.5 or later, libelf, zlib, libcurl 7.75 or later, tpm2-tss and LuaJIT[1]. The test VM needs QEMU, swtpm, tpm2-tools, cloud-image-utils and dracut-core, among other packages. The VM scripts stop at the first missing command and print the command that installs it[1]. The first boot downloads an Ubuntu cloud image, so you need network access[1]. The attestation step needs jq and openssl[1].

Step 1: fetch the test kernel and build

From the checkout root, download and stage the CI kernel for your architecture. The bundle includes the kernel, its BTF, configuration and modules, and shirudo compiles its embedded BPF objects against that BTF[1].

operator$ testing/vm/kernel-artifact.sh fetch

Then build the shirudo binary, which you run on both sides, and the operator helper shirudo-build. The helper compiles and signs. The signing code lives only in the helper, so it never reaches a target[1].

operator$ make
operator$ make shirudo-build

Put both on your PATH for the current shell so that shirudo can find the helper[1]:

operator$ export PATH="$PWD:$PWD/tools/shirudo-build:$PATH"

Step 2: boot a test target

The first make -C testing vm VM_NAME=quickstart takes a while. It builds a disk image and a bundle with the static target binary, a dm-verity runtime image, signed config images and a throwaway signing key. Later runs reuse them[1].

operator$ make -C testing vm VM_NAME=quickstart
...
[test-vm] building an initrd with shirudo for 7.3.0-bpf-next+
[test-vm] booting bzImage with 4 CPUs and 4G memory
[test-vm] VM ready: name=quickstart state=.../build/test-vm/vms/quickstart qemu_pid=... swtpm_pid=...
...
[test-vm] console: make -C testing vm-console VM_NAME=quickstart
[test-vm] ssh: make -C testing vm-ssh

The VM boots the way a production target does. The kernel starts with the BPF LSM and with the .bpf and .dm-verity keyrings open for enrollment. shirudo init runs from the initrd, enrolls the bundle's certificates, seals the .bpf keyring, attaches its LSM programs and binds the measurement register to a software TPM (swtpm)[1]. One difference from production is that QEMU starts the kernel and initrd directly, not from a signed unified kernel image, so the boot phases are not measured into PCR 11[1].

Open a root shell on the target with make -C testing vm-ssh VM_NAME=quickstart. Commands with the target# prompt run in that shell[1]:

operator$ make -C testing vm-ssh VM_NAME=quickstart

On the target, the trusted binary is /run/shirudo/runtime/usr/bin/shirudo. The LSM grants access to shirudo's state only to tasks that ran that binary from the runtime image, so the copy under /usr/local/bin refuses to read it[1]:

target# /usr/local/bin/shirudo status
shirudo: image state: Permission denied

Step 3: check that enforcement is on

shirudo status prints a report. A healthy target shows Status: ok with every condition OK. The conditions to look at are LsmAttached (the LSM link is pinned), KeyringSealed (the keyrings are sealed), ChainIntact (the register matches the eventlog) and TpmMeasured (the TPM index is readable)[1]:

target# shirudo status
Host:                  quickstart
Roles:                 target
Status:                ok
Version ID:            414d0c75238fcc31b1d60ce78b4943a8b450f49556a5cb255d62392061b87ccf

Conditions:
  TYPE               STATUS  DETAIL
  LsmAttached        OK      lsm/bpf link present and pinned
  KeyringSealed      OK      bpf serial 1025034781, dm-verity serial 939334546, pins match
  ChainIntact        OK      live register equals the eventlog replay
  UpatchesMeasured   OK      every pinned or archived upatch is in this boot's records
  TpmMeasured        OK      NV index 0x01818E00 readable
  ConfigActive       OK      config bb3a83a57bbd.. is active
  XdpCovered         OK      every device an XDP upatch selects runs it

The report also counts refused tamper attempts since boot, such as LoadNotLoader, MapCreate, BpfCommand and ObjGet. Scripts can read the verdict from shirudo status --json[1]. Running shirudo status --show-full expands the folded sections, including the .bpf keyring serials, the TPM measurement and the eventlog[1]. Reading one of shirudo's pins as root fails with Permission denied, and the next report counts the attempt under ObjGet[1]:

target# cat /run/shirudo/bpffs/tamper
cat: /run/shirudo/bpffs/tamper: Permission denied

Step 4: write and sign an upatch

The test VM's bundle generated an ML-DSA-87 key pair and enrolled its certificate. You sign with that key on the host. Name the key directory first. It sits outside the checkout and only your account can open it[1]:

operator$ KEYS=/tmp/shirudo-test-vm-private-$(id -u)/operator-keys/keys

The example upatch attaches to the kernel function do_nanosleep() and does nothing, which makes it a safe first load[1]:

// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>

char _license[] SEC("license") = "Dual BSD/GPL";

SEC("fentry/do_nanosleep")
int BPF_PROG(shirudo_test_basic)
{
        return 0;
}

shirudo build compiles the C code with clang against vendor/linux/vmlinux.h, turns the object into a loader that performs the load on the target, and signs the loader and its data with your key. The upatch takes the name basic from the file name[1]:

operator$ shirudo build testing/fixtures/basic.bpf.c --keys-dir "$KEYS" --vmlinux vendor/linux/vmlinux.h -o basic.upatch

shirudo upatch info prints the name, type, payload type, version, payload SHA-256 and file size, together with the loader and signature details[1].

operator$ shirudo upatch info basic.upatch
File:                  basic.upatch
Name:                  basic
Type:                  LOAD
Payload type:          bpf
Version:               1
Payload sha256:        3f8fda317513fb5bc952bf52c1b6ff05ed48ca64023b41aaaeeaffc19a99d176
File size:             8605 bytes

Keep the payload digest in a shell variable. shirudo upatch info --json with jq prints it, and the later steps need it[1]:

operator$ PAYLOAD=$(shirudo upatch info --json basic.upatch | jq -r .payload_sha256)

The unload directive is signed too. shirudo build --unload with --payload-sha256 builds a directive for that payload. If a different payload is loaded under the same name, the target refuses it with payload_mismatch[1]:

operator$ shirudo build --unload basic --payload-sha256 "$PAYLOAD" --keys-dir "$KEYS" -o basic.unload.upatch

Step 5: load on the target and check

shirudo upatch load makes the kernel check the loader's signature against the .bpf keyring before it runs the loader. The loader then creates the programs in the kernel, shirudo attaches them and pins the link, and the load is recorded in the measurement register and the eventlog[1]:

target# shirudo upatch load basic.upatch
upatch load: signed loader accepted, keyring 1025034781, 124 instructions
upatch load: loader ran, 0 maps and 1 programs
upatch load: program 0 (raw_tracepoint) pinned at /run/shirudo/bpffs/upatches/basic/link
upatch load: basic loaded, 1 programs, keyring 1025034781
upatch load: basic measured, register 2705e01ee2dbc5b81b7ba45749aa06251a32b535142788ef24a40be985b78bf7

shirudo upatch list shows the archived upatches and whether each is loaded. The target keeps a copy and loads it again at the next boot[1]:

target# shirudo upatch list
Archived upatches (/var/lib/shirudo/upatches):
  NAME                      LOADED  TYPE    KIND  PAYLOAD
  basic                     yes     load    bpf   3f8fda317513fb5b..

Step 6: prove the target's state with the TPM

The status report is what the target says about itself. Evidence signed by its TPM lets the operator check the same facts from the other side, using only the evidence, the certificates and the artifacts[1]. Start by creating a fresh nonce on the host:

operator$ NONCE=$(openssl rand -hex 32)

Then ask the target for evidence that answers this nonce. It contains a TPM quote over the PCRs and a certification of the register, both signed by the TPM's attestation key, plus this boot's eventlog[1]:

target# shirudo attest --nonce=<nonce> --output=/mnt/shirudo-out/ev.json

On the host, shirudo attest predict computes the register value the shipped certificates and artifacts should produce. shirudo attest verify then checks the signatures and the nonce, replays the eventlog and compares the result with that prediction. Neither command opens a TPM[1].

operator$ shirudo attest predict --cert="$KEYS/cert.der" --cert="$OWN" --event=load:basic="$PAYLOAD"
operator$ shirudo attest verify --evidence="$EV" --nonce="$NONCE" --ak-name="$(jq -r .ak.name "$EV")" --expect-chain=<register-after-events>

The command exits with 0 on verdict: ok and with 1 on verdict: fail. The NOTE lines name checks that the quickstart leaves out, such as an approved config image[1].

Step 7: unload

The unload runs the signed directive through the same signature check. The register moves forward to a new value instead of returning to its boot value, because it starts over only at the next TPM reset[1]:

target# shirudo upatch unload basic.unload.upatch
upatch unload: signed loader accepted, keyring 1025034781, 165 instructions
upatch unload: basic carries the directive's payload
upatch unload: basic measured, register 0100998a4c3a96bd8d36356fd3d3d4fca9217ee926166907272bf8dfa33b9495
upatch unload: basic detached and unpinned

Installing on real hosts

Real hosts take two packages. The operator host gets shirudo-operator, which contains /usr/bin/shirudo, the helper shirudo-build and the image generators, and no systemd unit[2]. A target gets shirudo-target, which carries no key or configuration file and contains a static /usr/bin/shirudo, the dracut module and the shirudo.service and shirudo-initrd.service units[2]. Both packages install /usr/bin/shirudo, so they conflict and one host holds only one of them[2].

From a checkout, the .deb packages are built with the command below. They land in the checkout root, and binrpm-pkg builds the .rpm equivalents[2]:

$ make -C packaging bindeb-pkg

To build the operator package for another distribution, build only that package on a host of that distribution, because it links the build host's shared libraries. Then run shirudo build --help, which prints the path of the helper it found[2]:

$ make -C packaging bindeb-pkg PKG_ROLES=operator
# apt install ./shirudo-operator_<version>_<arch>.deb
operator$ shirudo build --help
...
SHIRUDO_BUILD, /usr/libexec/shirudo/shirudo-build, then shirudo-build on PATH.
...

Installing the target package enables shirudo.service and five timers for the next boot, and starts none of them[2]:

# apt install ./shirudo-target_<version>_<arch>.deb
...
shirudo: shirudo.service enabled; it runs 'shirudo init' early on the
shirudo: next boot. To enforce now: systemctl start shirudo.service
shirudo: shirudo-map-export.timer enabled for the next boot
shirudo: shirudo-keepalive.timer enabled for the next boot
shirudo: shirudo-xdp-reconcile.timer enabled for the next boot
shirudo: shirudo-bpm-repo-update.timer enabled for the next boot
shirudo: shirudo-bpm-tree-sync.timer enabled for the next boot

On a target, shirudo init --check-only lists each prerequisite of init with its result and changes no enforcement state[2]:

target# shirudo init --check-only

Systems without a package manager can use a tarball. make -C packaging bintar-pkg builds two target tarballs. Unpack one, run its installer as root, and enable the units yourself with systemctl enable[2]:

$ tar -xzf shirudo.tar.gz
# ./shirudo-installer/install.sh
shirudo installer: installed into /

Installing from source uses make install-operator on an operator host and make install-target on a target, with binaries under /usr/local by default. The target build first builds OpenSSL, libcurl and tpm2-tss from source[2]:

# make install-operator
# make install-target

Check the install with shirudo version, which prints the release and the version ID that upatch load --expect-version-id compares against[2]:

$ shirudo version

When a target starts enforcing

Installing shirudo-target protects nothing by itself. A target enforces after it boots through the shirudo initrd with a kernel that has the BPF LSM active and the bpf.keyring_unsealed=1 and dm_verity.keyring_unsealed=1 settings, so that init can enroll the certificates and seal the keyrings[2]. It also needs a TPM 2.0 exposed as /dev/tpmrm0, and the operator's certificate at /var/lib/shirudo/keys/cert.der[2].

After the reboot, shirudo status on the target should show Status: ok with every condition OK, and shirudo status --show-full should show Bound in: initrd[2].

Common problems

  • **Permission denied from shirudo status**: the command ran from a copy outside the runtime image. On a target, use /run/shirudo/runtime/usr/bin/shirudo[1].
  • **A payload_mismatch error on unload**: the payload digest in the directive does not match the loaded payload. Rebuild the directive with the digest of the payload that is loaded[1].
  • Installed but not protected: installing the package is not enough. The target must boot through the shirudo initrd, and shirudo init --check-only lists what is still missing[2].

Next step

The official guides cover writing your own upatch and publishing one through an OCI registry, and the deployment checklist lists every step of a rollout[2].

Sources

  1. 1
    Quickstartshirudo-dev on GitHub
  2. 2
    Install shirudoshirudo-dev on GitHub

Cite this page: Shirudo quickstart: installing it and loading your first live patch on Linux. TellWorld, https://www.tellworld.net/practice/practice-shirudo-quickstart. Updated 2026-11-24

Related news

View all