Skip to content

eBPF-based security platform

bpm: refuse a tree publication whose tree ID is not a package name

Daniel Borkmanne717577ed195
diff --git a/Documentation/reference/formats/bpm-formats.rst b/Documentation/reference/formats/bpm-formats.rst
index a13d604c..833d385a 100644
--- a/Documentation/reference/formats/bpm-formats.rst
+++ b/Documentation/reference/formats/bpm-formats.rst
@@ -351,7 +351,7 @@ Publication document
* - ``schema``
- ``1``. Required.
* - ``tree_id``
- - Non-empty. Required.
+ - A package name. Required.
* - ``generation``
- Required. 1 for the first publication, one more for each append.
From 0 to 2\ :sup:`63` - 2.
@@ -481,9 +481,9 @@ Target acceptance
matching its descriptor's digest and size.
#. The signature verifies against the runtime image's initial
certificate.
-#. The document parses with the rules above, ``base.seq`` is 0, and every
- operation has a valid ``id``, ``op`` and digests and a correct
- ``operation_digest``.
+#. The document parses with the rules above, ``tree_id`` is a package
+ name, ``base.seq`` is 0, and every operation has a valid ``id``,
+ ``op`` and digests and a correct ``operation_digest``.
#. ``tree_id`` equals the one the node recorded.
#. A publication other than the recorded one has a higher
``generation``. A direct successor that names a
diff --git a/builtin-bpm.c b/builtin-bpm.c
index 788df101..0e8cb944 100644
--- a/builtin-bpm.c
+++ b/builtin-bpm.c
@@ -2230,6 +2230,15 @@ static int cmd_bpm_tree_sync(int argc, const char **argv)
ret = -EINVAL;
goto out;
}
+ /*
+ * The node records the tree ID in its state, which takes names
+ * alone: one that is not would be applied, measured and logged
+ * and then never recorded, failing every later sync.
+ */
+ if (!bpm_package_name_ok(pub.tree_id)) {
+ ret = -EINVAL;
+ goto out;
+ }
/* Snapshot compaction belongs to a later schema. */
if (pub.base_seq != 0) {
ret = -ENOTSUP;