Skip to content

eBPF-based security platform

ci: keep the fuzz corpora, fuzz ten minutes nightly, upload crashes

Daniel Borkmannab978274b383
diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml
index 97974c61..42216882 100644
--- a/.github/workflows/sanitizers.yml
+++ b/.github/workflows/sanitizers.yml
@@ -7,6 +7,9 @@ on:
tags:
- '*'
pull_request:
+ schedule:
+ - cron: '0 2 * * *'
+ workflow_dispatch:
permissions:
contents: read
@@ -14,6 +17,7 @@ permissions:
jobs:
tests:
name: ASan+UBSan (${{ matrix.compiler }})
+ if: github.event_name != 'schedule'
runs-on: ubuntu-latest
strategy:
fail-fast: false
@@ -100,9 +104,20 @@ jobs:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ # Every run starts from the corpus the last nightly run kept; the
+ # newest one is restored, as each is saved under a key of its own.
+ - name: Restore the fuzz corpora
+ uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
+ with:
+ path: build/fuzz-corpus
+ key: fuzz-corpus-${{ github.run_id }}-${{ github.run_attempt }}
+ restore-keys: fuzz-corpus-
+
# The targets need no BPF objects, but the toolchain the other jobs
- # build in comes with the LVH guest.
+ # build in comes with the LVH guest. A push or a pull request gets a
+ # minute per target, the nightly run ten.
- name: Fuzz the parsers of input from outside the host in LVH VM
+ id: fuzz
uses: cilium/little-vm-helper@f86d344aca812dda5aef167867a9a0a90ca6cca5 # v0.0.31
with:
test-name: shirudo-libfuzzer
@@ -118,4 +133,23 @@ jobs:
cd /host
.github/scripts/vm-toolchain.sh libclang-rt-21-dev
. build/vm-toolchain.env
- make -C testing fuzz FUZZ_SECONDS=60
+ make -C testing fuzz \
+ FUZZ_SECONDS=${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && 600 || 60 }} \
+ FUZZ_CORPUS=/host/build/fuzz-corpus
+
+ # Only the nightly and manual runs save, so that each push does not
+ # add a corpus to the cache the kernel and the VM images share.
+ - name: Save the fuzz corpora
+ if: always() && steps.fuzz.outcome != 'skipped' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
+ uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
+ with:
+ path: build/fuzz-corpus
+ key: fuzz-corpus-${{ github.run_id }}-${{ github.run_attempt }}
+
+ - name: Upload the crash inputs
+ if: failure()
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
+ with:
+ name: fuzz-crashes
+ path: testing/fuzz/crash-*
+ if-no-files-found: ignore
diff --git a/Documentation/contribute/testing/testing.rst b/Documentation/contribute/testing/testing.rst
index 53e10762..033c04d5 100644
--- a/Documentation/contribute/testing/testing.rst
+++ b/Documentation/contribute/testing/testing.rst
@@ -268,6 +268,18 @@ runs in, which ``make -C testing`` changes to ``testing/``:
An input in the kept corpus that crashes a later build fails that run
like any new crash.
+The ``libFuzzer`` job of the ``Sanitizers`` workflow runs every target
+for 60 seconds on each push and pull request, and for ten minutes in a
+nightly run, which also starts by hand from the Actions page. Every run
+starts from the corpus the last nightly or manual run kept in the
+Actions cache, and only those runs save it. When a run fails, the
+inputs that crashed are in its ``fuzz-crashes`` artifact; copy one into
+``testing/fuzz/`` and run its target on it to reproduce the crash:
+
+.. code-block:: console
+
+ $ testing/fuzz/fuzz-<target> testing/fuzz/crash-<target>-<hash>
+
Use the test VM
---------------