eBPF-based security platform
docs: describe the runs the kernel skipped in status and upatch get
Jiri Olsac8509c787487
diff --git a/.agents/skills/bpf-concurrency/SKILL.md b/.agents/skills/bpf-concurrency/SKILL.mdindex 788ff6d7..219d75fb 100644--- a/.agents/skills/bpf-concurrency/SKILL.md+++ b/.agents/skills/bpf-concurrency/SKILL.md@@ -57,7 +57,10 @@ The kernel skips `kprobe` and `kretprobe` runs while another runs on theCPU or the CPU is in a `bpf()` map call, nested `fentry`, `fexit`,`fmod_ret` and `tp_btf` runs, `kretprobe` returns beyond itsinstances and `uretprobe` and `uretprobe.multi` returns beyond the-task's 64, so a detector can miss what it looks for. Refuse an+task's 64, so a detector can miss what it looks for; on a target,+`shirudo status` (`MISSED`, `missed_runs`) and `shirudo upatch get`+show the skips the kernel counts, and `-` or `null` for the uprobe+kinds, whose skips it does not count. Refuse anoperation in an `lsm` program, never in `fmod_ret`: a skipped`fmod_ret` run lets the call through, and a task can arrange the skip.An `lsm` program does not see what an LSM before it refused, and itsdiff --git a/Documentation/operate/deploy/boot-integration.rst b/Documentation/operate/deploy/boot-integration.rstindex 09132e2d..5e1a69b5 100644--- a/Documentation/operate/deploy/boot-integration.rst+++ b/Documentation/operate/deploy/boot-integration.rst@@ -519,8 +519,8 @@ Boot and verifynoneLoaded upatches (1):- NAME LOCATION MAPS STATUS AGE- shirudo-test-basic fentry/do_nanosleep 0 success 1s+ NAME LOCATION MAPS MISSED STATUS AGE+ shirudo-test-basic fentry/do_nanosleep 0 0 success 1sFolded: keyrings, TPM measurement, assets (--show-full)diff --git a/Documentation/operate/deploy/initialize.rst b/Documentation/operate/deploy/initialize.rstindex 5e78363e..c74770dd 100644--- a/Documentation/operate/deploy/initialize.rst+++ b/Documentation/operate/deploy/initialize.rst@@ -102,8 +102,8 @@ Check that init workednoneLoaded upatches (1):- NAME LOCATION MAPS STATUS AGE- shirudo-test-basic fentry/do_nanosleep 0 success 1s+ NAME LOCATION MAPS MISSED STATUS AGE+ shirudo-test-basic fentry/do_nanosleep 0 0 success 1sFolded: keyrings, TPM measurement, assets (--show-full)diff --git a/Documentation/operate/run/read-status.rst b/Documentation/operate/run/read-status.rstindex f0e6982b..c95f580c 100644--- a/Documentation/operate/run/read-status.rst+++ b/Documentation/operate/run/read-status.rst@@ -62,8 +62,8 @@ Print the reportnoneLoaded upatches (1):- NAME LOCATION MAPS STATUS AGE- shirudo-test-basic fentry/do_nanosleep 0 success 1s+ NAME LOCATION MAPS MISSED STATUS AGE+ shirudo-test-basic fentry/do_nanosleep 0 0 success 1sFolded: keyrings, TPM measurement, assets (--show-full)@@ -117,8 +117,8 @@ line; a section unfolds on its own when its condition is not ``OK``.noneLoaded upatches (1):- NAME LOCATION MAPS STATUS AGE- shirudo-test-basic fentry/do_nanosleep 0 success 1s+ NAME LOCATION MAPS MISSED STATUS AGE+ shirudo-test-basic fentry/do_nanosleep 0 0 success 1sKeyring (.bpf):Serial: 272801410@@ -421,9 +421,15 @@ Loaded upatches~~~~~~~~~~~~~~~One row per upatch pinned in the private bpffs: its name, the attach-location resolved from kernel BTF, its number of maps, ``success`` and-the time since it was loaded. A loaded Java agent follows them with the-location ``java`` and no maps. ``Loaded upatches (0):`` followed by+location resolved from kernel BTF, its number of maps, the runs of its+programs the kernel skipped, ``success`` and the time since it was+loaded. ``MISSED`` is ``-`` for an upatch of no attach kind the kernel+counts skipped runs of, such as ``lsm``, ``xdp`` or a uprobe, and ``?``+when they cannot be read. A count that grows means the upatch misses+events it is meant to see; :ref:`runs-the-kernel-skips` says when that+happens, and ``shirudo upatch get`` splits the count by program. A+loaded Java agent follows them with the location ``java``, no maps and+``-`` for ``MISSED``. ``Loaded upatches (0):`` followed by``none`` means nothing is loaded.TPM measurementdiff --git a/Documentation/reference/cli/status.rst b/Documentation/reference/cli/status.rstindex b1900a0f..5ad1092d 100644--- a/Documentation/reference/cli/status.rst+++ b/Documentation/reference/cli/status.rst@@ -223,8 +223,8 @@ Show the state of a target:noneLoaded upatches (1):- NAME LOCATION MAPS STATUS AGE- shirudo-test-basic fentry/do_nanosleep 0 success 1s+ NAME LOCATION MAPS MISSED STATUS AGE+ shirudo-test-basic fentry/do_nanosleep 0 0 success 1sFolded: keyrings, TPM measurement, assets (--show-full)@@ -261,8 +261,8 @@ system as well:noneLoaded upatches (1):- NAME LOCATION MAPS STATUS AGE- shirudo-test-basic fentry/do_nanosleep 0 success 1s+ NAME LOCATION MAPS MISSED STATUS AGE+ shirudo-test-basic fentry/do_nanosleep 0 0 success 1sKeyring (.bpf):Serial: 272801410diff --git a/Documentation/reference/cli/upatch-get.rst b/Documentation/reference/cli/upatch-get.rstindex 6abcff6c..95f4a436 100644--- a/Documentation/reference/cli/upatch-get.rst+++ b/Documentation/reference/cli/upatch-get.rst@@ -30,6 +30,12 @@ Description``fentry/do_nanosleep``.- the program ID, the load time and the payload digest recorded on thepin.+- ``Missed runs``: the runs of its programs the kernel skipped since the+ load, summed over every link of a kind that counts them, with one line+ per program when more than one does. ``not counted for this attach+ kind`` for an upatch of none of them, ``unavailable`` when a link or+ program cannot be read. :ref:`runs-the-kernel-skips` says which kinds+ count and what.- the source lines from the program's BTF line info, which the signedloader installed. They are exact but cover only the lines the compilerkept.@@ -55,7 +61,10 @@ Options- off- Print one JSON object: ``schema`` and ``upatch`` with ``name``,``location``, ``prog_id``, ``loaded_at``, ``age``,- ``payload_sha256``, ``source`` and ``maps``.+ ``payload_sha256``, ``missed_runs`` (the total, or ``null`` when+ no program counts them or they cannot be read), ``programs`` (one+ object per counted program, with its ``location`` and+ ``missed_runs``), ``source`` and ``maps``.* - ``--show-full``- none- off@@ -94,6 +103,7 @@ Describe a loaded upatch:Program ID: 72Loaded at: 2026-11-03T14:54:33Z (1s ago)Payload sha256: 8aee7072a1a15e4dddc93ad6b253a0e2e70ad6cdf767442aa8a1c1997bc3069f (signature-bound)+ Missed runs: 0Maps: noneSource (kernel BTF line_info):diff --git a/Documentation/reference/formats/status-json.rst b/Documentation/reference/formats/status-json.rstindex 230f3001..d230d168 100644--- a/Documentation/reference/formats/status-json.rst+++ b/Documentation/reference/formats/status-json.rst@@ -481,6 +481,11 @@ upatches_loaded* - ``n_maps``- integer- Maps pinned for the upatch.+ * - ``missed_runs``+ - integer or ``null``+ - Runs of the upatch's programs the kernel skipped since the load,+ a lower bound. ``null`` for an upatch of no attach kind that+ counts them, or when they cannot be read.* - ``loaded_at``- string- Change time of the upatch's pin directory, or of a Java agent's@@ -917,6 +922,7 @@ indented here:"location": "fentry/do_nanosleep","status": "success","n_maps": 0,+ "missed_runs": 0,"loaded_at": "2026-11-03T14:54:33Z","age_sec": 1,"payload_sha256": "8aee7072a1a15e4dddc93ad6b253a0e2e70ad6cdf767442aa8a1c1997bc3069f"diff --git a/Documentation/start/quickstart.rst b/Documentation/start/quickstart.rstindex 16c461c2..2b77d285 100644--- a/Documentation/start/quickstart.rst+++ b/Documentation/start/quickstart.rst@@ -397,8 +397,8 @@ Load ittarget# shirudo status --show-full...Loaded upatches (1):- NAME LOCATION MAPS STATUS AGE- basic fentry/do_nanosleep 0 success 1s+ NAME LOCATION MAPS MISSED STATUS AGE+ basic fentry/do_nanosleep 0 0 success 1s...TPM measurement:...diff --git a/Documentation/upatches/write/pitfalls.rst b/Documentation/upatches/write/pitfalls.rstindex 8113867a..974c12c8 100644--- a/Documentation/upatches/write/pitfalls.rst+++ b/Documentation/upatches/write/pitfalls.rst@@ -15,18 +15,22 @@ shows any of it. This page lists what the kernel does that a upatch hasto plan for, for the attach kinds ``shirudo build`` accepts.:doc:`memory-consistency/hazards` covers the runs that interleave.+.. _runs-the-kernel-skips:+Runs the kernel skips----------------------The kernel skips some runs of a program and counts them only in the-program's ``recursion_misses``, which ``struct bpf_prog_info`` reports:+The kernel skips some runs of a program. It counts most in the program's+``recursion_misses``, which ``struct bpf_prog_info`` reports, and some in+the link, which ``struct bpf_link_info`` reports:- A ``kprobe``, ``kretprobe``, ``kprobe.multi`` or ``kretprobe.multi``run, while another program of these four kinds runs on the CPU, andwhile the CPU is in a ``bpf()`` call that looks up, updates or deletesa map element from userspace, as shirudo makes when it reads aupatch's maps. A ``kprobe`` hit inside the handler of another- ``kprobe`` is missed by the kprobe itself.+ ``kprobe`` is missed by the kprobe itself, and counted in the link's+ ``perf_event.kprobe.missed``.- A ``kprobe.multi`` or ``kretprobe.multi`` hit while ftrace alreadytraces a function in the same context on the CPU, such as a watchedfunction the program calls itself, and the return of a function a@@ -39,7 +43,8 @@ program's ``recursion_misses``, which ``struct bpf_prog_info`` reports:with preemptible RCU, or one an NMI interrupted.- The return of a function a ``kretprobe`` watches, when more calls ofit are in flight than the probe has instances for: the larger of 10- and twice the number of CPUs.+ and twice the number of CPUs. The link's ``perf_event.kprobe.missed``+ counts it.- The return of a function a ``uretprobe``, a ``uretprobe.multi`` ortheir ``.s`` forms watch, when the task already waits on the returns of64 calls that return probes watch, and the return of a function that@@ -47,8 +52,15 @@ program's ``recursion_misses``, which ``struct bpf_prog_info`` reports:case, rate-limited, and counts neither.A detector built on these kinds can therefore miss the event it looks-for, and a count it keeps is a lower bound. ``lsm`` and ``xdp`` programs-are never skipped.+for, and a count it keeps is a lower bound. ``lsm``, ``xdp``,+``cgroup_skb`` and ``netfilter`` programs are never skipped.++``shirudo status`` shows, in its ``MISSED`` column and ``missed_runs``,+the sum of what the kernel counts for each upatch: every program's+``recursion_misses`` and every kprobe link's own counter, and ``shirudo+upatch get`` shows it per program. For a uprobe kind it shows ``-`` and+``null``, as the kernel counts none of the runs it skips, and the sum+leaves out what the kernel does not count for the others either.Enforce in lsm programs-----------------------