shirudo upatch load#

Reference · Operators

Load a signed .upatch into the target kernel: verify the signature, run the loader, pin the resulting links and extend this boot’s measurement register.

Runs on: target, as root with the runtime binary. Requires: init completed this boot. Changes measured state: yes, one upatch_load event.

Usage#

shirudo upatch load [--expect-chain=<register>] [--expect-version-id=<version-id>]
                    [--no-precheck] [--no-version-check] [--report=<path>]
                    <file>

Every option with a value takes it after = or as the next argument. --help anywhere on the line prints the help. Progress and error messages go to standard error, so with --report=- standard output carries only the report.

Description#

  1. With --expect-version-id, load compares the value with this binary’s SHIRUDO_VERSION_ID and refuses on a difference (version_mismatch).

  2. It copies the file to a private staging file and reads it once. Every later step uses that copy.

  3. Pre-flight, unless --no-precheck: the kernel has the signed-loader interface (kernel_abi_unsupported), init froze a trust anchor this boot (keyring_missing), the .bpf keyring is the frozen one and the LSM link is pinned (tampered), and with --expect-chain the register holds that value (tampered, message chain_drift).

  4. It refuses when the eventlog would exceed eventlog.max_bytes (eventlog_full).

  5. It takes the register lock, an flock on the root of the private bpffs, /run/shirudo/bpffs, which it holds to the end, and undoes the pins and archives this boot’s records do not cover: those of a load stopped before its extend, of an unload stopped after it, and an archive brought back after its unload, which status reports under UpatchesMeasured. It takes only the records the register vouches for, which fold to the value the TPM reports, and refuses (tampered) when they do not, and (tpm_error) when it cannot read this boot’s records or cannot undo one of them. A upatch of the same name that is loaded, BPF or Java, is refused (already_loaded), a Java one also when its jar is missing or another, until its signed directive unloads it.

  6. It parses the artifact: a LOAD artifact, a safe and signed name, a payload digest that matches the payload, valid attach metadata (parser_rejected). For a uprobe it checks each target binary against its recorded build ID (target_verify phase).

  7. It loads the loader with BPF_PROG_LOAD against the .bpf keyring. The kernel checks the signature before the verifier runs (signed_loader_load phase).

  8. It runs the loader, which loads the payload programs and maps (payload_load phase).

  9. It attaches every program and pins the links under /run/shirudo/bpffs/upatches/<name>/, where a dot in the name becomes ~d, with the payload digest in the directory’s security.bpf.shirudo.payload extended attribute (link_create phase).

  10. It copies the artifact to /var/lib/shirudo/upatches/<name>.upatch, the archive that init restores at boot (persist phase).

  11. It extends the register with the upatch_load event for the name and payload digest, and appends the event to the eventlog (tpm_extend phase).

A Java upatch (see Java agent upatches) takes these steps in place of loading, running and attaching a loader: load checks its signature over the signed data against the certificates of the runtime that the .bpf keyring holds (java_verify phase, signature_rejected), and its signed name, type and payload digest (parser_rejected), then writes its jar to /run/shirudo-java/<name>.jar (java_install phase). It archives and extends as above, with the java_load event, then rewrites /run/environment.d/shirudo.conf. A failure to write that file is a warning: the upatch is loaded and measured.

When the copy to the archive or the register extend fails, load removes the pins or the jar and the archive again, so that no upatch runs unmeasured. When the extend succeeded and only the eventlog append failed, the upatch stays loaded and the report says tpm_error. A load stopped between its pins and its extend leaves the pins: status reports them as tampered and the next load or unload undoes them before it acts.

--no-precheck skips step 3 only. The kernel signature check and the LSM still apply. bpm passes it when it loads the upatches of a package.

For XDP, the signed device-class mask selects interfaces present in the initial network namespace at load time, with one endpoint per veth pair. Each program can produce several link_<n> pins. Native XDP is required: a device without it is logged and skipped. A device that has native XDP but refuses it in its current settings is an error. A upatch with no attachable device yet still loads, and shirudo upatch reconcile attaches it when one appears. A device that is occupied or does not report multi-buffer XDP, and any other error, undoes all links the load created. Attach kinds defines the classes and limits.

Options#

Option

Argument

Default

Description

--expect-chain

<register>, 64 hex characters

none

Refuse unless the register holds this value before the load, for example register_at_boot from shirudo attest predict.

--expect-version-id

<version-id>

none

Refuse unless this binary’s SHIRUDO_VERSION_ID equals the value (string comparison).

--no-version-check

none

off

Skip the --expect-version-id comparison.

--no-precheck

none

off

Skip the pre-flight checks, --expect-chain included, with a warning.

--report

<path> or -

none

Write the JSON report to <path> (mode 0644), or to standard output with -. A path in sealed state is refused.

Report#

--report writes one JSON object, also when the command fails:

Key

Value

schema

1

result

ok or failed

op

upatch_load or upatch_unload

phase

pre_flight, parse, target_verify, signed_loader_load, payload_load, link_create, pin, persist, tpm_extend or done

errno, errno_name

the error number and its name, or null

category

the failure category, ok on success

message

a short description

verifier_log

the kernel verifier’s log, when it gave one

loader_return

the loader’s return value

upatch

path, name and payload_sha256 of the artifact

kernel

release, the running kernel

tpm

nv_index and chain_after, the register after the event, on success, null otherwise

Exit status and failure categories#

Status

Meaning

0

The upatch is loaded and measured.

1

Refused or failed. The report and the message name the category.

2

A usage error: an unknown option or one given twice, a value missing or empty, a second file, no file, or an --expect-chain that is not 64 hexadecimal characters. Also attach_target_missing for missing probe targets.

load reports these categories: version_mismatch, kernel_abi_unsupported, keyring_missing, tampered, eventlog_full, already_loaded, parser_rejected, signature_rejected, signature_unsupported, lsm_denied, verifier_rejected, attach_target_missing, binary_mismatch, attach_scope_mismatch, xdp_multibuf_unsupported, xdp_driver_refused, xdp_device_occupied, tpm_error and unknown. Failure categories and exit status gives the cause and the action for each. Handle tampered as an incident (Respond to a tampered target).

Files and environment#

  • Reads the artifact, /var/lib/shirudo/eventlog and eventlog.max_bytes

  • Writes /run/shirudo/bpffs/upatches/<name>/, /var/lib/shirudo/upatches/<name>.upatch, the eventlog and the register

Examples#

Load an artifact and print the report:

target# shirudo upatch load --report=- shirudo-test-basic.upatch
upatch load: signed loader accepted, keyring 272801410, 124 instructions
upatch load: loader ran, 0 maps and 1 programs
upatch load: program 0 (raw_tracepoint) pinned at /run/shirudo/bpffs/upatches/shirudo-test-basic/link
upatch load: shirudo-test-basic loaded, 1 programs, keyring 272801410
upatch load: shirudo-test-basic measured, register 7f63313a31ac8ddd3a6a16fce2038322c9c782d5787155d2dc18dfa582dff548

Load only when the register holds the value you predicted:

target# shirudo upatch load --expect-chain=<register> fix.upatch

<register> is the register_at_boot or register_after_events line of shirudo attest predict for the state you expect. When the register differs, load refuses before it touches the kernel:

upatch load: pre-flight refused (category: tampered, message: chain_drift): live register c50b22ac27c5bb6a90ee5ff9b440fbbd5bb60b84a2aa7b395daec3f330886fcd is not the expected one; run status and pass the refreshed value

The message suggests repeating the command with the live value. Do not. A register that differs from your prediction is an incident (Respond to a tampered target).

A refusal for an artifact signed by a key the target does not trust:

target# shirudo upatch load --report=- shirudo-test-foreign.upatch
BPF_PROG_LOAD (signed loader): Required key not available
loader verifier log:
signature verification failed: -126

The report of that refusal names "phase":"signed_loader_load", "errno_name":"ENOKEY" and "category":"keyring_missing".