Skip to content

eBPF-based security platform

Documentation: draw package delivery, key trust and the upatch tree

Daniel Borkmannbeb190090683
diff --git a/Documentation/images/operate-key-trust.svg b/Documentation/images/operate-key-trust.svg
new file mode 100644
index 00000000..0062fe32
--- /dev/null
+++ b/Documentation/images/operate-key-trust.svg
@@ -0,0 +1,55 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 350" width="760" height="350" font-family="sans-serif" role="img" aria-labelledby="t">
+ <title id="t">Init builds the .bpf keyring from the runtime image's primary certificate and the config image's vouched certificates minus its revocations, and the .dm-verity keyring from the runtime image's config certificate; tree publications verify against the primary alone and package indexes against their repository certificates</title>
+ <style>@media (prefers-color-scheme: dark) { [fill="#5d6675"] { fill: #b4bcc7; } }</style>
+ <defs>
+ <marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
+ <path d="M0,0 L10,5 L0,10 z" fill="#8a93a0"/>
+ </marker>
+ </defs>
+ <g fill="none" stroke="#8a93a0" stroke-width="1.5">
+ <rect x="10" y="40" width="220" height="170" rx="6" fill="#8a93a0" fill-opacity="0.08"/>
+ <rect x="22" y="94" width="196" height="46" rx="4"/>
+ <rect x="22" y="152" width="196" height="46" rx="4"/>
+ <rect x="270" y="40" width="220" height="228" rx="6" fill="#8a93a0" fill-opacity="0.08"/>
+ <rect x="282" y="94" width="196" height="46" rx="4"/>
+ <rect x="282" y="152" width="196" height="46" rx="4"/>
+ <rect x="282" y="210" width="196" height="46" rx="4"/>
+ <rect x="530" y="40" width="220" height="228" rx="6" stroke-dasharray="6 4"/>
+ <rect x="542" y="80" width="196" height="104" rx="4" fill="#8a93a0" fill-opacity="0.08"/>
+ <rect x="542" y="196" width="196" height="62" rx="4" fill="#8a93a0" fill-opacity="0.08"/>
+ <path d="M218,104 L250,104 L250,24 L510,24 L510,96 L540,96" marker-end="url(#arrow)"/>
+ <line x1="478" y1="117" x2="540" y2="117" marker-end="url(#arrow)"/>
+ <line x1="478" y1="175" x2="540" y2="160" marker-end="url(#arrow)"/>
+ <path d="M218,175 L250,175 L250,290 L640,290 L640,260" marker-end="url(#arrow)"/>
+ </g>
+ <g fill="#5d6675" font-size="11">
+ <g text-anchor="middle">
+ <text x="120" y="64" font-size="13">Runtime image</text>
+ <text x="120" y="80">dm-verity, root hash in the UKI</text>
+ <text x="120" y="114">keys/cert.der</text>
+ <text x="120" y="130">runtime primary BPF certificate</text>
+ <text x="120" y="172">etc/shirudo/config-cert.der</text>
+ <text x="120" y="188">config verification certificate</text>
+ <text x="380" y="64" font-size="13">Config image</text>
+ <text x="380" y="80">signed, checked against .dm-verity</text>
+ <text x="380" y="114">keys/trusted/&lt;name&gt;.der, .vouch</text>
+ <text x="380" y="130">vouched BPF certificates</text>
+ <text x="380" y="172">keys/revoked/&lt;fingerprint&gt;.der</text>
+ <text x="380" y="188">revocation records</text>
+ <text x="380" y="230">etc/shirudo/bpm/keys/</text>
+ <text x="380" y="246">repository index certificates</text>
+ <text x="640" y="64" font-size="13">Kernel keyrings, sealed by init</text>
+ <text x="640" y="101" font-size="13">.bpf</text>
+ <text x="640" y="119">the primary, each certificate</text>
+ <text x="640" y="135">vouched by one already in the set,</text>
+ <text x="640" y="151">minus revoked, at most 16</text>
+ <text x="640" y="173">checks signed loaders</text>
+ <text x="640" y="217" font-size="13">.dm-verity</text>
+ <text x="640" y="235">the config certificate</text>
+ <text x="640" y="251">checks config images</text>
+ <text x="509" y="190">removes</text>
+ </g>
+ <text x="10" y="320">Tree publications verify against the runtime primary alone, whatever the config vouches for or revokes.</text>
+ <text x="10" y="338">Package indexes verify against the certificate their repository definition names.</text>
+ </g>
+</svg>
diff --git a/Documentation/images/operate-package-delivery.svg b/Documentation/images/operate-package-delivery.svg
new file mode 100644
index 00000000..dcc459e4
--- /dev/null
+++ b/Documentation/images/operate-package-delivery.svg
@@ -0,0 +1,64 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 360" width="760" height="360" font-family="sans-serif" role="img" aria-labelledby="t">
+ <title id="t">The operator host builds and pushes packages, a signed index and tree operations to an OCI registry; the target's timers pull them, verify them and load the upatches, which the kernel checks and the TPM measures</title>
+ <style>@media (prefers-color-scheme: dark) { [fill="#5d6675"] { fill: #b4bcc7; } }</style>
+ <defs>
+ <marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
+ <path d="M0,0 L10,5 L0,10 z" fill="#8a93a0"/>
+ </marker>
+ </defs>
+ <g fill="none" stroke="#8a93a0" stroke-width="1.5">
+ <rect x="10" y="40" width="200" height="270" rx="6" fill="#8a93a0" fill-opacity="0.08"/>
+ <rect x="250" y="40" width="200" height="270" rx="6" fill="#8a93a0" fill-opacity="0.08"/>
+ <rect x="265" y="96" width="170" height="54" rx="4"/>
+ <rect x="265" y="164" width="170" height="40" rx="4"/>
+ <rect x="265" y="218" width="170" height="54" rx="4"/>
+ <rect x="490" y="10" width="260" height="340" rx="6" stroke-dasharray="6 4"/>
+ <rect x="505" y="44" width="230" height="208" rx="4" fill="#8a93a0" fill-opacity="0.08"/>
+ <rect x="505" y="268" width="230" height="70" rx="4" fill="#8a93a0" fill-opacity="0.08"/>
+ <line x1="210" y1="175" x2="248" y2="175" marker-end="url(#arrow)"/>
+ <line x1="450" y1="175" x2="503" y2="175" marker-end="url(#arrow)"/>
+ <line x1="620" y1="252" x2="620" y2="266" marker-end="url(#arrow)"/>
+ </g>
+ <g fill="#5d6675" font-size="11">
+ <text x="502" y="32" font-size="12">target</text>
+ <g text-anchor="middle">
+ <text x="110" y="64" font-size="13">Operator host</text>
+ <text x="350" y="64" font-size="13">OCI registry</text>
+ <text x="350" y="82">one endpoint per repository</text>
+ <text x="350" y="119">shirudo/bpm-index:stable</text>
+ <text x="350" y="137">index and its signature</text>
+ <text x="350" y="188">packages (.bee)</text>
+ <text x="350" y="241">upatch tree</text>
+ <text x="350" y="259">publication and artifacts</text>
+ <text x="620" y="66" font-size="13">Timers</text>
+ <text x="620" y="291" font-size="13">Kernel and TPM</text>
+ <text x="620" y="310">signature checked against .bpf</text>
+ <text x="620" y="326">register extended per load</text>
+ <text x="229" y="167">push</text>
+ <text x="476" y="167">pull</text>
+ </g>
+ <text x="22" y="100">1</text>
+ <text x="37" y="100">shirudo bpm build</text>
+ <text x="37" y="116">&lt;name&gt;-&lt;version&gt;.bee</text>
+ <text x="22" y="146">2</text>
+ <text x="37" y="146">shirudo bpm push</text>
+ <text x="37" y="162">package and a signed</text>
+ <text x="37" y="178">index entry</text>
+ <text x="22" y="208">3</text>
+ <text x="37" y="208">shirudo bpm tree append</text>
+ <text x="37" y="224">a signed tree operation,</text>
+ <text x="37" y="240">optional</text>
+ <text x="517" y="92">4</text>
+ <text x="532" y="92">bpm repo update, every minute:</text>
+ <text x="532" y="108">verify each index against its</text>
+ <text x="532" y="124">repository certificate, cache it</text>
+ <text x="517" y="150">5</text>
+ <text x="532" y="150">bpm upgrade: for a newer</text>
+ <text x="532" y="166">version, check the digest and</text>
+ <text x="532" y="182">load each upatch</text>
+ <text x="517" y="208">6</text>
+ <text x="532" y="208">bpm tree sync, every minute:</text>
+ <text x="532" y="224">verify against the primary,</text>
+ <text x="532" y="240">apply matching operations</text>
+ </g>
+</svg>
diff --git a/Documentation/images/operate-tree-selectors.svg b/Documentation/images/operate-tree-selectors.svg
new file mode 100644
index 00000000..68ad523c
--- /dev/null
+++ b/Documentation/images/operate-tree-selectors.svg
@@ -0,0 +1,48 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 330" width="760" height="330" font-family="sans-serif" role="img" aria-labelledby="t">
+ <title id="t">A target with kernel release 7.4.0, architecture x86_64 and label env=prod goes through a tree publication in sequence order: it applies the operations whose selectors match, skips the others for good, and its cursor last_seq ends at the last operation</title>
+ <style>@media (prefers-color-scheme: dark) { [fill="#5d6675"] { fill: #b4bcc7; } }</style>
+ <defs>
+ <marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
+ <path d="M0,0 L10,5 L0,10 z" fill="#8a93a0"/>
+ </marker>
+ </defs>
+ <g fill="none" stroke="#8a93a0" stroke-width="1.5">
+ <rect x="10" y="44" width="420" height="34" rx="4" fill="#8a93a0" fill-opacity="0.08"/>
+ <rect x="10" y="88" width="420" height="34" rx="4" fill="#8a93a0" fill-opacity="0.08"/>
+ <rect x="10" y="132" width="420" height="34" rx="4" fill="#8a93a0" fill-opacity="0.08"/>
+ <rect x="10" y="176" width="420" height="34" rx="4" fill="#8a93a0" fill-opacity="0.08"/>
+ <rect x="10" y="220" width="420" height="34" rx="4" fill="#8a93a0" fill-opacity="0.08"/>
+ <rect x="470" y="44" width="280" height="34" rx="4"/>
+ <rect x="470" y="88" width="280" height="34" rx="4"/>
+ <rect x="470" y="132" width="280" height="34" rx="4" stroke-dasharray="4 3"/>
+ <rect x="470" y="176" width="280" height="34" rx="4" stroke-dasharray="4 3"/>
+ <rect x="470" y="220" width="280" height="34" rx="4"/>
+ <line x1="430" y1="61" x2="468" y2="61" marker-end="url(#arrow)"/>
+ <line x1="430" y1="105" x2="468" y2="105" marker-end="url(#arrow)"/>
+ <line x1="430" y1="149" x2="468" y2="149" marker-end="url(#arrow)"/>
+ <line x1="430" y1="193" x2="468" y2="193" marker-end="url(#arrow)"/>
+ <line x1="430" y1="237" x2="468" y2="237" marker-end="url(#arrow)"/>
+ </g>
+ <g fill="#5d6675" font-size="11">
+ <text x="10" y="28" font-size="13">Tree publication, in sequence order</text>
+ <text x="470" y="20" font-size="13">Target</text>
+ <text x="470" y="36">release 7.4.0, x86_64, label env=prod</text>
+ <text x="22" y="65">1 add obs</text>
+ <text x="160" y="65">no selector</text>
+ <text x="22" y="109">2 add fix-a</text>
+ <text x="160" y="109">kernel_release_prefix 7.4</text>
+ <text x="22" y="153">3 add fix-b</text>
+ <text x="160" y="153">architecture aarch64</text>
+ <text x="22" y="197">4 add probe</text>
+ <text x="160" y="197">labels env=canary</text>
+ <text x="22" y="241">5 delete fix-a</text>
+ <text x="160" y="241">kernel_release_prefix 7.4</text>
+ <text x="482" y="65">applied: loaded and measured</text>
+ <text x="482" y="109">applied: loaded and measured</text>
+ <text x="482" y="153">skipped: architecture differs</text>
+ <text x="482" y="197">skipped: label differs</text>
+ <text x="482" y="241">applied: unloaded and measured</text>
+ <text x="10" y="290">The cursor last_seq ends at 5. Operations 3 and 4 stay skipped, even if the target's labels or</text>
+ <text x="10" y="308">kernel change later; a new operation with its own sequence number is the way to reach the target.</text>
+ </g>
+</svg>
diff --git a/Documentation/operate/maintain/keys.rst b/Documentation/operate/maintain/keys.rst
index c39b37dc..075b7ba3 100644
--- a/Documentation/operate/maintain/keys.rst
+++ b/Documentation/operate/maintain/keys.rst
@@ -33,6 +33,21 @@ Before you begin
Key inventory
-------------
+Figure 1 shows how ``init`` builds the kernel's two keyrings from the
+runtime image and the config image, and which key checks what. The
+table lists every key.
+
+.. figure:: /images/operate-key-trust.svg
+ :alt: The .bpf keyring holds the runtime image's primary certificate
+ and the config image's vouched certificates minus its
+ revocations; the .dm-verity keyring holds the runtime image's
+ config certificate. Tree publications verify against the
+ primary alone, package indexes against their repository
+ certificate.
+
+ Figure 1. The keys a target trusts and the keyrings ``init`` builds
+ from them.
+
.. list-table::
:header-rows: 1
:widths: 22 28 50
diff --git a/Documentation/operate/run/deliver-packages.rst b/Documentation/operate/run/deliver-packages.rst
index e9babbbb..03387ddf 100644
--- a/Documentation/operate/run/deliver-packages.rst
+++ b/Documentation/operate/run/deliver-packages.rst
@@ -17,7 +17,8 @@ and how the timers and the upatch tree deliver them without you.
How a package reaches a target
------------------------------
-Delivery is a pull in four steps:
+Delivery is a pull in four steps, which Figure 1 shows together with
+the upatch tree:
#. On the operator host, ``shirudo bpm push`` publishes the package and
a signed entry in the repository index ``shirudo/bpm-index:stable``.
@@ -42,6 +43,15 @@ reaches every target that follows the repository about a minute later,
with nobody logged in. Treat every push to an index as a fleet-wide
rollout.
+.. figure:: /images/operate-package-delivery.svg
+ :alt: The operator host builds and pushes a package, a signed index
+ entry and, optionally, a signed tree operation to an OCI
+ registry. On the target, timers update the indexes, upgrade
+ the packages and sync the tree; each load is checked by the
+ kernel and measured by the TPM.
+
+ Figure 1. How a package and a tree operation reach a target.
+
What is configured where
------------------------
@@ -357,7 +367,8 @@ node labels, so one publication serves a mixed fleet.
boot and every 60 seconds after that. Without a tree configuration the
command exits 0 and does nothing. Each applied operation is measured.
-Keep these rules of the tree in mind:
+Keep these rules of the tree in mind. Figure 2 shows them on one
+publication:
- A sync moves the target's cursor past an operation whose selectors do
not match. The target never applies that operation later, even when
@@ -370,6 +381,15 @@ Keep these rules of the tree in mind:
sign them, and revoking the primary in the signed config does not stop
them. :doc:`/operate/maintain/keys` describes the limit.
+.. figure:: /images/operate-tree-selectors.svg
+ :alt: A target with kernel 7.4.0 on x86_64 and the label env=prod
+ applies the operations with no selector or a matching
+ kernel release, skips those for aarch64 and for env=canary,
+ and ends with last_seq at the last operation.
+
+ Figure 2. One target going through a tree publication. Skipped
+ operations stay skipped.
+
Timers and locks
----------------