Skip to content

eBPF-based security platform

attest: compare a config history's TPM boot by its reset count

Daniel Borkmann2e40ba21fc8c
diff --git a/Documentation/contribute/testing/proof-coverage.rst b/Documentation/contribute/testing/proof-coverage.rst
index a30e047e..4f78cae6 100644
--- a/Documentation/contribute/testing/proof-coverage.rst
+++ b/Documentation/contribute/testing/proof-coverage.rst
@@ -921,7 +921,7 @@ or shorter, and "lengths 0 to 6" every input of each of those lengths.
every quote mask, TPM boot, PCR value and expectation; SHA-256 as
any digest or failure
- Passes exactly when the PCR is one from 0 to 15 but 9 and 11,
- quoted and the expected one, the TPM boot the quote's, the events
+ quoted and the expected one, the reset count the quote's, the events
one boot event then updates in sequence, the quoted value the
initial one extended by each event's digest in order, and the last
root the expected one; a digest hashes the tag, the kind and the
@@ -930,7 +930,7 @@ or shorter, and "lengths 0 to 6" every input of each of those lengths.
- ``config_evidence_collect()``, ``collect_event()``
- Every journal of 0 to 2 records and every active selection, the
journal's reader a stub that may fail; SHA-256 as any result
- - Exports exactly the records of the selection's TPM boot, in order,
+ - Exports exactly the records of the selection's reset count, in order,
when they are on its PCR from its initial value, one boot event
then updates in sequence, and end at the selection; a refusal
returns nothing, with nothing left allocated
diff --git a/Documentation/internals/measurement-register.rst b/Documentation/internals/measurement-register.rst
index 270968b0..b1b88b8f 100644
--- a/Documentation/internals/measurement-register.rst
+++ b/Documentation/internals/measurement-register.rst
@@ -578,11 +578,14 @@ first event of a TPM boot records the PCR's value before it as
records the sequence, the TPM's reset and restart counts and the root of
each event. :doc:`config-images` explains activation.
-Evidence includes the config PCR in the quote and the config history.
-``verify`` with ``--expect-config-root`` and ``--expect-config-pcr``
-derives each event digest, requires one boot event followed by updates in
-sequence for the quoted TPM boot, a replay from ``initial_pcr`` that
-reaches the quoted PCR value, and the expected root as the selection.
+Evidence includes the config PCR in the quote and the config history:
+the events of the TPM's reset count, which a resume or a TPM restart
+keeps. ``verify`` with ``--expect-config-root`` and
+``--expect-config-pcr`` derives each event digest, requires one boot
+event followed by updates in sequence for the quote's reset count, a
+replay from ``initial_pcr`` that reaches the quoted PCR value, and the
+expected root as the selection. The restart count the history carries is
+not compared.
Limits
------
diff --git a/testing/functional/tpm/t4004-config-attest.sh b/testing/functional/tpm/t4004-config-attest.sh
index d65a3a05..b064fbba 100755
--- a/testing/functional/tpm/t4004-config-attest.sh
+++ b/testing/functional/tpm/t4004-config-attest.sh
@@ -136,7 +136,7 @@ def flip_hex(value):
save("event-root", lambda d: event(d).__setitem__("root_hash", flip_hex(event(d)["root_hash"])))
for key in ("sequence", "kind"):
save("event-" + key, lambda d, key=key: event(d).__setitem__(key, event(d)[key] + 1))
-for key in ("schema", "reset_count", "restart_count", "pcr"):
+for key in ("schema", "reset_count", "pcr"):
save("meta-" + key, lambda d, key=key: d["config"].__setitem__(key, d["config"][key] + 1))
save("initial-pcr", lambda d: d["config"].__setitem__("initial_pcr", "55" * 32))
save("missing-field", lambda d: event(d).pop("root_hash"))
diff --git a/testing/helper/test-config-attest.c b/testing/helper/test-config-attest.c
index 81b3ab45..cbda3c66 100644
--- a/testing/helper/test-config-attest.c
+++ b/testing/helper/test-config-attest.c
@@ -131,7 +131,7 @@ int main(int argc, char **argv)
__u8 pcrs[24][32] = {}, root[32];
const char *reason = NULL;
const __u8 *expected;
- __u32 mask, reset, restart;
+ __u32 mask, reset;
char *document = NULL;
size_t length = 0;
int pcr, ret;
@@ -161,11 +161,9 @@ int main(int argc, char **argv)
}
mask = 1u << (pcr < 0 ? config.pcr : (__u32)pcr);
reset = strtoul(argv[5], NULL, 10);
- restart = strtoul(argv[6], NULL, 10);
expected = !strcmp(argv[3], "-") ? NULL : root;
- ret = config_evidence_verify(&config, mask, reset,
- restart, pcrs, expected,
- pcr, &reason);
+ ret = config_evidence_verify(&config, mask, reset, pcrs,
+ expected, pcr, &reason);
} else if (strcmp(argv[1], "parse")) {
ret = -EINVAL;
}
diff --git a/testing/proofs/cbmc/config-evidence-collect.c b/testing/proofs/cbmc/config-evidence-collect.c
index 39f26ef2..b5b023cb 100644
--- a/testing/proofs/cbmc/config-evidence-collect.c
+++ b/testing/proofs/cbmc/config-evidence-collect.c
@@ -93,10 +93,10 @@ static bool blank(const struct config_evidence *view)
!view->present;
}
+/* A TPM boot is its reset count: a restart or a resume goes on in it. */
static bool this_boot(const struct config_update_record *record)
{
- return record->reset_count == selection->reset_count &&
- record->restart_count == selection->restart_count;
+ return record->reset_count == selection->reset_count;
}
/* On the selection's PCR, from its initial value, a sequence in a __s64. */
diff --git a/testing/proofs/cbmc/config-evidence-verify.c b/testing/proofs/cbmc/config-evidence-verify.c
index aca46470..0efb1a99 100644
--- a/testing/proofs/cbmc/config-evidence-verify.c
+++ b/testing/proofs/cbmc/config-evidence-verify.c
@@ -163,7 +163,7 @@ static void replayed(void)
static void verified(void)
{
bool holds_events, config_pcr, approved, have_root;
- __u32 quote_mask, reset, restart;
+ __u32 quote_mask, reset;
const __u8 *expected_root = NULL;
struct config_evidence view;
const char *reason = NULL;
@@ -173,7 +173,7 @@ static void verified(void)
any_view(&view, &holds_events);
if (have_root)
expected_root = any_bytes(32);
- ret = config_evidence_verify(&view, quote_mask, reset, restart, pcrs,
+ ret = config_evidence_verify(&view, quote_mask, reset, pcrs,
expected_root, expected_pcr, &reason);
__CPROVER_assert(reason, "a reason either way");
if (!view.present) {
@@ -187,7 +187,6 @@ static void verified(void)
approved = config_pcr && (quote_mask >> view.pcr & 1) &&
(expected_pcr < 0 || view.pcr == (__u32)expected_pcr) &&
view.reset_count == reset &&
- view.restart_count == restart &&
!(expected_root && expected_pcr < 0);
if (!approved) {
__CPROVER_assert(ret,
diff --git a/util/attest.c b/util/attest.c
index 6d596e21..71c97d86 100644
--- a/util/attest.c
+++ b/util/attest.c
@@ -235,7 +235,6 @@ int attest_evidence_config(const __u8 *nonce, size_t nonce_len,
(tpm_attest_parse(quote.attest, quote.attest_len,
&quoted) ||
quoted.reset_count != config.reset_count ||
- quoted.restart_count != config.restart_count ||
memcmp(values[config.pcr],
config.value, 32))) {
ret = -EUCLEAN;
@@ -1130,7 +1129,6 @@ static void verify_config(struct verify *v)
pcr = expect->have_config_pcr ? (int)expect->config_pcr : -1;
ret = config_evidence_verify(&v->config, quote->pcr_mask,
quote->reset_count,
- quote->restart_count,
v->p->pcrs, root, pcr,
&reason);
say(rep, !ret, "config: %s", reason);
diff --git a/util/config_attest.c b/util/config_attest.c
index 01dc33f3..579dd915 100644
--- a/util/config_attest.c
+++ b/util/config_attest.c
@@ -73,8 +73,7 @@ static int collect_event(const struct config_update_record *record,
struct config_evidence_event event = {};
struct config_evidence *view = opaque;
- if (record->reset_count != view->reset_count ||
- record->restart_count != view->restart_count)
+ if (record->reset_count != view->reset_count)
return 0;
if (record->pcr != view->pcr || record->sequence > INT64_MAX ||
memcmp(record->initial_pcr, view->initial_pcr, 32))
@@ -262,7 +261,7 @@ fail:
int config_evidence_verify(const struct config_evidence *view,
__u32 quote_mask, __u32 reset,
- __u32 restart, const __u8 pcrs[24][32],
+ const __u8 pcrs[24][32],
const __u8 *expected_root,
int expected_pcr, const char **reason)
{
@@ -280,7 +279,7 @@ int config_evidence_verify(const struct config_evidence *view,
*reason = "config PCR is unquoted or unexpected";
return -EKEYREJECTED;
}
- if (view->reset_count != reset || view->restart_count != restart) {
+ if (view->reset_count != reset) {
*reason = "config history belongs to another TPM boot";
return -EKEYREJECTED;
}
diff --git a/util/config_attest.h b/util/config_attest.h
index ef424986..d905c509 100644
--- a/util/config_attest.h
+++ b/util/config_attest.h
@@ -43,7 +43,7 @@ int config_evidence_parse(const char *evidence, size_t length,
struct config_evidence *out);
int config_evidence_verify(const struct config_evidence *view,
__u32 quote_mask, __u32 reset,
- __u32 restart, const __u8 pcrs[24][32],
+ const __u8 pcrs[24][32],
const __u8 *expected_root,
int expected_pcr, const char **reason);