Skip to content

eBPF-based security platform

proofs: check where on_pcr() stores a PCR value, and what

Daniel Borkmann0b9a4496a13e
diff --git a/Documentation/contribute/testing/proof-coverage.rst b/Documentation/contribute/testing/proof-coverage.rst
index ddea2ce7..79c107eb 100644
--- a/Documentation/contribute/testing/proof-coverage.rst
+++ b/Documentation/contribute/testing/proof-coverage.rst
@@ -953,8 +953,9 @@ or shorter, and "lengths 0 to 6" every input of each of those lengths.
* - ``attest-pcr``
- ``on_pcr()`` of the evidence parser
- Every index and 64-byte value text
- - Stores only PCRs 0 to 23 and marks exactly that one, from 64 hex
- digits; a refusal marks nothing
+ - Stores only PCRs 0 to 23, the value its 64 hex digits spell under
+ its index, and marks exactly that one; the other PCRs stay as they
+ were; a refusal marks nothing
* - ``chain-events``
- ``chain_upatch_tag()``, ``chain_upatch_event()``,
``chain_key_event()``, ``chain_tree_event()``, ``chain_fold()``,
diff --git a/testing/proofs/cbmc/attest-pcr.c b/testing/proofs/cbmc/attest-pcr.c
index 84cff844..2763d034 100644
--- a/testing/proofs/cbmc/attest-pcr.c
+++ b/testing/proofs/cbmc/attest-pcr.c
@@ -4,8 +4,8 @@
*
* on_pcr() of util/attest.c, which stores each PCR value of a target's
* evidence, for every index and value text: it stores only a 64-digit hex
- * value under one of the 24 PCRs and marks that one, and a refusal marks
- * nothing.
+ * value, as the bytes it spells, under one of the 24 PCRs, marks that one
+ * and leaves the others, and a refusal marks nothing.
*/
#include "proof.h"
@@ -21,9 +21,15 @@ static char any_char(void)
return c;
}
+static __u8 hex_value(char hi, char lo)
+{
+ return hex_nibble(hi) << 4 | hex_nibble(lo);
+}
+
void harness(void)
{
- __u32 had;
+ __u8 other_was[32];
+ __u32 had, other;
__s64 index;
size_t i;
@@ -31,6 +37,9 @@ void harness(void)
p.pcr_index = index;
for (i = 0; i + 1 < sizeof(p.pcr_value_hex); i++)
p.pcr_value_hex[i] = any_char();
+ __CPROVER_assume(other < 24 && other != index);
+ for (i = 0; i < 32; i++)
+ p.pcrs[other][i] = other_was[i];
if (on_pcr(&p)) {
__CPROVER_assert(p.pcr_have == had, "a refusal marks nothing");
return;
@@ -40,4 +49,12 @@ void harness(void)
"one of the 24 PCRs marked");
__CPROVER_assert(strlen(p.pcr_value_hex) == 64,
"a SHA-256 value in hex");
+ for (i = 0; i < 32; i++) {
+ __CPROVER_assert(p.pcrs[index][i] ==
+ hex_value(p.pcr_value_hex[2 * i],
+ p.pcr_value_hex[2 * i + 1]),
+ "stored under its index, as its digits spell");
+ __CPROVER_assert(p.pcrs[other][i] == other_was[i],
+ "the other PCRs as they were");
+ }
}
diff --git a/testing/proofs/cbmc/proofs.list b/testing/proofs/cbmc/proofs.list
index ff76a3d1..c7e2e96a 100644
--- a/testing/proofs/cbmc/proofs.list
+++ b/testing/proofs/cbmc/proofs.list
@@ -46,7 +46,7 @@ tpm-digest --unwind 2 --object-bits 12
tpm-kdf --unwind 3 --unwindset strlen.0:68 --object-bits 12 -DLABEL_MAX=66 -DOUT_MAX=64
attest-fields --unwind 18 LEN=0-16
attest-replay-model --slice-formula --unwind 20 --unwindset memneq_explicit.0:33,strlen.0:70 LEN=1-3
-attest-pcr --unwind 1 --unwindset harness.0:65,hex_decode.0:33,strlen.0:66 --no-array-field-sensitivity
+attest-pcr --unwind 1 --unwindset harness.0:65,harness.1:33,harness.2:33,hex_decode.0:33,strlen.0:66 --no-array-field-sensitivity
eventlog-records --unwind 34 LEN=0-32
config-image --unwind 6 --unwindset memcmp.0:89,harness.0:33 LEN=0,511,512,4096
config-auth --unwind 18 LEN=0-16