Interoperability#
On a target where shirudo enforces, its LSM programs refuse operations
that other software on the host may rely on. This page lists them by
area. Each entry names the mechanism, what the other software sees, the
tamper counter that moves, and what to do. The refusals start when
init attaches the guards in the initrd and last until the next boot.
Enforcement in the kernel describes every hook, and
Tamper counters every counter.
lsm/bpf runs before the kernel checks capabilities, so unprivileged
processes move counters too. Software that probes for BPF support at
startup, systemd among it, moves several counters on every target, which
is why
Read shirudo status asks you to learn the baseline of your hosts.
Other BPF users#
- Mechanism:
After
init, a program load from userspace passeslsm/bpfonly as aBPF_PROG_TYPE_SYSCALLloader with a signature, andlsm/bpf_prog_loadonly when the kernel verified that signature against the.bpfkeyringinitfroze. Map creation, map writes, test runs, attaching and pinning are reserved to tasks with runtime authority, which only an exec of a file on the runtime image grants.lsm/bpf_maprefuses every map descriptor to other tasks. Everybpf()command that shirudo has not classified is refused.- Still allowed:
BPF_PROG_GET_FD_BY_ID,BPF_BTF_GET_FD_BY_ID,BPF_OBJ_GET_INFO_BY_FD, the*_GET_NEXT_IDcommands,BPF_PROG_QUERY,BPF_TASK_FD_QUERY, and lookups through a map descriptor a process already holds. Classic BPF, as seccomp filters andSO_ATTACH_FILTERin libpcap use it, does not go throughbpf()and is not affected.- What to do:
Plan a target as a host where only signed upatches run BPF. Keep BPF-based agents, network plugins and tracing tools off enforcing targets, or ship what they do as upatches (upatches). Run one-off investigations with bcc or bpftrace on a host that does not enforce.
Each refused call fails with EACCES (Permission denied). The
program load rows apply to every task, the others to tasks without
runtime authority:
Call |
Counter |
|---|---|
|
|
|
|
|
|
|
|
|
|
A writable map descriptor |
|
|
|
|
|
|
|
|
|
The |
|
Every other command, among them |
|
What common software sees:
Software |
Effect |
|---|---|
Loaders built on libbpf |
A recent libbpf first tries to create a BPF token from
|
|
|
|
Counting and sampling without BPF work. Options that load BPF
programs, such as |
bcc, bpftrace |
Fail at their first map creation or program load. Nothing they compile runs. |
Cilium and other BPF datapaths |
The agent cannot create its maps or load its programs, so the datapath does not come up. |
Tetragon, Falco’s eBPF drivers |
Cannot load their programs. Falco’s kernel module driver is a kernel module, which shirudo does not gate, see Module loading and kernel live patching. |
XDP and tc programs from |
The program load is refused. |
systemd |
Starts units without its BPF-based settings, see the next section. |
systemd’s BPF-based settings#
- Mechanism:
systemd probes whether BPF works when a manager starts: the system manager at boot and at every re-execution, including the switch from the initrd to the root file system, and every user manager. The probes load programs, which
inithas already closed off. systemd then treats the features as unsupported for the lifetime of that manager and starts units without them. This section describes systemd 262.- Symptom:
The units start. Their BPF-based restrictions do not hold. Each refused probe moves a counter:
LoadNotLoaderfor the program loads,MapCreatefor the mapRestrictFileSystems=creates, andBpfCommandfor other commands, such as libbpf’s token attempt.- What to do:
Do not rely on these settings on a target. Enforce address and interface policy with nftables, or with a signed upatch of the
cgroup_skbornetfilterattach kind (Attach kinds). No upatch attach kind covers cgroup device programs.
Setting |
On an enforcing target |
|---|---|
|
Not applied. For the first unit that uses them, the manager logs
|
|
Not applied. On cgroup v2 the device controller exists only as a
|
|
Not applied. |
|
Not applied. The manager logs the failed probe at debug level only. |
|
Not applied. At startup the system manager logs
|
Seccomp filters and shirudo’s own commands#
- Mechanism:
The seal grants runtime authority at an exec of a file on the runtime image only when the task is not traced and has no seccomp filter, so that neither a debugger nor a filter installed beforehand controls the new process.
lsm.s/bprm_check_securityrefuses such an exec. A seccomp filter passes to every child and survives exec.- Symptom:
Running the runtime
shirudofails withEACCES(Permission denied). No counter moves.- Affected:
systemd unit settings that install a seccomp filter, among them
SystemCallFilter=,SystemCallArchitectures=,SystemCallLog=,RestrictAddressFamilies=,RestrictNamespaces=,RestrictRealtime=,RestrictSUIDSGID=,LockPersonality=,MemoryDenyWriteExecute=,PrivateDevices=,ProtectClock=,ProtectHostname=yes,ProtectKernelTunables=,ProtectKernelModules=andProtectKernelLogs=, on a unit that runs shirudo or on any unit whose processes start it. A container with a seccomp profile. systemd’sRestrictFileSystemAccess=: with it enabled, systemd 262 installs a seccomp filter in PID 1, which every later process on the host inherits, so no runtime command can run at all. This last case is a reading of the systemd 262 source and is not tested.- What to do:
Add none of these settings to shirudo’s units or to their drop-ins (systemd units and timers). Do not enable
RestrictFileSystemAccess=on a target. Run shirudo commands from a root shell or a unit without a seccomp filter.
BPF loaded before init#
- Mechanism:
Before
initattacheslsm/bpfin the initrd, any process can load and attach BPF, and what it attaches stays (R7 in Threat model). It stays as long as something holds it: a pin, an open descriptor, or an attachment that needs neither, such asBPF_PROG_ATTACHto a cgroup. In-kernel loaders, such as thebpf_preloadmodule, pass the gates at any time (R18).- Symptom:
After
init, the owner of such a program can no longer detach it withbpf()(BpfCommand), write or delete map elements (MapWrite,BpfCommand), or reopen its maps and links by pin or by id (ObjGet). It can still look up elements through a map descriptor it holds, close descriptors, and remove its pins from any bpffs other than shirudo’s, which releases the object when nothing else holds it. systemd’s manager re-executes at the switch to the root file system and sets up its BPF features again afterinit, so the previous section applies to them.- What to do:
Keep the initrd free of BPF loaders you do not trust. The initrd is part of the trusted computing base, and its PCR 9 and PCR 11 measurements are what a verifier pins (Attest targets).
systemd-keyring-setup#
- Mechanism:
systemd 263 adds
systemd-keyring-setup. It runs in the initrd beforeshirudo-initrd.serviceand again on the root file system, enrolls certificates of its own, and seals.bpf,.dm-verityand.fs-veritywith a chain restriction, also when it has no certificate to enroll.initenrolls the config certificate and the BPF signers itself and seals both keyrings against every further key. It refuses a keyring that another task sealed or filled first, and shirudo does not adopt the keyrings that tool set up.- Symptom:
initfails in the initrd. It stops at the.dm-veritykeyring with one ofinitrd boot keys: add config verification certificate: <error>,initrd boot keys: check dm-verity verification keys: Key was rejected by serviceor, when the tool enrolled nothing,initrd boot keys: dm-verity keyring sealed empty at boot; boot with dm_verity.keyring_unsealed=1: Required key not available, which names the boot parameter even when it is set.init: BPF keyring initialization failedfollows. The boot then continues without enforcement (U11). Ifinitran first, the tool’s run on the root file system is refused bylsm/key_permissionand movesKeyringWrite.- What to do:
Keep
systemd-keyring-setupoff targets: do not install it in the initrd or on the root file system, or mask its unit in both.
kexec and kdump#
- Mechanism:
lsm/kernel_load_dataandlsm/kernel_read_filerefuse every kexec image and kexec initramfs to every task, shirudo included, throughkexec_load(2)andkexec_file_load(2)alike. A crash kernel goes through the same checks. A kexec would boot a kernel of the caller’s choosing while the TPM keeps this boot’s register and PCRs.- Symptom:
The load fails with
EPERM(Operation not permitted) and movesKexec. The kdump service cannot load its crash kernel, andsystemctl kexecfails.- What to do:
Plan targets without kdump. Use crash capture that needs no second kernel, such as pstore, which shirudo does not hook. Reboot through the firmware instead of kexec.
Module loading and kernel live patching#
- Mechanism:
shirudo loads signed modules only.
lsm/kernel_load_dataandlsm/kernel_read_filelet every load other than a kexec image or initramfs through, and the kernel checks the module’s signature. When the signature is missing or the kernel cannot verify it, and the kernel does not refuse the module itself, it asks lockdown, andlsm/locked_downrefuses it frominiton (A4 in Threat model). A livepatch module, as kpatch or the kernel’sklp-buildproduce, is a kernel module like any other.- Symptom:
init_module(2)andfinit_module(2)of an unsigned module fail withEPERM(modprobeprintsOperation not permitted), and the integrity counterModuleSignaturecounts it.modprobe --force, which strips the version checks, makes a signed module count as unsigned.- What to do:
Build the kernel with
CONFIG_MODULE_SIG, as Hardening checklist lists and the pre-flight checkmodule_signaturesrequires, and sign every module the target loads, livepatch modules included, with a key the kernel trusts. A signed module runs as kernel code outside every shirudo check. Unloading a module that a kprobe upatch targets leaves the upatch loaded and measured but without effect, a reading of the kernel source (R21). shirudo’s tests do not cover a livepatch and a upatch on the same function.
Other LSMs#
- Mechanism:
The kernel calls the active LSMs in the order of
lsm=, orCONFIG_LSMwithout it, and stops at the first refusal (BPF LSM). shirudo’s programs pass an earlier refusal on unchanged. The pre-flight checkbpf_lsm_activechecks thatbpfis in the list, not where.- Order:
Either order refuses what any active LSM refuses. The order decides who sees the attempt. With
bpfafter SELinux, AppArmor, Smack or Landlock, an operation one of them refuses never reaches shirudo’s programs and moves no counter. Withbpfbefore them, shirudo’s refusal ends the walk and the other LSM does not see or log the attempt.- Seal labels:
With the kernel project patch, the seal reads a file’s label as the in-kernel LSMs read theirs, without the caller’s read permission, and no other LSM’s
inode_permissionpolicy can hide it. On an upstream kernel the kfunc checks that permission, every LSM that implements the hook takes part, SELinux and Smack among them, and a policy that grants write or unlink but refuses read makes a sealed file without a mark look unlabeled (see the seal in Threat model).- Policies:
shirudo ships no SELinux, AppArmor or Smack policy. A policy that confines shirudo’s processes must allow what they use, among it
bpf(), mounts under/run/shirudo, loop and device-mapper devices, the.bpfand.dm-veritykeyrings, the TPM device and thesecurity.bpf.shirudoextended attributes.- What to do:
Run no other LSM whose policy root can change at runtime. Choose the order by which LSM you want to account for refusals.
Hibernation and suspend#
- Mechanism:
shirudo refuses hibernation from
initon:lsm/locked_downrefuses the kernel’s hibernation check, andlsm/file_openthe write of theHibernateLocationEFI variable from which systemd’s initrd would resume (A9 in Threat model). The behavior of the register across hibernation is not analyzed. Before a suspend, the kernel’s TPM driver sendsTPM2_Shutdown(STATE)to a TPM 2.0 unless the TPM stays powered, and the TPM counts that in its restart count (TPM 2.0 and how shirudo uses it). The config activation record holds the TPM’s reset count, which a resume leaves, so the TPM boot goes on; a command the suspend interrupts sees the restart count move and refuses.- Symptom:
/sys/power/statelists nodisk, andsystemctl hibernatefails as hibernation is not supported. After a resume from suspend, shirudo commands run as before. A config activation that was pending stays pending, and every state-changing command refuses, until the next reboot;shirudo initrun by hand does not end it. The test VM, with suspend support added to its kernel, shows this in thedeep(S3) mode of/sys/power/mem_sleep, on QEMU 8.2’sq35machine with SeaBIOS 1.16.3 and swtpm 0.7.3: SeaBIOS sendsTPM2_Startup(STATE)on resume, and the restart count goes up while the reset count, the PCRs and the register stay.upatch load,upatch unloadandattestrun, andattest verifyaccepts the evidence. With an activation pending,init,upatch load,upatch unloadandattestprintOperation now in progressand exit 1, and the next reboot completes the activation. Firmware that sendsTPM2_Startup(CLEAR)on resume makes it a TPM restart instead, which Back up, recover and decommission a target describes. Thes2idlemode is not tested.- What to do:
Turn hibernation off as Hardening checklist lists, and keep targets from sleeping, for example with
AllowSuspend=noandAllowHibernation=noin/etc/systemd/sleep.conf. After an unplanned resume with an activation pending, reboot; see Back up, recover and decommission a target.
Containers and Kubernetes#
- BPF:
The gates apply in every namespace.
BPF_TOKEN_CREATEis refused (BpfCommand), so a bpffs mounted withdelegate_cmds=and its kin gives a container nothing. A container may mount a bpffs of its own, but nothing can be pinned there (ObjPin).- Device rules:
On cgroup v2, container runtimes and systemd enforce device access with
BPF_PROG_TYPE_CGROUP_DEVICEprograms, and their loads are refused (LoadNotLoader). How a runtime reacts is up to the runtime: test yours on an enforcing target.- Networking:
A network plugin built on BPF cannot run. Use one that does not need BPF.
- Mounts:
The
/run/shirudotmpfs, the private bpffs and the runtime and config image mounts, and their copies in every other mount namespace, cannot be unmounted or remounted one by one, and no task without runtime authority mounts over them. The calls fail withEPERM, whichumount(8)reports asmust be superuser to unmount. They moveBpffsUmountorBpffsMountfor the bpffs and no counter for the others. An unmount of a mount above them in another namespace is refused only when it propagates into the bpffs mount ofinit’s namespace or a mount above it (BpffsUmountAbove). Tearing a namespace down is not affected. R3 in Threat model lists the mount operations the guards do not see.- Pins:
Directories of the private bpffs stay listable. Opening a pin is refused (
ObjGet).- What to do:
Run shirudo commands on the host, not in a container. Inside a container with a seccomp profile they cannot run at all, see Seccomp filters and shirudo’s own commands.
Debuggers, tracing and /proc#
- Mechanism:
The seal marks a task at its exec of a runtime file, and a fork inherits the mark.
lsm/ptrace_access_checkrefuses every ptrace access check against a marked task, both attach and read modes, but counts only attach mode, andlsm/perf_event_allocrefuses a perf event bound to one. An exec of a runtime file by a traced task is refused. The ptrace check runs after the kernel’s own user and capability checks, so only root, or a caller running as the same user, reaches it.- Symptom:
See the table below.
- What to do:
Debug shirudo where it does not enforce, such as the test VM (Run and write tests). A read-mode refusal shows only as
EACCESto the caller, never inSealPtrace.
Action |
Result |
Counter |
|---|---|---|
|
|
|
Starting shirudo under |
The exec fails with |
|
Starting shirudo from a process that shares its root and working
directory with another, made with |
The exec fails with |
|
Reading |
|
|
Reading |
|
None |
Reading |
Succeeds, with the fields that need the check zeroed |
None |
journald receiving a log line from a shirudo command |
journald cannot read |
None |
|
|
|
System-wide |
Not refused |
none |
A task-bound perf event that a process opened before the exec that marks the task is not refused (D9 in Threat model).
XFS dump and restore#
- Mechanism:
lsm/file_ioctlrefusesXFS_IOC_ATTRMULTI_BY_HANDLEon an XFS file system to every task without runtime authority, since XFS changes the attributes a handle names without passing an xattr hook, and a seal label removed that way would unseal the inode.- Symptom:
xfsdumpandxfsrestore, which read and write extended attributes through that ioctl, fail on the attributes withEACCES, andXattrHandlemoves.- Not refused:
Reading and writing attributes through
getfattr,setfattrand the other xattr system calls, which the seal checks as it checks every xattr change.- What to do:
Back up XFS file systems on a target with a tool that reads attributes through the xattr system calls, or without extended attributes.
TPM tools#
- Mechanism:
lsm/tpm_commandsees every command written to/dev/tpm0and/dev/tpmrm0. It refusesTPM2_NV_Extendof shirudo’s register, NV index0x01818E00, to every task without runtime authority. shirudo itself reaches the TPM throughdevice:/dev/tpmrm0by default, the kernel’s resource manager, and on a target refuses a TCTI that is not adevice:one, which rules out a userspace resource manager such astpm2-abrmd.- Symptom:
tpm2_nvextendof that index fails: the write to the device returnsEACCESandTpmExtendmoves. Every other command works: reading PCRs and NV indices, quotes, keys, other NV indices.- Not refused:
Extending PCRs, which a verifier then sees in PCR 9 or the config PCR (R4, R11), and undefining the register with the owner password, after which measuring commands refuse until the next TPM reset (R20).
- What to do:
Keep other software from measuring into PCR 9, PCR 11 and the config PCR, and keep the owner password from tools that do not need it.
Keyrings and keyctl#
- Mechanism:
lsm/key_permissionguards the.bpfand.dm-veritykeyrings and the keys in them. It refuses write, set-attribute and unlink to every task without runtime authority, and a search through a reference the caller does not possess, which is howkeyctlreaches a key by its serial. The kernel’s own search during signature verification stays open.- Symptom:
keyctl add,link,unlink,clear,revoke,invalidate,setperm,chownandrestrict_keyringon these keyrings or their keys fail withEACCESand moveKeyringWrite. shirudo does not refuse reading them, askeyctl show,list,describeandreaddo.- What to do:
Keep tools that manage these keyrings off targets. They conflict with
initas systemd-keyring-setup does.