Skip to content

eBPF-based security platform

systemd: run the XDP reconcile timer every 60 seconds

John Fastabend149b1847241e
diff --git a/Documentation/operate/run/read-status.rst b/Documentation/operate/run/read-status.rst
index 94151efb..40dfb441 100644
--- a/Documentation/operate/run/read-status.rst
+++ b/Documentation/operate/run/read-status.rst
@@ -260,7 +260,8 @@ verdict is derived from them.
reports: ``no native XDP``, ``no multi-buffer XDP``, ``another
XDP program attached`` or ``not attached``. A device added in the
last seconds shows ``not attached`` until ``upatch reconcile``
- attaches it. One that stays listed is unfiltered. Its driver
+ attaches it, and one udev does not announce, such as a veth peer
+ moving namespace, for up to a minute. One that stays listed is unfiltered. Its driver
refused the program, or a setting such as LRO turned its XDP off,
or the reconcile units are stopped. ``WARN`` ``XDP coverage not
checked: <error>`` means the check could not run.
@@ -670,6 +671,18 @@ program, and the next ``upatch reconcile`` attaches it. Where the
device cannot run XDP at all, sign the upatch with a class mask that
leaves the device out.
+A device that stays listed also costs the target work on every
+reconcile pass. The pass takes the register lock, checks the archive
+again, retries the attach and logs a warning, every 60 seconds and on
+each udev event for the device, for as long as the device stays as it
+is. shirudo does not stop retrying on its own, because a pass has no
+memory of the last one. Treat a lasting ``XdpCovered`` warning as an
+alert. End it by undoing what makes the device refuse, or, if the device
+is meant to stay that way, by unloading the upatch (``upatch unload``
+with its unload directive, ``bpm uninstall``, or retracting it from the
+upatch tree) and loading one signed with a class mask that leaves the
+device out.
+
The reason ``no TPM answered`` means the TPM stopped answering while
``status`` ran. On a production target every command first checks that
the TPM is the one ``init`` bound, so a TPM that does not answer at all
diff --git a/Documentation/operate/run/telemetry.rst b/Documentation/operate/run/telemetry.rst
index aced49d2..3fcd0114 100644
--- a/Documentation/operate/run/telemetry.rst
+++ b/Documentation/operate/run/telemetry.rst
@@ -406,8 +406,10 @@ The keepalive body is the ``shirudo status --json`` document.
enforcement.
* - ``XdpCovered`` with ``status`` ``WARN`` in several keepalives
- A device an XDP upatch selects runs without it: its driver
- refuses the program or its XDP was turned off. See
- :doc:`/operate/run/read-status`.
+ refuses the program or its XDP was turned off. Each reconcile
+ pass retries it at a cost to the target until the device changes
+ or the upatch is unloaded. Alert on it, and end it as
+ :doc:`/operate/run/read-status` describes.
* - ``shirudo.tamper_attempts`` rises
- Something on the target tried an operation the guards refused.
The counters start at zero each boot. See
diff --git a/Documentation/reference/cli/upatch-reconcile.rst b/Documentation/reference/cli/upatch-reconcile.rst
index 4d1b64a6..6a945b71 100644
--- a/Documentation/reference/cli/upatch-reconcile.rst
+++ b/Documentation/reference/cli/upatch-reconcile.rst
@@ -45,7 +45,12 @@ device what it runs:
- Leaves it. A program already on a device is never replaced.
It also removes the pin of a link whose device is gone. A pass that has
-nothing to do does not take the register lock.
+nothing to do does not take the register lock. A selected device that
+keeps refusing is not nothing to do: every pass takes the lock, checks
+the archive again, retries it and logs a warning, on each udev event
+for the device and every 60 seconds from the timer. ``status`` reports
+such a device under ``XdpCovered``, and it is for the operator to end,
+as :doc:`/operate/run/read-status` describes.
``reconcile`` adds no event to the register: the measured state is the
upatch, not the devices it reaches.
diff --git a/Documentation/reference/systemd-units.rst b/Documentation/reference/systemd-units.rst
index 666eea2d..f27711ed 100644
--- a/Documentation/reference/systemd-units.rst
+++ b/Documentation/reference/systemd-units.rst
@@ -221,8 +221,10 @@ The rule ``90-shirudo-xdp-reconcile.rules`` in
network device other than ``lo`` appears. It is not ``RUN+=``, because a
child of ``systemd-udevd`` inherits its seccomp filter and would get no
task mark. A veth peer moving namespace gives the initial namespace no
-such event, so the timer is what catches it. The unit and the rule are not
-in the initrd. See :doc:`/reference/cli/upatch-reconcile`.
+such event, so the timer is what catches it, within a minute. The timer
+runs a pass 60 seconds after the previous one ends rather than more
+often because a device that keeps refusing costs a full retry on every
+pass. The unit and the rule are not in the initrd. See :doc:`/reference/cli/upatch-reconcile`.
shirudo-map-export.service
--------------------------
@@ -320,7 +322,7 @@ Timers
* - ``shirudo-keepalive.timer``
- ``OnBootSec=5s``, ``OnUnitInactiveSec=5s``, ``AccuracySec=1s``
* - ``shirudo-xdp-reconcile.timer``
- - ``OnBootSec=5s``, ``OnUnitInactiveSec=5s``, ``AccuracySec=1s``
+ - ``OnBootSec=5s``, ``OnUnitInactiveSec=60s``, ``AccuracySec=1s``
* - ``shirudo-map-export.timer``
- ``OnBootSec=5s``, ``OnUnitInactiveSec=5s``, ``AccuracySec=1s``
* - ``shirudo-bpm-repo-update.timer``
diff --git a/Documentation/security/threat-model.rst b/Documentation/security/threat-model.rst
index 31d680e7..60448365 100644
--- a/Documentation/security/threat-model.rst
+++ b/Documentation/security/threat-model.rst
@@ -1552,7 +1552,7 @@ R21 upatches can be neutralized by changing their targets
XDP coverage is reconciled, not continuous. A device added after load
runs without the upatch until ``upatch reconcile`` next runs, and is
unfiltered until then: normally seconds after its udev event, and up to
- one pass plus five seconds when udev gives no signal, as for a veth
+ one pass plus 60 seconds when udev gives no signal, as for a veth
peer moving namespace. A device stays uncovered while its XDP slot is
occupied, it has no native XDP, its driver refuses the program, or
root stops the timer and the udev rule. ``status`` lists every such
diff --git a/systemd/shirudo-xdp-reconcile.timer b/systemd/shirudo-xdp-reconcile.timer
index a3f2ca57..6a1383c2 100644
--- a/systemd/shirudo-xdp-reconcile.timer
+++ b/systemd/shirudo-xdp-reconcile.timer
@@ -6,7 +6,7 @@ Description=shirudo: periodically attach XDP upatches to new network devices
[Timer]
OnBootSec=5s
-OnUnitInactiveSec=5s
+OnUnitInactiveSec=60s
AccuracySec=1s
Unit=shirudo-xdp-reconcile.service