Skip to content

eBPF-based security platform

ci: Cache the sanitizer suite's OpenSSL build

Tobias Klauser38c8460eb75b
diff --git a/.github/scripts/sanitizer-openssl-deps.sh b/.github/scripts/sanitizer-openssl-deps.sh
new file mode 100644
index 00000000..b159040d
--- /dev/null
+++ b/.github/scripts/sanitizer-openssl-deps.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+#
+# Build the OpenSSL 3.5+ toolchain the sanitizer suite needs, reusing the
+# host cache: the distribution's OpenSSL predates ML-DSA, and the suite
+# generates its test keys with the openssl binary. The build does not
+# depend on the compiler under test, so one cache entry serves every
+# matrix leg.
+
+set -eu
+
+OPENSSL_VERSION=3.5.9
+OPENSSL_SHA256=603f5602e2eef00d77fbd429d34dcd5822bb301757a1bc9cdb24c670f1eb859a
+
+cache=/host/build/sanitizer-openssl
+openssl=/tmp/shirudo-openssl
+
+if [ -s "$cache/lib/libcrypto.so" ]; then
+ rm -rf "$openssl"
+ cp -a "$cache" "$openssl"
+ exit 0
+fi
+
+rm -rf "$openssl" "$cache" "/tmp/openssl-$OPENSSL_VERSION"
+tarball="openssl-$OPENSSL_VERSION.tar.gz"
+curl -fsSL --retry 3 -o "/tmp/$tarball" \
+ "https://github.com/openssl/openssl/releases/download/openssl-$OPENSSL_VERSION/$tarball"
+printf '%s /tmp/%s\n' "$OPENSSL_SHA256" "$tarball" | sha256sum -c --quiet
+tar -C /tmp -xf "/tmp/$tarball"
+cd "/tmp/openssl-$OPENSSL_VERSION"
+./Configure --prefix="$openssl" --openssldir=/etc/ssl --libdir=lib \
+ no-docs no-tests
+make -j4
+make install_sw
+
+mkdir -p "$(dirname "$cache")"
+cp -a "$openssl" "$cache"
diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml
index ec110aef..6130c1ce 100644
--- a/.github/workflows/sanitizers.yml
+++ b/.github/workflows/sanitizers.yml
@@ -35,6 +35,15 @@ jobs:
- 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.
+ - name: Restore the sanitizer OpenSSL build
+ id: sanitizer-openssl
+ uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
+ with:
+ path: build/sanitizer-openssl
+ key: sanitizer-openssl-${{ hashFiles('.github/scripts/sanitizer-openssl-deps.sh') }}
+
# The BPF objects embedded in the binary need the BTF of a signed-BPF
# capable bpf-next kernel, so the build runs in the same LVH VM as the
# package build. The host-side suite itself needs no root, LSM or TPM.
@@ -77,17 +86,7 @@ jobs:
git config --global --add safe.directory /host
- # OpenSSL 3.5+: the distribution's build predates ML-DSA, and
- # the suite generates its test keys with the openssl binary.
- curl -fsSL https://github.com/openssl/openssl/releases/download/openssl-3.5.9/openssl-3.5.9.tar.gz \
- -o /tmp/openssl-3.5.9.tar.gz
- tar -C /tmp -xf /tmp/openssl-3.5.9.tar.gz
- cd /tmp/openssl-3.5.9
- ./Configure --prefix=/tmp/shirudo-openssl --openssldir=/etc/ssl \
- --libdir=lib no-docs no-tests
- make -j4
- make install_sw
- cd /host
+ sh .github/scripts/sanitizer-openssl-deps.sh
export PATH=/tmp/shirudo-openssl/bin:\$PATH
export PKG_CONFIG_PATH=/tmp/shirudo-openssl/lib/pkgconfig
@@ -99,6 +98,13 @@ jobs:
make -C testing SANITIZE=address,undefined test-helpers
make tests VM=0 SANITIZE=address,undefined
+ - name: Save the sanitizer OpenSSL build
+ if: always() && steps.sanitizer-openssl.outputs.cache-hit != 'true' && hashFiles('build/sanitizer-openssl/lib/libcrypto.so') != ''
+ uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
+ with:
+ path: build/sanitizer-openssl
+ key: ${{ steps.sanitizer-openssl.outputs.cache-primary-key }}
+
libfuzzer:
name: libFuzzer
runs-on: ubuntu-latest