eBPF-based security platform
ci: run the clang sanitizers and AFL++ only on pushes to main
Martynas Pumputisa21aa82b785b
diff --git a/.agents/skills/pre-submit/SKILL.md b/.agents/skills/pre-submit/SKILL.mdindex 542b0a9b..d1ec9e94 100644--- a/.agents/skills/pre-submit/SKILL.md+++ b/.agents/skills/pre-submit/SKILL.md@@ -99,6 +99,10 @@ checks: read it against the change. A proof out of step with the codeis a security bug, as the `security-audit` skill has it; the `proofs`skill says how to fix one.+The clang and TSan legs of the `Sanitizers` workflow and its `afl-fuzz`+job also run only after a push to main, so the clang and TSan runs+above are the only ones a series gets before it lands.+## Fixing a commit of the seriesFold a fix into the commit it belongs to rather than adding one on top:diff --git a/.agents/skills/testing/SKILL.md b/.agents/skills/testing/SKILL.mdindex 984f0c4e..646b5264 100644--- a/.agents/skills/testing/SKILL.md+++ b/.agents/skills/testing/SKILL.md@@ -20,8 +20,8 @@ make -C testing unit/<suite> # one unit suitemake -C testing functional/<family> # one family, its VM tests toomake tests VM=0 # without the target testsmake tests BACKEND=0 # without the backend's SQL tests-make tests VM=0 BACKEND=0 SANITIZE=address,undefined # CI: once with gcc, once with clang-make tests VM=0 BACKEND=0 SANITIZE=thread CC=clang # CI: TSan, for threads and handlers+make tests VM=0 BACKEND=0 SANITIZE=address,undefined # CI: gcc on a PR, clang too on main+make tests VM=0 BACKEND=0 SANITIZE=thread CC=clang # CI on main: TSan, for threads and handlerssh .github/scripts/msan-deps.sh # MSan: instrumented libraries once,sh .github/scripts/msan-tests.sh [60] # then unit and fuzz from a clean treemake -C testing fuzz [FUZZ_SECONDS=60] [FUZZERS=<target>...]diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.ymlindex f4aadead..2f662969 100644--- a/.github/workflows/sanitizers.yml+++ b/.github/workflows/sanitizers.yml@@ -25,22 +25,20 @@ jobs:# ThreadSanitizer finds data races and, in a signal handler, a call# that is not async-signal-safe or a changed errno. shirudo starts no# thread and installs no handler today; the leg is there for the first.+ # A pull request runs the gcc leg alone, which covers the same suite in+ # less time; the push to main runs the clang ones as well.tests:- name: ${{ matrix.name }} (${{ matrix.compiler }})+ name: ${{ matrix.sanitize == 'thread' && 'TSan' || 'ASan+UBSan' }} (${{ matrix.compiler }})runs-on: ubuntu-lateststrategy:fail-fast: falsematrix:- include:- - name: ASan+UBSan- sanitize: address,undefined- compiler: gcc- - name: ASan+UBSan- sanitize: address,undefined- compiler: clang- - name: TSan+ compiler: [gcc, clang]+ sanitize: ['address,undefined', thread]+ exclude:+ - compiler: gccsanitize: thread- compiler: clang+ - compiler: ${{ github.event_name == 'pull_request' && 'clang' || '' }}env:SHIRUDO_SKIP_TREE_CHECKS: >-${{ (github.event_name == 'pull_request' ||@@ -128,8 +126,9 @@ jobs:# The unit tests link the util objects, whose build needs the BTF of# a signed-BPF capable bpf-next kernel, as the other jobs do. A push- # or a pull request gets a minute per fuzz target, a run by hand- # ten.+ # gets a minute per fuzz target and a run by hand ten. A pull request+ # gets ten seconds, in which a target still runs every seed under+ # MSan; the libFuzzer job fuzzes it for the minute.- name: Build under MSan and run the unit tests and fuzz targets in LVH VMuses: ./.github/actions/lvhwith:@@ -173,7 +172,7 @@ jobs:sh .github/scripts/msan-deps.shsh .github/scripts/msan-tests.sh \- ${{ github.event_name == 'workflow_dispatch' && 600 || 60 }}+ ${{ github.event_name == 'workflow_dispatch' && 600 || github.event_name == 'pull_request' && 10 || 60 }}- name: Save the MemorySanitizer librariesif: always() && steps.msan-deps.outputs.cache-hit != 'true' && hashFiles('build/msan-deps/lib/libcrypto.so') != ''@@ -262,12 +261,14 @@ jobs:if-no-files-found: ignore# The same targets under AFL++, whose comparison logging and mutators- # find inputs libFuzzer does not, for a minute a target on a push or a- # pull request and ten by hand. It shares the corpus with the libFuzzer- # job through the cache: each starts from what the newest run of- # either kept on main.+ # find inputs libFuzzer does not, for a minute a target on a push and+ # ten by hand. A pull request leaves it to main: the libFuzzer and MSan+ # jobs fuzz the same targets there. It shares the corpus with the+ # libFuzzer job through the cache: each starts from what the newest run+ # of either kept on main.afl-fuzz:name: afl-fuzz+ if: github.event_name != 'pull_request'runs-on: ubuntu-latesttimeout-minutes: 180diff --git a/Documentation/contribute/testing/testing.rst b/Documentation/contribute/testing/testing.rstindex 00b5cd65..7c3d66dc 100644--- a/Documentation/contribute/testing/testing.rst+++ b/Documentation/contribute/testing/testing.rst@@ -418,14 +418,15 @@ Run under the sanitizers``SANITIZE`` instruments the host binaries and the test helpers. The BPFobjects are unaffected. Recovery is off, so every report fails the run.-CI runs the same with gcc and with clang.+CI runs the same with gcc on each pull request, and with gcc and with+clang on each push to ``main``.``SANITIZE=thread`` runs the same tests under ThreadSanitizer, whichreports data races and, in a signal handler, a call that is notasync-signal-safe or a changed ``errno``. shirudo starts no thread andinstalls no signal handler, so it reports nothing today; the ``TSan``-leg of the ``Sanitizers`` workflow runs it with clang so that the first-one added is checked.+leg of the ``Sanitizers`` workflow runs it with clang on each push to+``main`` so that the first one added is checked.These three CI jobs install dependencies with:src:`.github/scripts/sanitizer-deps.sh` inside a disposable LVH guest.@@ -471,8 +472,9 @@ leaves out the decoder's unit tests and fuzz target: LuaJIT'sinterpreter is assembly, which no sanitizer instruments, so the valuesit hands back would read as uninitialized. ASan and UBSan cover those.The ``MSan`` job of the ``Sanitizers`` workflow runs the same, the fuzz-targets for 60 seconds on each push and pull request and for ten-minutes in a run started by hand.+targets for 60 seconds on each push to ``main``, for ten seconds on a+pull request, in which each still runs its seeds, and for ten minutes in+a run started by hand.Run the fuzz targets--------------------@@ -553,8 +555,9 @@ and leaves its input in ``testing/fuzz/crash-afl-<target>-<n>``; thelibFuzzer build of the target reproduces it like any other input.The ``afl-fuzz`` job of the ``Sanitizers`` workflow runs every target-under AFL++ when the ``libFuzzer`` job does, for as long, and saves its-corpus when that job does. Each starts from the newest corpus either+under AFL++ on each push to ``main`` and in a run started by hand, for+as long as the ``libFuzzer`` job, and saves its corpus when that job+does. A pull request leaves it out. Each starts from the newest corpus eitherkept, so that what one finds the other starts from. What crashed is inthe job's ``afl-fuzz-crashes`` artifact.