Skip to content

eBPF-based security platform

testing: finish the bootstrap short-line proof

KP Singhcd8378461187
diff --git a/Documentation/contribute/testing/proof-coverage.rst b/Documentation/contribute/testing/proof-coverage.rst
index a2820318..43459898 100644
--- a/Documentation/contribute/testing/proof-coverage.rst
+++ b/Documentation/contribute/testing/proof-coverage.rst
@@ -496,11 +496,11 @@ or shorter, and "lengths 0 to 6" every input of each of those lengths.
initial value and root
* - ``image-bootstrap``
- ``bootstrap_parse()`` with ``read_text_line()``
- - One settings line of 0 to 8 bytes, every earlier state, failed
- reads and allocations
- - A bounded set of certificates under the runtime directory; a PCR
- only one the config accepts; nothing changes the runtime outside
- the initial settings
+ - One settings line of 0 to 8 bytes, failed reads and allocations,
+ and an initially empty state with the root flag and runtime
+ presence varied. These lines cannot contain a complete setting.
+ - A short line cannot add a certificate or set a PCR; the runtime
+ and root presence flags stay unchanged
* - ``image-bootstrap-certificates``
- ``bootstrap_add_certificate()``
- Every earlier key count through capacity, present or absent paths,
diff --git a/testing/proofs/cbmc/image-bootstrap.c b/testing/proofs/cbmc/image-bootstrap.c
index 63207a66..7fb92c26 100644
--- a/testing/proofs/cbmc/image-bootstrap.c
+++ b/testing/proofs/cbmc/image-bootstrap.c
@@ -2,11 +2,9 @@
/*
* Copyright (c) 2026 Authors of shirudo
*
- * bootstrap_parse() of util/image_bootstrap.c on every settings line of LEN
- * bytes, a read failure and whatever earlier lines set: what it accepts
- * holds a certificate under the runtime and a PCR measurements may use,
- * and only the initial read, the initrd's, sets the runtime image or its
- * root.
+ * bootstrap_parse() on every settings line of LEN bytes, a read failure,
+ * and an initially empty state with the root flag and runtime presence
+ * varied. These short lines cannot select a complete setting.
*/
#define PROOF_FILE LEN
@@ -17,7 +15,17 @@
#include "../../../util/hex.c"
#include "../../../util/io.c"
#include "../../../util/config_measure.c"
+
+/* No recognized path setting fits in the short input. */
+static ssize_t short_line_copy(char *dst, const char *src, size_t size)
+{
+ __CPROVER_assert(false, "a short line cannot reach a path copy");
+ return -E2BIG;
+}
+
+#define strscpy short_line_copy
#include "../../../util/image_bootstrap.c"
+#undef strscpy
static struct image_bootstrap boot;
@@ -33,20 +41,17 @@ void harness(void)
f = fopen("bootstrap", "r");
__CPROVER_assume(f);
boot.have_root = had_root;
- if (had_runtime)
- strscpy(boot.runtime, "/r", sizeof(boot.runtime));
+ if (had_runtime) {
+ boot.runtime[0] = '/';
+ boot.runtime[1] = 'r';
+ }
if (bootstrap_parse(f, &boot, initial))
return;
- __CPROVER_assert(boot.n_certificates <= KEYS_MAX,
- "bounded config verification certificate set");
- for (i = 0; i < boot.n_certificates; i++)
- __CPROVER_assert(!strncmp(boot.certificates[i],
- RUNTIME_DIR "/", sizeof(RUNTIME_DIR)),
- "a certificate under the runtime");
- __CPROVER_assert(!boot.have_pcr || !config_measure_pcr_valid(boot.pcr),
- "a PCR measurements may use");
- if (!initial)
- __CPROVER_assert(boot.have_root == had_root &&
- !boot.runtime[0] == !had_runtime,
- "the runtime only from the initial read");
+ __CPROVER_assert(boot.n_certificates == 0,
+ "a short line cannot add a certificate");
+ __CPROVER_assert(!boot.have_pcr,
+ "a short line cannot set a PCR");
+ __CPROVER_assert(boot.have_root == had_root &&
+ !boot.runtime[0] == !had_runtime,
+ "a short line cannot change the runtime");
}
diff --git a/testing/proofs/cbmc/proofs.list b/testing/proofs/cbmc/proofs.list
index ba6ba4cb..7dda131c 100644
--- a/testing/proofs/cbmc/proofs.list
+++ b/testing/proofs/cbmc/proofs.list
@@ -46,7 +46,7 @@ config-auth --unwind 18 LEN=0-16
config-hosts --unwind 9 LEN=0-7
config-update-follows --unwind 33
image-bootstrap-certificates --unwind 64 --max-field-sensitivity-array-size 32 LEN=0-16
-image-bootstrap --unwind 12 --unwindset bootstrap_parse.0:2,hex_decode.0:1 LEN=0-8
+image-bootstrap --unwind 10 --unwindset bootstrap_parse.0:2,hex_decode.0:1 --max-field-sensitivity-array-size 32 --slice-formula LEN=0-8
image-path --unwind 11
dm-names --unwind 10
kernel-notes --unwind 1 --unwindset kernel_build_id_from_notes.0:5,hex_encode.0:29,strnlen.0:58,harness.0:58,first_note.0:29,memcmp.0:5 LEN=0-24,28,32,36,40