Skip to content

eBPF-based security platform

ci: add a ThreadSanitizer leg to the sanitizer matrix

Daniel Borkmann578cc97ce921
diff --git a/.agents/skills/pre-submit/SKILL.md b/.agents/skills/pre-submit/SKILL.md
index b8a9570a..54d5ff74 100644
--- a/.agents/skills/pre-submit/SKILL.md
+++ b/.agents/skills/pre-submit/SKILL.md
@@ -61,6 +61,7 @@ make -B CC=clang && make -B CC=clang shirudo-build &&
make -B -f Makefile.shirudo CC=clang test-helpers
make tests VM=0 SANITIZE=address,undefined # CC=gcc and CC=clang,
# one worktree each
+make tests VM=0 SANITIZE=thread CC=clang # and TSan in a third
sh .github/scripts/msan-deps.sh && # MSan, a worktree of
sh .github/scripts/msan-tests.sh 60 # its own
make -C testing fuzz FUZZ_SECONDS=60
diff --git a/.agents/skills/testing/SKILL.md b/.agents/skills/testing/SKILL.md
index 74b72852..2c3e8d26 100644
--- a/.agents/skills/testing/SKILL.md
+++ b/.agents/skills/testing/SKILL.md
@@ -20,6 +20,7 @@ make -C testing unit/<suite> # one unit suite
make -C testing functional/<family> # one family, its VM tests too
make tests VM=0 # without the target tests
make tests VM=0 SANITIZE=address,undefined # CI: once with gcc, once with clang
+make tests VM=0 SANITIZE=thread CC=clang # CI: TSan, for threads and handlers
sh .github/scripts/msan-deps.sh # MSan: instrumented libraries once,
sh .github/scripts/msan-tests.sh [60] # then unit and fuzz from a clean tree
make -C testing fuzz [FUZZ_SECONDS=60] [FUZZERS=<target>...]
diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml
index b00069da..3a28698e 100644
--- a/.github/workflows/sanitizers.yml
+++ b/.github/workflows/sanitizers.yml
@@ -20,23 +20,33 @@ concurrency:
cancel-in-progress: true
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.
tests:
- name: ASan+UBSan (${{ matrix.compiler }})
+ name: ${{ matrix.name }} (${{ matrix.compiler }})
if: github.event_name != 'schedule'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
- compiler:
- - gcc
- - clang
+ include:
+ - name: ASan+UBSan
+ sanitize: address,undefined
+ compiler: gcc
+ - name: ASan+UBSan
+ sanitize: address,undefined
+ compiler: clang
+ - name: TSan
+ sanitize: thread
+ compiler: clang
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- # The build does not depend on the compiler under test, so one cache
- # entry serves both matrix legs.
+ # The build does not depend on the compiler or the sanitizer under
+ # test, so one cache entry serves every matrix leg.
- name: Restore the sanitizer OpenSSL build
id: sanitizer-openssl
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
@@ -50,7 +60,7 @@ jobs:
- name: Build with sanitizers and run the host-side suite in LVH VM
uses: cilium/little-vm-helper@c8b0bfbae3bdda7bc69fb9cd370e4b74ce84986d # v0.0.33
with:
- test-name: shirudo-sanitizers-${{ matrix.compiler }}
+ test-name: shirudo-sanitizers-${{ matrix.compiler }}-${{ matrix.sanitize == 'thread' && 'tsan' || 'asan' }}
image: kind
image-version: bpf-next-20260603.072225
kernel-version: bpf-next-main
@@ -91,10 +101,10 @@ jobs:
export LD_LIBRARY_PATH=/tmp/shirudo-openssl/lib
export CC=${{ matrix.compiler }}
- make -j4 SANITIZE=address,undefined
- make SANITIZE=address,undefined shirudo-build
- make -C testing SANITIZE=address,undefined test-helpers
- make tests VM=0 SANITIZE=address,undefined
+ make -j4 SANITIZE=${{ matrix.sanitize }}
+ make SANITIZE=${{ matrix.sanitize }} shirudo-build
+ make -C testing SANITIZE=${{ matrix.sanitize }} test-helpers
+ make tests VM=0 SANITIZE=${{ matrix.sanitize }}
- name: Save the sanitizer OpenSSL build
if: always() && steps.sanitizer-openssl.outputs.cache-hit != 'true' && hashFiles('build/sanitizer-openssl/lib/libcrypto.so') != ''
diff --git a/Documentation/contribute/code/developer-guide.rst b/Documentation/contribute/code/developer-guide.rst
index c397f160..8d45fe78 100644
--- a/Documentation/contribute/code/developer-guide.rst
+++ b/Documentation/contribute/code/developer-guide.rst
@@ -203,6 +203,9 @@ variables change it:
* - ``SANITIZE=address,undefined``
- Instruments the host binaries and the test helpers with ASan and
UBSan. See :doc:`/contribute/testing/testing`.
+ * - ``SANITIZE=thread``
+ - Instruments them with TSan. See
+ :doc:`/contribute/testing/testing`.
* - ``SANITIZE=memory``
- Instruments them with MSan, the vendored libbpf included, and
wants the instrumented libraries
diff --git a/Documentation/contribute/testing/testing.rst b/Documentation/contribute/testing/testing.rst
index ea76f453..9314b003 100644
--- a/Documentation/contribute/testing/testing.rst
+++ b/Documentation/contribute/testing/testing.rst
@@ -273,6 +273,13 @@ Run under the sanitizers
objects are unaffected. Recovery is off, so every report fails the run.
CI runs the same with gcc and with clang.
+``SANITIZE=thread`` runs the same tests under ThreadSanitizer, which
+reports 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 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.
+
Run under MemorySanitizer
-------------------------