eBPF-based security platform
proofs: give each record of config-evidence-collect an object of its own
Daniel Borkmannf4bacc7cbd33
diff --git a/testing/proofs/cbmc/ci-skip.list b/testing/proofs/cbmc/ci-skip.listindex 571c1704..84940470 100644--- a/testing/proofs/cbmc/ci-skip.list+++ b/testing/proofs/cbmc/ci-skip.list@@ -10,4 +10,3 @@ bpm-tree-sync-walk no result after 7 hours, past 15 GBbpm-tree-recovery-model 76 to 97 minutes, once no result in 2 hoursupatch-prog-uprobes 12 GB at its peakbpm-tree-state-match 11 GB at its peak, for labels read from /etc-config-evidence-collect 7 GB at its peakdiff --git a/testing/proofs/cbmc/config-evidence-collect.c b/testing/proofs/cbmc/config-evidence-collect.cindex ddb1cdf6..39f26ef2 100644--- a/testing/proofs/cbmc/config-evidence-collect.c+++ b/testing/proofs/cbmc/config-evidence-collect.c@@ -19,7 +19,12 @@#pragma CPROVER check pop#include "../../../util/config_attest.c"-static const struct config_update_record *journal, *selection;+/*+ * Each record is an object of its own, as the reader hands them over one at+ * a time: in one object of 8 KB, a read through a pointer CBMC keeps+ * symbolic, as history()'s last, could be any byte of it.+ */+static const struct config_update_record *journal[LEN + 1], *selection;static int check_result, read_result;static __u8 last_digest[32];static bool hash_failed;@@ -59,7 +64,7 @@ int config_update_events(struct config_update *update,int ret;for (i = 0; i < LEN; i++) {- ret = consume(&journal[i], ctx);+ ret = consume(journal[i], ctx);if (ret)return ret;}@@ -113,23 +118,41 @@ static bool history(size_t *n)*n = 0;for (i = 0; i < LEN; i++) {- if (!this_boot(&journal[i]))+ if (!this_boot(journal[i]))continue;- if (!agrees(&journal[i]) || !journal[i].sequence ||- journal[i].kind != (last ? CONFIG_EVENT_UPDATE :- CONFIG_EVENT_BOOT) ||- (last && journal[i].sequence - last->sequence != 1))+ if (!agrees(journal[i]) || !journal[i]->sequence ||+ journal[i]->kind != (last ? CONFIG_EVENT_UPDATE :+ CONFIG_EVENT_BOOT) ||+ (last && journal[i]->sequence - last->sequence != 1))return false;- last = &journal[i];+ last = journal[i];(*n)++;}return last && last->sequence == selection->sequence &&same(last->target.root_hash, selection->target.root_hash);}+/*+ * The record of this boot that comes at-th, in the journal's order, so that+ * check_exported() reads events[] at an index CBMC knows.+ */+static const struct config_update_record *this_boot_at(size_t at)+{+ size_t i, seen = 0;++ for (i = 0; i < LEN; i++) {+ if (!this_boot(journal[i]))+ continue;+ if (seen++ == at)+ return journal[i];+ }+ return NULL;+}+static void check_exported(const struct config_evidence *view, size_t n){- size_t i, at = 0;+ const struct config_update_record *record;+ size_t at;__CPROVER_assert(view->present && view->pcr == selection->pcr &&view->reset_count == selection->reset_count &&@@ -138,16 +161,14 @@ static void check_exported(const struct config_evidence *view, size_t n)"the selection's PCR, TPM boot and initial value");__CPROVER_assert(view->n_events == n && n <= view->capacity,"this boot's records and no other, inside their room");- for (i = 0; i < LEN; i++) {- if (!this_boot(&journal[i]))- continue;- __CPROVER_assert(view->events[at].sequence ==- journal[i].sequence &&- view->events[at].kind == journal[i].kind &&+ for (at = 0; at < LEN && at < n; at++) {+ record = this_boot_at(at);+ __CPROVER_assert(record &&+ view->events[at].sequence == record->sequence &&+ view->events[at].kind == record->kind &&same(view->events[at].root_hash,- journal[i].target.root_hash),+ record->target.root_hash),"each as the journal has it, in its order");- at++;}__CPROVER_assert(same(view->value, last_digest),"the value after the last event");@@ -158,10 +179,11 @@ void harness(void)struct config_update update, *given = NULL;struct config_evidence view;bool attested, whole;- size_t n;+ size_t i, n;int ret;- journal = any_bytes(LEN * sizeof(*journal));+ for (i = 0; i < LEN; i++)+ journal[i] = any_bytes(sizeof(*journal[i]));selection = any_bytes(sizeof(*selection));check_result = any_result();read_result = any_result();diff --git a/testing/proofs/cbmc/proofs.list b/testing/proofs/cbmc/proofs.listindex c35b92cd..ee5bc68f 100644--- a/testing/proofs/cbmc/proofs.list+++ b/testing/proofs/cbmc/proofs.list@@ -101,7 +101,7 @@ config-evidence-event --unwind 1 --unwindset harness.0:33,same_event.0:33,hex_diconfig-evidence-parse --unwind 1 --unwindset config_evidence_parse.0:7,on_event.0:4,replay.0:4,hex_decode.0:33,strlen.0:66,strcmp.0:15,named.0:7,json_parse.0:7,json_parse.1:4,give_event.0:4,give_text.0:66,any_document.0:4,whole.0:4,in_order.0:4,hex_digits.0:65,spells.0:33,blank.0:33,check_as_said.0:4,check_as_said.1:33 --memory-leak-check --slice-formula LEN=0-2config-evidence-roundtrip --unwind 1 --unwindset config_evidence_emit.0:4,hex_encode.0:33,config_evidence_parse.0:7,on_event.0:4,replay.0:4,hex_decode.0:33,strlen.0:66,strcmp.0:15,named.0:7,json_parse.0:7,json_parse.1:4,give_event.0:4,give_text.0:66,json_kv_string.0:66,sequence_overflows.0:4,replays.0:4,same.0:33,blank.0:33,check_read_back.0:4 --memory-leak-check --slice-formula LEN=0-2config-evidence-verify --unwind 1 --unwindset replay.0:4,memcmp.0:33,in_order.0:4,check_event.0:24,same.0:33 --slice-formula LEN=0-3-config-evidence-collect --unwind 1 --unwindset config_update_events.0:4,replay.0:4,memcmp.0:33,history.0:4,check_exported.0:4,same.0:33,blank.0:33 --memory-leak-check --slice-formula LEN=0-2+config-evidence-collect --unwind 1 --unwindset config_update_events.0:4,replay.0:4,memcmp.0:33,history.0:4,this_boot_at.0:4,check_exported.0:4,same.0:33,blank.0:33,harness.0:4 --memory-leak-check --slice-formula LEN=0-2upatch-writer-header --unwind 2 --unwindset strnlen.0:257,memchr.0:257,memcmp.0:33upatch-writer-sections --memory-leak-check --max-field-sensitivity-array-size 512 --object-bits 10 --unwind 2 --unwindset harness.0:9,compose_signed_data.0:3,compose_signed_data.1:3,parse_signed_sections.0:3,parse_decoders.0:0,parse_policy_labels.0:0 LEN=0,1,7,8upatch-writer-load --max-field-sensitivity-array-size 8192 --unwind 2 --unwindset compose_signed_data.0:5,compose_signed_data.1:5,parse_signed_sections.0:5,parse_decoders.0:2,parse_policy_labels.0:2 LEN=1