shirudo upatch load#
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#
With
--expect-version-id,loadcompares the value with this binary’sSHIRUDO_VERSION_IDand refuses on a difference (version_mismatch).It copies the file to a private staging file and reads it once. Every later step uses that copy.
Pre-flight, unless
--no-precheck: the kernel has the signed-loader interface (kernel_abi_unsupported),initfroze a trust anchor this boot (keyring_missing), the.bpfkeyring is the frozen one and the LSM link is pinned (tampered), and with--expect-chainthe register holds that value (tampered, messagechain_drift).It refuses when the eventlog would exceed
eventlog.max_bytes(eventlog_full).It takes the register lock, an
flockon 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, whichstatusreports underUpatchesMeasured. 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.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_verifyphase).It loads the loader with
BPF_PROG_LOADagainst the.bpfkeyring. The kernel checks the signature before the verifier runs (signed_loader_loadphase).It runs the loader, which loads the payload programs and maps (
payload_loadphase).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’ssecurity.bpf.shirudo.payloadextended attribute (link_createphase).It copies the artifact to
/var/lib/shirudo/upatches/<name>.upatch, the archive thatinitrestores at boot (persistphase).It extends the register with the
upatch_loadevent for the name and payload digest, and appends the event to the eventlog (tpm_extendphase).
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 |
|---|---|---|---|
|
|
none |
Refuse unless the register holds this value before the load, for
example |
|
|
none |
Refuse unless this binary’s |
|
none |
off |
Skip the |
|
none |
off |
Skip the pre-flight checks, |
|
|
none |
Write the JSON report to |
Report#
--report writes one JSON object, also when the command fails:
Key |
Value |
|---|---|
|
|
|
|
|
|
|
|
|
the error number and its name, or |
|
the failure category, |
|
a short description |
|
the kernel verifier’s log, when it gave one |
|
the loader’s return value |
|
|
|
|
|
|
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
|
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/eventlogandeventlog.max_bytesWrites
/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".