eBPF-based security platform
ci: refuse a test kernel without the LSM hooks bpf/ attaches to
Daniel Borkmann40d0119bc4df
diff --git a/.github/scripts/tests.sh b/.github/scripts/tests.shindex d1034de3..d7cab954 100755--- a/.github/scripts/tests.sh+++ b/.github/scripts/tests.sh@@ -61,6 +61,24 @@ require_kernel_config() {fi}+# The programs of bpf/ attach to LSM hooks that carried patches of kernel/+# add. A kernel built without one passes every other check here and then+# fails init in the initrd of every VM.+require_lsm_hooks() {+ btf="$1"+ names=$(mktemp) || return 1+ tr '\0' '\n' <"$btf" >"$names"+ missing=$(sed -nE 's/^SEC\("lsm(\.s)?\/([a-z0-9_]+)"\).*/\2/p' bpf/*.c |+ sort -u | while read -r hook; do+ grep -qx "bpf_lsm_$hook" "$names" || printf ' %s' "$hook"+ done)+ rm -f "$names"+ [ -z "$missing" ] && return 0+ printf 'kernel BTF lacks the LSM hooks%s: build it with kernel/*.patch\n' \+ "$missing" >&2+ return 1+}+validate_lvh_kernel() {source_dir="$1"[ -d "$source_dir/boot" ] || {@@ -95,6 +113,7 @@ validate_lvh_kernel() {echo "LVH kernel BTF lacks bpf_attr.signature_size" >&2return 1}+ require_lsm_hooks "$btf" || return 1for setting in \CONFIG_BPF_EVENTS=y \@@ -120,6 +139,7 @@ validate_lvh_kernel() {CONFIG_CRYPTO_SHA512=y \CONFIG_CRYPTO_SHA256=y \CONFIG_MODULE_SIG=y \+ CONFIG_MODULE_SIG_ALL=y \CONFIG_UPROBES=y \CONFIG_SECURITY=y \CONFIG_SECURITY_NETWORK=y \diff --git a/Documentation/contribute/testing/testing.rst b/Documentation/contribute/testing/testing.rstindex 9314b003..6a17e744 100644--- a/Documentation/contribute/testing/testing.rst+++ b/Documentation/contribute/testing/testing.rst@@ -46,13 +46,19 @@ Before you beginoperator's build dependencies to the image of the operator VM.The ``CI suite`` workflow uses the x86-64 CI kernel package from-``shirudo-dev/kernel`` for every trigger. By default, it selects the-latest available ``kernel-packages-x86-64-ci`` artifact from ``main``.-For a manual run, set ``kernel_run_id`` to select a specific run instead.-The run must contain that artifact. The-``KERNEL_REPO_READ_TOKEN`` secret needs Actions read access to the kernel-repository. Setup extracts the image and headers packages, checks the-kernel config and BTF, and stages the result for the test VM.+``shirudo-dev/kernel`` for every trigger: the+``kernel-packages-x86-64-ci`` artifact of the run that+:src:`.github/workflows/tests.yml` pins, so that a new build of the+kernel does not change what a series is tested on. For a manual run,+set ``kernel_run_id`` to select another run. The run must contain that+artifact. The ``KERNEL_REPO_READ_TOKEN`` secret needs Actions read+access to the kernel repository. Setup extracts the image and headers+packages, checks the kernel config and BTF, and stages the result for+the test VM. It refuses a kernel whose BTF lacks an LSM hook a program+of ``bpf/`` attaches to, or whose config does not sign every module.+A change to ``kernel/`` or to :src:`testing/vm/build-kernel.sh`+therefore needs a new run of the kernel repository and the pin moved to+it before CI can boot the series.Test tiers----------