eBPF-based security platform
proofs: take attest-name-digest to the 256-byte limit of a name
Daniel Borkmann92e5aa60689f
diff --git a/Documentation/contribute/testing/proof-coverage.rst b/Documentation/contribute/testing/proof-coverage.rstindex 601b3d1e..6bec9974 100644--- a/Documentation/contribute/testing/proof-coverage.rst+++ b/Documentation/contribute/testing/proof-coverage.rst@@ -107,9 +107,15 @@ or shorter, and "lengths 0 to 6" every input of each of those lengths.* - ``attest-name-digest``- ``attest_parse_name_digest()``- Lengths 64 to 70- - Accepted exactly when a name of a byte or more runs to the first+ - Accepted exactly when a name of 1 to 256 bytes runs to the firstequals sign and 64 hex digits follow, into that name and theirvalue+ * - ``attest-name-digest-long``+ - ``attest_parse_name_digest()``+ - Lengths 321 and 322: any 8 bytes, then letters to an equals sign+ and any 64 bytes+ - The rule of ``attest-name-digest`` at the name's limit of 256+ bytes* - ``paths-bpffs-name``- ``upatch_bpffs_name()``, ``upatch_name_from_bpffs()``- Names up to 4 bytes, pin names up to 8diff --git a/testing/proofs/cbmc/attest-name-digest-long.c b/testing/proofs/cbmc/attest-name-digest-long.cnew file mode 100644index 00000000..c04b953d--- /dev/null+++ b/testing/proofs/cbmc/attest-name-digest-long.c@@ -0,0 +1,9 @@+// SPDX-License-Identifier: BSD-2-Clause+/*+ * Copyright (c) 2026 Authors of shirudo+ *+ * attest-name-digest at the 256-byte limit of a name, with the bounds of+ * its own that strings of 321 and 322 bytes need.+ */++#include "attest-name-digest.c"diff --git a/testing/proofs/cbmc/attest-name-digest.c b/testing/proofs/cbmc/attest-name-digest.cindex 7174357f..ae418b2f 100644--- a/testing/proofs/cbmc/attest-name-digest.c+++ b/testing/proofs/cbmc/attest-name-digest.c@@ -3,10 +3,11 @@* Copyright (c) 2026 Authors of shirudo** attest_parse_name_digest() of util/attest.c, which reads attest- * predict's --expect and --event values, on every string of LEN bytes:- * accepted exactly when a name of one byte or more runs up to the first- * equals sign and 64 hex digits follow it, into that name and the value- * of those digits.+ * predict's --expect and --event values, on every string of LEN bytes,+ * or of LEN bytes past the name limit whose middle is fixed: accepted+ * exactly when a name of 1 to 256 bytes runs up to the first equals sign+ * and 64 hex digits follow it, into that name and the value of those+ * digits.*/#include <stdbool.h>@@ -27,6 +28,26 @@ static int digit(char c)return -1;}+/*+ * A string longer than SYMBOLIC bytes, there to reach the name limit, is+ * any 8 bytes, letters up to an equals sign 65 bytes from its end, and+ * any 64 bytes after it.+ */+#define SYMBOLIC 70++static char *any_spec(void)+{+ char *s = any_bytes(LEN + 1);+ size_t i;++ if (LEN > SYMBOLIC) {+ for (i = 8; i < LEN - 65; i++)+ s[i] = 'n';+ s[LEN - 65] = '=';+ }+ return s;+}+void harness(void){char name[UPATCH_NAME_MAX + 1];@@ -36,7 +57,7 @@ void harness(void)char *s;int ret;- s = any_bytes(LEN + 1);+ s = any_spec();__CPROVER_assume(!s[LEN] && strnlen(s, LEN) == LEN);ret = attest_parse_name_digest(s, name, digest);for (i = LEN; i > 0; i--)@@ -45,9 +66,10 @@ void harness(void)for (i = eq + 1; i < LEN; i++)if (digit(s[i]) < 0)hex = false;- ok = eq < LEN && eq >= 1 && LEN - eq - 1 == 64 && hex;+ ok = eq < LEN && eq >= 1 && eq <= UPATCH_NAME_MAX &&+ LEN - eq - 1 == 64 && hex;__CPROVER_assert(!ret == ok,- "a name up to the first equals sign, then 64 digits");+ "a name of 1 to 256 bytes, an equals sign, 64 digits");if (ret)return;__CPROVER_assert(strnlen(name, sizeof(name)) == eq &&diff --git a/testing/proofs/cbmc/proofs.list b/testing/proofs/cbmc/proofs.listindex 7c5b20b7..a08e88e4 100644--- a/testing/proofs/cbmc/proofs.list+++ b/testing/proofs/cbmc/proofs.list@@ -10,6 +10,7 @@ io-lines --unwind 10io-append --unwind 12 LEN=0-6attest-pcrs --unwind 9attest-name-digest --unwind 72 LEN=64-70+attest-name-digest-long --unwind 72 --unwindset any_spec.0:323,harness.0:323,harness.1:323,strnlen.0:323,strchr.0:323,strlen.0:323,memcmp.0:323 LEN=321,322paths-bpffs-name --unwind 18upatch-header --unwind 2 --unwindset memchr.0:257upatch-decoders --unwind 2 --unwindset memchr.0:65,parse_decoders.0:3,harness.0:3