Skip to content

eBPF-based security platform

proofs: say what ties the tree sync model to the C and its walks

Daniel Borkmann3290cd146952
diff --git a/Documentation/contribute/testing/proof-coverage.rst b/Documentation/contribute/testing/proof-coverage.rst
index 194b1d1b..47b540f4 100644
--- a/Documentation/contribute/testing/proof-coverage.rst
+++ b/Documentation/contribute/testing/proof-coverage.rst
@@ -271,7 +271,8 @@ or shorter, and "lengths 0 to 6" every input of each of those lengths.
the registry cannot serve. Names have one byte, and the previous
root and the history roots the outcomes record holds at the cursor
and at any other seq have 32 symbolic bytes each.
- - Writes match the Lean model ``Shirudo.TreeSync`` in order, the
+ - Writes match the C restatement of the Lean model
+ ``Shirudo.TreeSync`` in ``bpm-tree-sync-model.c`` in order, the
cut of the outcomes record, each outcome line with its code and
both roots, and the state written at acceptance with the
publication's head and base included; a publication whose base
@@ -1324,18 +1325,19 @@ the model follows the C.
``sync_progress``: given a checked publication that follows a
reachable node and holds its pending operation when that is
above the cursor, recovery refuses nothing and the sync runs to
- its end, recording the publication's head as the cursor. All of
- these hold across
- segment boundaries, as a publication of any base is a sync;
- ``walk_same_ops``: the segments of a walk, each recorded before
+ its end, recording the publication's head as the cursor. They
+ cover a publication of any base, and a sync that walks only as a
+ sync of each segment in turn; ``walk_same_ops``: the segments of a
+ walk, each recorded before
its operations, apply the operations of the tree taken as one
publication, in its order, with the same ``pending.json``,
register, tree eventlog and outcomes writes, and end at the same
cursor and projection root
- - A sync that walks is one sync per segment: it leaves out only the
- state each segment but the last writes at its end, which the next
- segment's record overwrites with the same cursor and root, and
- its cut keeps every line; the base and prefix checks are left out
+ - A sync that walks is taken as one sync per segment, which it is
+ but for the state each segment but the last writes at its end, a
+ pending record an earlier segment passed, which stays to the next
+ sync rather than the next segment, and the cut a sync makes before
+ a walk back that refuses; the base and prefix checks are left out
of the model, as they only refuse more. A manifest digest names
one publication; the hash is injective on
(root, digest) and never 64 zeros; only sync writes the tree files,
@@ -1344,12 +1346,16 @@ the model follows the C.
outcome line holds whether the selector matched, not which of 1
and 3, and no history root; the check that the record covers the
cursor is a theorem, not a branch of the model
- - CBMC: ``bpm-tree-follows`` for ``tree_publication_follows()``,
- ``bpm-tree-sync-model`` and its two-operation variants for
- sync writes, ``bpm-tree-sync-walk`` for a walk,
+ - CBMC, all run in CI: ``bpm-tree-follows`` for
+ ``tree_publication_follows()``; ``bpm-tree-sync-model`` and its
+ two-operation variants and ``bpm-tree-sync-walk`` check
+ ``cmd_bpm_tree_sync()``, its loop, recovery and a walk over one
+ sealed segment against the C restatement of ``run``, ``recover``
+ and ``loop``, writes and refusals alike;
``bpm-tree-recovery-model`` for pending recovery,
- ``bpm-tree-state-replay`` for ``tree_event_replay()``;
- ``tree_parse()`` and the walk as one sync per segment by review
+ ``bpm-tree-state-replay`` for ``tree_event_replay()``. The
+ restatement, ``tree_parse()`` and the walk as one sync per
+ segment by review
* - ``Shirudo.TreeOverlap``, :src:`util/bpm_tree_overlap.c` against
``tree_selector_matches()`` of :src:`util/bpm_tree_state.c`
- ``disjoint_sound``: no node matches two selectors that
diff --git a/testing/proofs/lean4/Shirudo/TreeSync.lean b/testing/proofs/lean4/Shirudo/TreeSync.lean
index 53d430c7..8930c5bb 100644
--- a/testing/proofs/lean4/Shirudo/TreeSync.lean
+++ b/testing/proofs/lean4/Shirudo/TreeSync.lean
@@ -82,27 +82,39 @@ the payload already loaded under the name as installed, and
`upatch_remove()` an upatch already gone as removed.
testing/proofs/cbmc/bpm-tree-follows.c proves
`tree_publication_follows()` returns 0 exactly when `Follows` holds and asks
-for a walk exactly when the publication starts past the cursor, and
-bpm-tree-sync-model.c checks the writes of `cmd_bpm_tree_sync()` against
-`run` for publications of up to two operations, and through a walk back
-over one sealed segment.
+for a walk exactly when the publication starts past the cursor.
+bpm-tree-sync-model.c restates `run`, `recover` and `loop` in C, which
+review alone ties to the definitions here, and the CBMC proofs built on it,
+all of which CI runs, check `cmd_bpm_tree_sync()` against that
+restatement: it makes the same writes in the same order, none after a
+failure or a refusal and all of them when nothing fails, and refuses
+exactly where the restatement refuses. They do so for publications of no,
+one and two operations, the last with and without a pending record
+(bpm-tree-sync-model, -application, -pending), and through a walk back over
+one sealed segment of one operation (bpm-tree-sync-walk);
+bpm-tree-recovery-model checks `tree_recover_pending()` alone on
+publications of up to two operations.
A publication that starts past the cursor is a segment the node reaches by
walking back through the sealed segments before it. The sync then takes
the segments oldest first, each recorded at acceptance and its operations
applied, as `run` takes one publication: the oldest segment with the cut
of the outcomes record and recovery, and each later one, which starts at
-the cursor the one before left, with neither, as the cut keeps every line
-and nothing is pending between two segments. A sync that walks is
-therefore a sync of each segment in turn, with one write fewer: the state
-`run` writes at the end of a segment, which the next segment's record at
-acceptance overwrites with the same cursor and root. Every node such a
-sync leaves is one a `Steps` history of single syncs leaves, so every
-theorem here holds across segment boundaries too; `walk_same_ops` shows
-that the segments apply the operations the unsegmented tree applies, in
-its order, with the same records. The base check and the prefix check
-of the walk only refuse more; the model leaves them out, as it does the
-digest checks.
+the cursor the one before left, with neither. Such a sync is close to a
+sync of each segment in turn: it leaves out the state `run` writes at the
+end of a segment, which the next segment's record at acceptance
+overwrites with the same cursor and root, and the cut of each later
+segment, which would keep every line. It differs in two ways no `Step`
+takes: a pending record an earlier segment's loop passed over stays until
+the next sync's recovery removes it, where a sync of the next segment
+would remove it at once, and a sync whose walk back refuses has already
+cut the outcomes record to the cursor, without a publication that follows
+the node. `Step` has no walk, so the theorems here cover a sync that walks
+only by that argument, not by proof; `walk_same_ops` shows that the
+segments apply the operations the unsegmented tree applies, in its order,
+with the same records. The base check and the prefix check of the walk
+only refuse more; the model leaves them out, as it does the digest
+checks.
-/
namespace Shirudo.TreeSync