Skip to content

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.md
index 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.
```sh
make proofs # every proof
make 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 from
variables 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.md
index 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's
directory (`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 check
parsers and emitters for every input within a bound. A change to code a
proof covers runs it, and a new parser gets one where CBMC can carry
it; the `proofs` skill says how.
diff --git a/Documentation/contribute/testing/proof-coverage.rst b/Documentation/contribute/testing/proof-coverage.rst
index 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 code
each one proves, the inputs it covers and the properties it states, and
the parsers no proof covers yet. :doc:`proofs` explains how to run and
write them. Every proof also shows that the code reads and writes nothing
diff --git a/Documentation/contribute/testing/proofs.rst b/Documentation/contribute/testing/proofs.rst
index 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 input
within its bounds: `CBMC <https://www.cprover.org/cbmc/>`_ turns shirudo's
C and a harness into a formula and asks a SAT solver for an input that
breaks 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 failed
check: the input that breaks it and the steps that lead there.
@@ -64,7 +64,7 @@ Run the proofs
Write 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 the
source file it proves, so that it reaches static functions too, and
defines ``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 proof
every section inside it. A check that restates the implementation
proves 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 CBMC
options:
- ``--unwind <n>`` for loops, ``--unwindset <loop>:<n>`` for one loop,
diff --git a/Makefile b/Makefile
index 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 testing
proofs:
- $(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.c
similarity index 98%
rename from testing/proofs/hex.c
rename to testing/proofs/cbmc/hex.c
index 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 4
diff --git a/testing/proofs/io-lines.c b/testing/proofs/cbmc/io-lines.c
similarity index 95%
rename from testing/proofs/io-lines.c
rename to testing/proofs/cbmc/io-lines.c
index 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 8
diff --git a/testing/proofs/proof.h b/testing/proofs/cbmc/proof.h
similarity index 100%
rename from testing/proofs/proof.h
rename to testing/proofs/cbmc/proof.h
diff --git a/testing/proofs/proofs.list b/testing/proofs/cbmc/proofs.list
similarity index 100%
rename from testing/proofs/proofs.list
rename to testing/proofs/cbmc/proofs.list
diff --git a/testing/proofs/run.sh b/testing/proofs/cbmc/run.sh
similarity index 94%
rename from testing/proofs/run.sh
rename to testing/proofs/cbmc/run.sh
index 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 ]; then
fi
cd "$(dirname "$0")"
-root=$(cd ../.. && pwd)
+root=$(cd ../../.. && pwd)
command -v cbmc >/dev/null 2>&1 || {
printf 'proofs: cbmc not found; install cbmc\n' >&2
exit 2
diff --git a/testing/proofs/string-copy.c b/testing/proofs/cbmc/string-copy.c
similarity index 96%
rename from testing/proofs/string-copy.c
rename to testing/proofs/cbmc/string-copy.c
index 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 8
diff --git a/testing/proofs/string-number.c b/testing/proofs/cbmc/string-number.c
similarity index 98%
rename from testing/proofs/string-number.c
rename to testing/proofs/cbmc/string-number.c
index 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 0x5a5a5a5a5a5a5a5aULL
diff --git a/testing/proofs/string-sanitize.c b/testing/proofs/cbmc/string-sanitize.c
similarity index 98%
rename from testing/proofs/string-sanitize.c
rename to testing/proofs/cbmc/string-sanitize.c
index 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.c
similarity index 97%
rename from testing/proofs/string-utf8.c
rename to testing/proofs/cbmc/string-utf8.c
index 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.c
similarity index 97%
rename from testing/proofs/upatch-header.c
rename to testing/proofs/cbmc/upatch-header.c
index 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)
{