Overhead#
What shirudo uses on a target: files, memory, CPU time, TPM commands, network traffic and disk writes. The base platform is what every target pays with no upatch loaded. Each upatch adds a fixed cost on top of it, and the cost of its own programs and maps, which depends on how the upatch is written.
Sizes and limits come from the code and the build. Times and memory peaks come from one test VM, described under Measurement setup. They show orders of magnitude for that system. Other CPUs, kernels, disks and TPMs give other numbers, and every command that talks to the TPM takes as long as the TPM takes to answer.
Measurement setup#
Item |
Value |
|---|---|
shirudo |
Commit |
Host |
AMD Ryzen 9 3950X, Ubuntu 24.04, QEMU 8.2.2 with KVM. |
Guest |
A test VM: |
Kernel |
The pinned bpf-next artifact built from |
TPM |
swtpm 0.7.3, a software TPM, through |
Method |
Peak RSS and wall time per command from |
Base platform#
Files and images#
Item |
Size |
Notes |
|---|---|---|
Target binary |
17.0 MiB as built, 12.7 MiB without symbols, 3.8 MiB compressed
with |
Static PIE. It contains OpenSSL, libcurl, tpm2-tss, libelf, zlib,
zstd, LuaJIT, libbpf and the guard BPF objects. |
Binary in the initrd |
14.0 MiB before compression |
dracut removes the debug sections. The |
Runtime image |
15 MiB by default, plus a 128 KiB hash tree |
|
Config image |
1 MiB by default, plus a 16 KiB hash tree |
|
|
22 KiB after the first boot |
Certificates, a 1.9 KiB eventlog and the config activation state. |
|
|
Holds the mount points of the images and the private bpffs. It held no file data in the test VM. |
Eventlog growth |
1.9 KiB per boot, 350 B per upatch load or unload |
shirudo never shortens the eventlog. See the size limits in Eventlog events. |
Figure 1. The default runtime image of 15 MiB around the stripped x86-64 target binary.#
Boot#
shirudo-initrd.service ran for 1.17 s in the test VM, nearly all of
it in the three steps of Figure 2: mapping, reading and verifying the
runtime and config images and sealing the keyrings, loading and
attaching the guards, and defining and binding the measurement register
with its extension of PCR 9.
Figure 2. Steps of init in the initrd.#
init reads every image completely through its dm-verity mapping
before it uses it, so each boot reads the whole runtime image and the
active config image from disk. The second init, from the root file
system, took 120 ms and sends no register extension.
Memory#
No shirudo process runs between commands. Every command calls
mlockall(MCL_CURRENT | MCL_FUTURE) first, so all of its memory,
including the pages of the binary it maps, stays resident and locked
until it exits. The units set LimitMEMLOCK=infinity for this, see
systemd units and timers.
Command |
Peak RSS |
Wall time |
|---|---|---|
|
12.9 MiB |
1.3 ms |
|
20.5 MiB |
72 ms |
|
20.5 MiB |
72 ms |
|
20.5 MiB |
48 ms |
|
20.5 MiB |
48 to 62 ms |
|
21.1 MiB |
120 ms |
|
29.7 MiB |
0.50 to 0.51 s |
|
20.5 MiB |
0.46 s |
Larger inputs raise the peak. These limits bound it:
Input |
Limit |
|---|---|
upatch file |
16 MiB. |
Registry responses read into memory |
16 MiB: manifests, the repository index and its signature, tree publications and the upatch artifacts they name. |
Package archive |
256 MiB, written to disk, and 256 MiB unpacked. |
JSON documents, the repository index and the eventlog among them |
8 MiB, read whole. |
Lua decoder |
32 MiB of heap, which holds the copy of the map it decodes, and 1,000,000 instructions per run. |
OTLP request |
|
Map reads |
No limit. An export reads every map of every loaded upatch whole, one map at a time, so its memory follows the size of the largest map. |
In the kernel, the guards stay loaded until shutdown:
Object |
Size |
|---|---|
Programs |
48 BPF LSM programs on 39 hooks: 50,952 B of translated instructions, 28,281 B JIT-compiled, 196 KiB charged as locked memory. The kernel adds a BPF trampoline for each hook. |
Maps |
Nine: small arrays for the identity record, the tamper counters and internal records, a hash map for 128 dm-verity devices that the kernel allocates in full when it creates it, three task-storage maps and one inode-storage map. |
Task storage |
About 0.5 KiB for each task that has executed a program or written a file, computed from the kernel’s local-storage layout: two storage elements and the per-task storage header. The kernel frees it when the task exits. |
Inode storage |
One element for each directory under shirudo’s seal label while its inode is cached. |
Guard hooks#
The kernel runs the guards on every operation their hooks cover, whether or not the operation touches shirudo’s state. Enforcement in the kernel describes what each hook checks. The BPF time one operation cost in the test VM, summed over every guard program it ran. The BPF trampoline’s own work on each call, RCU and recursion handling among it, comes on top and is not counted here:
Operation |
Hooks |
BPF time |
|---|---|---|
|
|
3.2 µs |
Open, read and close an existing file |
|
0.15 µs |
Create, write, rename and unlink a file |
|
0.65 µs |
|
|
37 ns |
|
|
0.15 µs |
|
|
0.28 µs |
In the loops behind these numbers, the guards took 6.4 ms of 845 ms for
2,000 forks and execs, 6.5 ms of 133 ms for 10,000 file cycles on
ext4 and tmpfs, and 2.9 ms of 37 ms for 20,000 opens. Other hooks
with guards run on frequent operations as well: inode_setattr,
inode_setxattr, inode_removexattr, ptrace_access_check,
task_prctl and key_permission. On an otherwise idle target the
guards ran 56,452 times per minute for a total of 2.8 ms, mostly for
shirudo’s own timer runs.
Timers#
The four timers start a new shirudo process each time. Every run of
a target command other than init and version checks that all 48
guards are attached, loading the kernel’s BTF to do so, and creates the
TPM attestation key, see TPM commands.
Unit |
Interval |
CPU per run |
Runs per minute |
|---|---|---|---|
|
60 s after the previous run ends |
17.9 ms before it quoted its body |
1 |
|
5 s after the previous run ends |
14.5 ms with no upatch loaded |
11.9 |
|
60 s after the previous run ends |
32.3 ms |
1 |
|
60 s after the previous run starts |
9.8 ms |
1 |
Together they used 0.43 s of CPU time per minute in the test VM, 0.71 % of one vCPU, in about 27 process starts, when the keepalive ran every 5 seconds and sent no quote. Figure 3 shows that measurement, with the keepalive and map export timers taking most of it. The keepalive now runs once a minute, which leaves it one run of the 11.8 the figure counts, plus the quote below, which the measurement does not include.
Figure 3. CPU time of the four timers per minute, with no upatch loaded.#
To read the CPU time of a timer’s last run on your own target:
target# systemctl show shirudo-keepalive.service -p CPUUsageNSec
CPUUsageNSec=19073000
TPM commands#
Operation |
TPM work |
|---|---|
Every target command except |
Creates the ECC P-256 attestation key, reads the clock and the config PCR. |
|
Adds reads of the measurement register’s NV index. |
|
Adds a second attestation key, created with
|
|
One register extension: about 20 commands, among them a new
RSA-3072 primary key (the NV writer key), a new attestation key, a
signature, a policy session and |
|
Two RSA-3072 primary keys and two attestation keys,
|
|
Reads only. |
|
A quote over 14 PCRs by default, |
With the default timers an idle target creates its attestation key about
17 times per minute, twice in each keepalive. The register is an orderly NV index, so an
extension updates it in TPM RAM rather than writing NV memory each time.
init defines the index again at every boot. In the test VM, with
swtpm, the extension took 0.44 s of a 0.50 s load, binding the register
at boot 0.56 s and attest 0.46 s.
TPM 2.0 and how shirudo uses it explains the objects involved.
The keepalive’s TPM2_CreatePrimary derives the P-256 key from the
endorsement seed at every run. A firmware or discrete TPM can take
hundreds of milliseconds for it, which the keepalive spends once a
minute. Keeping the key under a persistent handle would avoid it, at the
price of TPM state shirudo does not keep today;
Design decisions records the choice.
Network#
With no repository, tree or export endpoint configured, shirudo sends nothing.
Source |
Traffic |
|---|---|
Keepalive |
One OTLP/HTTP request per run when |
Map export |
One OTLP/HTTP request per map of every loaded upatch per run when
|
|
Every minute, for every configured repository: the index manifest, the whole index and its signature, with no conditional request. A registry that wants a token adds a refused request and a token request before each of them. |
|
Nothing unless the cached index lists a newer version of an installed package. |
|
Every minute with a tree configured: its manifest, payload and signature. |
Each request opens a new connection with its own TLS 1.3 handshake. Monitor and export telemetry and Deliver packages describe the settings.
Disk writes#
bpm upgraderewritesbpm/state.jsonwithfsync()every minute, also when nothing changed.bpm repo updaterewrites the cached index of every repository.bpm tree syncrewritesbpm/upatch-tree/state.jsonwithfsync()twice every minute with a tree configured, also when nothing changed, and appends a line of about 220 bytes tobpm/upatch-tree/outcomeswithfsync()for every new tree operation. It reads that file once at the start of a sync.shirudo appends every eventlog record with
fsync().Map export creates an empty lock file for every map it exports in
/var/lib/shirudo/locks, named by the kernel’s map ID. Map IDs change at every load and every boot, and the files stay.systemd logs about 5 KiB per minute for the starts and stops of the four timers’ services.
upatches#
A upatch costs the target in two ways: a fixed cost that shirudo adds for every upatch, whatever it does, and the cost of its own programs and maps. shirudo limits neither how many programs and maps a upatch brings nor how often the kernel runs them. The verifier bounds a single program run, not the work a upatch does on a hook that fires for every open or exec, nor the size of its maps. A badly written upatch can slow the target down or use much of its memory.
Per-upatch baseline#
Item |
Cost |
|---|---|
Signed file |
8.4 KiB for a upatch with one small program, 4,627 B of it the ML-DSA-87 signature. An unload directive is 9.1 KiB. |
Copies on disk |
One in |
Eventlog |
About 330 B plus the length of its name per load and per unload, and about 100 B plus the name in the init record of every boot that restores it. |
TPM |
One register extension per load and per unload. Restoring loaded upatches at boot adds no extension. |
Load |
29.7 MiB peak RSS in the loading process. The signed loader runs once and is freed. |
Kernel |
A pin for every link and map in the private bpffs. |
Timers |
Map export reads every map of the upatch every 5 s and, with an
endpoint configured, sends one request per map. |
Programs and maps of a upatch#
Its programs run on every event of their hooks. Their time adds to the guards’ time on the same operation.
Array maps and hash maps created without
BPF_F_NO_PREALLOCtake their full size when the loader creates them. An arena takes pages as the programs write them. Local storage grows with the tasks, sockets or inodes it is attached to.The verifier’s time at load grows with the size and branches of the programs. It runs in the kernel, in the loading process.
Serializer programs and Lua decoders run at every export, every 5 s. The Lua limits above bound a decoder.
Maps, arenas and serializers explains how a upatch keeps records in an arena.
kernel-obs example#
The observability package in upatches/kernel-obs is one example,
measured in the same test VM:
Item |
Value |
|---|---|
Signed file |
819 KiB. |
Programs |
35: 24 on LSM hooks, 2 on cgroup socket buffers, 8 serializers and 1 test program. 348,248 B of translated instructions, 184,460 B JIT-compiled. |
Maps |
18. Its records live in one arena of up to 4,096 pages, 16 MiB with 4 KiB pages, which it fills as it records. |
Load |
1.97 to 2.19 s, 1.42 to 1.47 s of it CPU time in the kernel. 31.0 MiB peak RSS. |
Unload |
0.50 s. |
Added hook time |
4.1 µs per |
Export |
72 ms and 20.4 MiB per |
Figure 4 sets the hook time kernel-obs adds beside that of the guards.
On fork() and execve() it more than doubles the BPF time: it runs
a program of its own on each hook they pass, task_alloc,
bprm_check_security, file_open, mmap_file and
file_mprotect.
Figure 4. BPF time per operation, the guards and kernel-obs on top of them.#