eBPF-based security platform
testing: move the CBMC proofs to testing/proofs/cbmc
Daniel Borkmannd3793a06a657
diff --git a/.agents/skills/proofs/SKILL.md b/.agents/skills/proofs/SKILL.mdindex 7843463e..4f7dfa05 100644--- a/.agents/skills/proofs/SKILL.md+++ b/.agents/skills/proofs/SKILL.md@@ -1,6 +1,6 @@---name: proofs-description: Run, write and debug shirudo's CBMC proofs under testing/proofs, which check its parsers and emitters for every input within a bound. Covers make proofs, the harness and proofs.list conventions, choosing properties and bounds, keeping a proof fast and within memory, and telling a real bug from a harness error. Use when changing code a proof covers, when adding a parser or emitter, when a proof fails, or when asked to prove code correct.+description: Run, write and debug shirudo's CBMC proofs under testing/proofs/cbmc, which check its parsers and emitters for every input within a bound. Covers make proofs, the harness and proofs.list conventions, choosing properties and bounds, keeping a proof fast and within memory, and telling a real bug from a harness error. Use when changing code a proof covers, when adding a parser or emitter, when a proof fails, or when asked to prove code correct.---# Proofs@@ -16,7 +16,7 @@ page in the same commit.```shmake proofs # every proofmake proofs PROOFS="string-number hex" # some of them-testing/proofs/run.sh -v <proof> # whole output and traces+testing/proofs/cbmc/run.sh -v <proof> # whole output and traces```Cap the memory of a long run, `ulimit -v 24000000` in the shell that@@ -25,8 +25,8 @@ to wait for.## Write-- `testing/proofs/<name>.c` includes `"proof.h"` and the `.c` it proves,- and defines `harness()`. Inputs come from `any_bytes(n)` and from+- `testing/proofs/cbmc/<name>.c` includes `"proof.h"` and the `.c` it+ proves, and defines `harness()`. Inputs come from `any_bytes(n)` and fromvariables left uninitialized; `__CPROVER_assume()` bounds them and`__CPROVER_assert(cond, "what holds")` states each property.- State the contract, not the implementation: which inputs are accepted,diff --git a/AGENTS.md b/AGENTS.mdindex c98d85a6..1a48c899 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -306,7 +306,7 @@ one usually still compiles and passes tests.fuzz target, and a shell test `t<F><K><NN>` lives in its family'sdirectory (`Documentation/contribute/testing/testing.rst`). The`testing` and `fuzz-target` skills say how to run and add them.-- `make proofs` runs the CBMC proofs of `testing/proofs/`, which check+- `make proofs` runs the CBMC proofs of `testing/proofs/cbmc/`, which checkparsers and emitters for every input within a bound. A change to code aproof covers runs it, and a new parser gets one where CBMC can carryit; the `proofs` skill says how.diff --git a/Documentation/contribute/testing/proof-coverage.rst b/Documentation/contribute/testing/proof-coverage.rstindex 6997f090..df0c08ce 100644--- a/Documentation/contribute/testing/proof-coverage.rst+++ b/Documentation/contribute/testing/proof-coverage.rst@@ -8,7 +8,7 @@Proof coverage==============-This page lists the CBMC proofs under :src:`testing/proofs/`, the code+This page lists the CBMC proofs under :src:`testing/proofs/cbmc/`, the codeeach one proves, the inputs it covers and the properties it states, andthe parsers no proof covers yet. :doc:`proofs` explains how to run andwrite them. Every proof also shows that the code reads and writes nothingdiff --git a/Documentation/contribute/testing/proofs.rst b/Documentation/contribute/testing/proofs.rstindex 00f7b5a9..5172c197 100644--- a/Documentation/contribute/testing/proofs.rst+++ b/Documentation/contribute/testing/proofs.rst@@ -9,7 +9,7 @@ Prove code with CBMC====================A test checks the inputs someone thought of, and a fuzz target the ones it-happens to find. A proof under :src:`testing/proofs/` checks every input+happens to find. A proof under :src:`testing/proofs/cbmc/` checks every inputwithin its bounds: `CBMC <https://www.cprover.org/cbmc/>`_ turns shirudo'sC and a harness into a formula and asks a SAT solver for an input thatbreaks a property. When none exists, the property holds for all of them.@@ -56,7 +56,7 @@ Run the proofs.. code-block:: console- $ testing/proofs/run.sh -v string-number+ $ testing/proofs/cbmc/run.sh -v string-number``-v`` prints CBMC's whole output, with the trace of each failedcheck: the input that breaks it and the steps that lead there.@@ -64,7 +64,7 @@ Run the proofsWrite a proof--------------1. Write ``testing/proofs/<name>.c``. It includes ``proof.h`` and the+1. Write ``testing/proofs/cbmc/<name>.c``. It includes ``proof.h`` and thesource file it proves, so that it reaches static functions too, anddefines ``harness()``, which CBMC runs with every input at once.``any_bytes(n)`` gives ``n`` bytes of any contents, and a variable@@ -77,7 +77,7 @@ Write a proofevery section inside it. A check that restates the implementationproves nothing about it.-3. Add the proof to :src:`testing/proofs/proofs.list` with its CBMC+3. Add the proof to :src:`testing/proofs/cbmc/proofs.list` with its CBMCoptions:- ``--unwind <n>`` for loops, ``--unwindset <loop>:<n>`` for one loop,diff --git a/Makefile b/Makefileindex c7a7d1ca..b75504ea 100644--- a/Makefile+++ b/Makefile@@ -91,7 +91,7 @@ help:' Install roles: make install-target, make install-operator' \' Package: make -C packaging help' \' Tests: make tests (all of them), make -C testing help' \- ' Proofs: make proofs [PROOFS=<proof>...] (CBMC, testing/proofs)' \+ ' Proofs: make proofs [PROOFS=<proof>...] (CBMC, testing/proofs/cbmc)' \' Documentation: make docs (render and serve), make -C Documentation help' \' Watch lists: make -C upatches/kernel-obs lists'@@ -108,7 +108,7 @@ tests:+$(Q)$(MAKE) -C testingproofs:- $(Q)testing/proofs/run.sh $(PROOFS)+ $(Q)testing/proofs/cbmc/run.sh $(PROOFS)# config.mk is regenerated by Makefile.config from the host's pkg-config# state. Caches results until `make distclean`.diff --git a/testing/proofs/hex.c b/testing/proofs/cbmc/hex.csimilarity index 98%rename from testing/proofs/hex.crename to testing/proofs/cbmc/hex.cindex de8c2049..244b1b43 100644--- a/testing/proofs/hex.c+++ b/testing/proofs/cbmc/hex.c@@ -11,7 +11,7 @@#include <stdbool.h>#include "proof.h"-#include "../../util/hex.c"+#include "../../../util/hex.c"#define LEN_MAX 4diff --git a/testing/proofs/io-lines.c b/testing/proofs/cbmc/io-lines.csimilarity index 95%rename from testing/proofs/io-lines.crename to testing/proofs/cbmc/io-lines.cindex b168f8d3..1f317a4d 100644--- a/testing/proofs/io-lines.c+++ b/testing/proofs/cbmc/io-lines.c@@ -8,7 +8,7 @@*/#include "proof.h"-#include "../../util/io.c"+#include "../../../util/io.c"#define LEN_MAX 8diff --git a/testing/proofs/proof.h b/testing/proofs/cbmc/proof.hsimilarity index 100%rename from testing/proofs/proof.hrename to testing/proofs/cbmc/proof.hdiff --git a/testing/proofs/proofs.list b/testing/proofs/cbmc/proofs.listsimilarity index 100%rename from testing/proofs/proofs.listrename to testing/proofs/cbmc/proofs.listdiff --git a/testing/proofs/run.sh b/testing/proofs/cbmc/run.shsimilarity index 94%rename from testing/proofs/run.shrename to testing/proofs/cbmc/run.shindex 2ab60b33..16396323 100755--- a/testing/proofs/run.sh+++ b/testing/proofs/cbmc/run.sh@@ -2,7 +2,7 @@# SPDX-License-Identifier: BSD-2-Clause# Copyright (c) 2026 Authors of shirudo#-# testing/proofs/run.sh -- check with CBMC that shirudo's parsers keep the+# testing/proofs/cbmc/run.sh -- check with CBMC that shirudo's parsers keep the# properties the harnesses in this directory state, for every input within# the bounds each harness names, and fail when one does not hold. Each# harness defines harness() and includes the source it proves; proofs.list@@ -11,7 +11,7 @@# has to keep symbolic. -v prints the whole CBMC output and the trace of a# failed check.#-# testing/proofs/run.sh [-v] [<proof>...]+# testing/proofs/cbmc/run.sh [-v] [<proof>...]set -eu@@ -22,7 +22,7 @@ if [ "${1:-}" = -v ]; thenficd "$(dirname "$0")"-root=$(cd ../.. && pwd)+root=$(cd ../../.. && pwd)command -v cbmc >/dev/null 2>&1 || {printf 'proofs: cbmc not found; install cbmc\n' >&2exit 2diff --git a/testing/proofs/string-copy.c b/testing/proofs/cbmc/string-copy.csimilarity index 96%rename from testing/proofs/string-copy.crename to testing/proofs/cbmc/string-copy.cindex a50b3618..05c0d2f5 100644--- a/testing/proofs/string-copy.c+++ b/testing/proofs/cbmc/string-copy.c@@ -11,7 +11,7 @@#include <stdbool.h>#include "proof.h"-#include "../../util/string.c"+#include "../../../util/string.c"#define LEN_MAX 8diff --git a/testing/proofs/string-number.c b/testing/proofs/cbmc/string-number.csimilarity index 98%rename from testing/proofs/string-number.crename to testing/proofs/cbmc/string-number.cindex 5ca24d9f..4f9ab935 100644--- a/testing/proofs/string-number.c+++ b/testing/proofs/cbmc/string-number.c@@ -11,7 +11,7 @@#include <stdbool.h>#include "proof.h"-#include "../../util/string.c"+#include "../../../util/string.c"#define LEN_MAX 22 /* past the 20 digits of the largest __u64 */#define UNSET 0x5a5a5a5a5a5a5a5aULLdiff --git a/testing/proofs/string-sanitize.c b/testing/proofs/cbmc/string-sanitize.csimilarity index 98%rename from testing/proofs/string-sanitize.crename to testing/proofs/cbmc/string-sanitize.cindex 5ac8565e..648620b8 100644--- a/testing/proofs/string-sanitize.c+++ b/testing/proofs/cbmc/string-sanitize.c@@ -12,7 +12,7 @@#include <stdbool.h>#include "proof.h"-#include "../../util/string.c"+#include "../../../util/string.c"static bool in(__u8 c, __u8 lo, __u8 hi){diff --git a/testing/proofs/string-utf8.c b/testing/proofs/cbmc/string-utf8.csimilarity index 97%rename from testing/proofs/string-utf8.crename to testing/proofs/cbmc/string-utf8.cindex 2cf175c9..f0b81418 100644--- a/testing/proofs/string-utf8.c+++ b/testing/proofs/cbmc/string-utf8.c@@ -10,7 +10,7 @@#include <stdbool.h>#include "proof.h"-#include "../../util/string.c"+#include "../../../util/string.c"static bool in(__u8 c, __u8 lo, __u8 hi){diff --git a/testing/proofs/upatch-header.c b/testing/proofs/cbmc/upatch-header.csimilarity index 97%rename from testing/proofs/upatch-header.crename to testing/proofs/cbmc/upatch-header.cindex f5aec63e..87f9ec70 100644--- a/testing/proofs/upatch-header.c+++ b/testing/proofs/cbmc/upatch-header.c@@ -9,7 +9,7 @@*/#include "proof.h"-#include "../../util/upatch.c"+#include "../../../util/upatch.c"static bool inside(__u32 off, __u32 len, size_t n){