Skip to content

eBPF-based security platform

testing: build VM kernels from release tags of v7.4 or newer

Daniel Borkmann536d5cdfb14e
diff --git a/Documentation/requirements.rst b/Documentation/requirements.rst
index d7d27791..de65f352 100644
--- a/Documentation/requirements.rst
+++ b/Documentation/requirements.rst
@@ -199,7 +199,7 @@ BTF, the attach points the shield will use. Run that loop in a VM
booting the target kernel rather than on the operator host. ``make -C testing
kernel KERNEL_TAG=<tag> KERNEL_CONFIG=<the fleet's .config>`` builds
such a kernel with its BTF, ``make -C testing vm KERNEL=<version>`` boots a
-supported selection with a software TPM and a prepared shirudo, and
+release of v7.4 or newer with a software TPM and a prepared shirudo, and
``make -C testing test-tgt`` runs the target suite in it; any VM of the operator's
own serves the same purpose. A mitigation that loads and passes its
reproducer on a kernel unlike the fleet's proves nothing about the
diff --git a/contrib/build-kernel-package.sh b/contrib/build-kernel-package.sh
index 4f987334..1a35466a 100755
--- a/contrib/build-kernel-package.sh
+++ b/contrib/build-kernel-package.sh
@@ -18,12 +18,20 @@ if [[ "$KERNEL_TAG" =~ ^[0-9]+\.[0-9]+([.][0-9]+)?$ ]]; then
fi
if [[ "$KERNEL_TAG" != "bpf-next" &&
! "$KERNEL_TAG" =~ ^v[0-9]+\.[0-9]+([.][0-9]+)?$ ]]; then
- echo "KERNEL_TAG must be bpf-next or a Linux release tag such as v6.18" >&2
+ echo "KERNEL_TAG must be bpf-next or a Linux release tag such as v7.4" >&2
exit 1
fi
+KERNEL_MIN_VERSION="7.4"
+if [[ "$KERNEL_TAG" != "bpf-next" ]]; then
+ oldest=$(printf '%s\n' "$KERNEL_MIN_VERSION" "${KERNEL_TAG#v}" | sort -V | head -n 1)
+ if [[ "$oldest" != "$KERNEL_MIN_VERSION" ]]; then
+ echo "shirudo requires Linux v${KERNEL_MIN_VERSION} or newer; ${KERNEL_TAG} is older" >&2
+ exit 1
+ fi
+fi
if [[ -n "$KERNEL_COMMIT" ]]; then
if [[ "$KERNEL_TAG" == "bpf-next" ]]; then
- echo "KERNEL_COMMIT is supported only for stable/LTS kernel tags" >&2
+ echo "KERNEL_COMMIT is supported only for release kernel tags" >&2
exit 1
fi
if [[ ! "$KERNEL_COMMIT" =~ ^[0-9a-fA-F]{7,40}$ ]]; then
diff --git a/testing/Makefile b/testing/Makefile
index 8c2529be..e87f2f8a 100644
--- a/testing/Makefile
+++ b/testing/Makefile
@@ -48,25 +48,32 @@ TEST_VM_MEMORY ?= 4G
TEST_VM_DISK_SIZE ?= 30G
TEST_VM_UBUNTU_CODENAME ?= resolute
TEST_VM_VERBOSE ?= 0
-# `make -C testing vm` keeps bpf-next as its default, but can select a stable kernel
-# built from an upstream Linux tag. The stable list is intentionally explicit
-# so a typo cannot silently create a new VM kernel artifact directory.
+# `make -C testing vm` keeps bpf-next as its default, but can boot a kernel
+# built from an upstream release tag, Linux v7.4 or newer being what a
+# target runs.
VM_KERNEL ?= $(if $(strip $(KERNEL)),$(KERNEL),bpf-next)
VM_KERNEL_VERSION := $(patsubst v%,%,$(VM_KERNEL))
-VM_KERNEL_STABLE_VERSIONS := 7.2 6.18 6.12 6.6 6.1
+VM_KERNEL_MIN := 7.4
+VM_KERNEL_IS_RELEASE := $(shell printf '%s\n' '$(VM_KERNEL_VERSION)' | \
+ grep -Ec '^[0-9]+\.[0-9]+(\.[0-9]+)?$$')
+VM_KERNEL_OLDEST := $(firstword $(shell printf '%s\n' '$(VM_KERNEL_MIN)' \
+ '$(VM_KERNEL_VERSION)' | sort -V))
KERNEL_COMMIT ?=
KERNEL_COMMIT_SUFFIX := $(if $(strip $(KERNEL_COMMIT)),-$(KERNEL_COMMIT),)
ifeq ($(VM_KERNEL),bpf-next)
ifneq ($(strip $(KERNEL_COMMIT)),)
- $(error KERNEL_COMMIT is supported only for stable/LTS VM kernels)
+ $(error KERNEL_COMMIT is supported only for release VM kernels)
endif
VM_KERNEL_TAG := bpf-next
VM_KERNEL_ARTIFACT_DIR := $(ROOT)/artifacts/bpf-next-kernel-debs
-else ifneq ($(filter $(VM_KERNEL_VERSION),$(VM_KERNEL_STABLE_VERSIONS)),)
+else ifeq ($(VM_KERNEL_IS_RELEASE),1)
+ifneq ($(VM_KERNEL_OLDEST),$(VM_KERNEL_MIN))
+ $(error shirudo requires Linux v$(VM_KERNEL_MIN) or newer; KERNEL '$(VM_KERNEL)' is older)
+endif
VM_KERNEL_TAG := v$(VM_KERNEL_VERSION)
VM_KERNEL_ARTIFACT_DIR := $(ROOT)/artifacts/linux-$(VM_KERNEL_TAG)$(KERNEL_COMMIT_SUFFIX)-kernel-debs
else
- $(error unsupported VM KERNEL '$(VM_KERNEL)'; choose bpf-next, 7.2, 6.18, 6.12, 6.6, or 6.1)
+ $(error unsupported VM KERNEL '$(VM_KERNEL)'; choose bpf-next or a release such as $(VM_KERNEL_MIN))
endif
VM_KERNEL_IMAGE_NAME := $(call test-vm-arch,TEST_VM_ARCH_KIMAGE)
VM_KERNEL_IMAGE := $(VM_KERNEL_ARTIFACT_DIR)/$(VM_KERNEL_IMAGE_NAME)
@@ -84,7 +91,7 @@ KERNEL_BUILD_JOBS ?= $(shell nproc)
ifeq ($(KERNEL_TAG),bpf-next)
ifneq ($(filter kernel bpf-next,$(MAKECMDGOALS)),)
ifneq ($(strip $(KERNEL_COMMIT)),)
- $(error KERNEL_COMMIT is supported only for stable/LTS kernel tags)
+ $(error KERNEL_COMMIT is supported only for release kernel tags)
endif
endif
KERNEL_TAG_NORMALIZED := bpf-next
@@ -278,8 +285,8 @@ help:
' make -C testing test-tgt-obs' \
' make -C testing test-installer' \
' make -C testing vm, vm-console, vm-ssh, vm-stop, or vm-clean' \
- ' make -C testing vm KERNEL=6.18' \
- ' make -C testing kernel KERNEL_TAG=v6.18' \
+ ' make -C testing vm KERNEL=7.4' \
+ ' make -C testing kernel KERNEL_TAG=v7.4' \
' make -C testing bpf-next or test-vm-bundle' \
' make -C testing clean'
diff --git a/testing/t0015-test-vm-cli.sh b/testing/t0015-test-vm-cli.sh
index 98366ce8..73b2b4b0 100755
--- a/testing/t0015-test-vm-cli.sh
+++ b/testing/t0015-test-vm-cli.sh
@@ -420,16 +420,25 @@ test_expect_success 'make -C testing vm and test-vm share named mode support' '
grep -q "VM_TENANT" ../contrib/test-vm.sh &&
grep -q "while :; do sleep 3600; done" ../contrib/test-vm.sh
'
-test_expect_success 'make -C testing vm selects supported stable kernel artifacts' '
- grep -q "VM_KERNEL_STABLE_VERSIONS := 7.2 6.18 6.12 6.6 6.1" ../testing/Makefile &&
- grep -q "make -C testing vm KERNEL=6.18" ../testing/Makefile &&
+test_expect_success 'make -C testing vm boots a release kernel at or above the floor' '
+ grep -q "VM_KERNEL_MIN := 7.4" ../testing/Makefile &&
+ grep -q "make -C testing vm KERNEL=7.4" ../testing/Makefile &&
grep -Fq "VM_KERNEL_ARTIFACT_DIR := \$(ROOT)/artifacts/linux-\$(VM_KERNEL_TAG)\$(KERNEL_COMMIT_SUFFIX)-kernel-debs" ../testing/Makefile &&
grep -q "TEST_VM_KERNEL=\"\$(abspath \$(VM_KERNEL_IMAGE))\"" ../testing/Makefile &&
- make -n -C .. -f testing/Makefile vm KERNEL=6.18 TEST_VM_ARCH=x86_64 \
- TEST_VM_WORK_DIR="$WORK/stable-vm" \
- >"$WORK/stable-vm-make.out" 2>&1 &&
- grep -q "artifacts/linux-v6.18-kernel-debs/bzImage" \
- "$WORK/stable-vm-make.out"
+ make -n -C .. -f testing/Makefile vm KERNEL=7.4 TEST_VM_ARCH=x86_64 \
+ TEST_VM_WORK_DIR="$WORK/release-vm" \
+ >"$WORK/release-vm-make.out" 2>&1 &&
+ grep -q "artifacts/linux-v7.4-kernel-debs/bzImage" \
+ "$WORK/release-vm-make.out" &&
+ make -n -C .. -f testing/Makefile vm KERNEL=7.10 TEST_VM_ARCH=x86_64 \
+ TEST_VM_WORK_DIR="$WORK/newer-vm" \
+ >"$WORK/newer-vm-make.out" 2>&1 &&
+ grep -q "artifacts/linux-v7.10-kernel-debs/bzImage" \
+ "$WORK/newer-vm-make.out" &&
+ ! make -n -C .. -f testing/Makefile vm KERNEL=6.18 TEST_VM_ARCH=x86_64 \
+ TEST_VM_WORK_DIR="$WORK/old-vm" \
+ >"$WORK/old-vm-make.out" 2>&1 &&
+ grep -q "requires Linux v7.4 or newer" "$WORK/old-vm-make.out"
'
test_expect_success 'the VM kernel image is named for the host architecture' '
@@ -437,10 +446,10 @@ test_expect_success 'the VM kernel image is named for the host architecture' '
riscv64:bzImage
do
arch=${spec%%:*} image=${spec#*:} &&
- make -n -C .. -f testing/Makefile vm KERNEL=6.18 \
+ make -n -C .. -f testing/Makefile vm KERNEL=7.4 \
TEST_VM_ARCH=$arch TEST_VM_WORK_DIR="$WORK/arch-$arch" \
>"$WORK/arch-$arch.out" 2>&1 &&
- grep -q "artifacts/linux-v6.18-kernel-debs/$image" \
+ grep -q "artifacts/linux-v7.4-kernel-debs/$image" \
"$WORK/arch-$arch.out" || return 1
done
'
@@ -460,7 +469,7 @@ test_expect_success 'all kernel and VM builds use the slim profile' '
grep -q "kernel-slim.config" ../contrib/build-kernel-package.sh &&
grep -q "config_profile=slim" ../contrib/build-kernel-package.sh &&
grep -q "CONFIG_CC_OPTIMIZE_FOR_SIZE=y" ../contrib/build-kernel-package.sh &&
- grep -q "make -C testing vm KERNEL=6.18" ../testing/Makefile &&
+ grep -q "make -C testing vm KERNEL=7.4" ../testing/Makefile &&
make -n -C .. -f testing/Makefile vm VM_NAME=slim-cli-vm \
TEST_VM_ARCH=x86_64 TEST_VM_WORK_DIR="$WORK/slim-vm" \
>"$WORK/slim-vm-make.out" 2>&1 &&
@@ -488,25 +497,28 @@ test_expect_success 'make -C testing kernel builds a tagged third-party Linux so
grep -q "KERNEL_REPOSITORY=\"\${KERNEL_REPOSITORY:-https://git.kernel.org" \
../contrib/build-kernel-package.sh &&
grep -q "git clone --depth 1 --branch" ../contrib/build-kernel-package.sh &&
- grep -q "make -C testing kernel KERNEL_TAG=v6.18" ../testing/Makefile &&
+ grep -q "make -C testing kernel KERNEL_TAG=v7.4" ../testing/Makefile &&
! KERNEL_TAG=not-a-kernel-tag ../contrib/build-kernel-package.sh \
>"$WORK/invalid-kernel-tag.out" 2>&1 &&
grep -q "KERNEL_TAG must be bpf-next or a Linux release tag" \
- "$WORK/invalid-kernel-tag.out"
+ "$WORK/invalid-kernel-tag.out" &&
+ ! KERNEL_TAG=v6.18 ../contrib/build-kernel-package.sh \
+ >"$WORK/old-kernel-tag.out" 2>&1 &&
+ grep -q "requires Linux v7.4 or newer" "$WORK/old-kernel-tag.out"
'
-test_expect_success 'make -C testing vm and kernel select an exact stable commit' '
- make -n -C .. -f testing/Makefile vm KERNEL=6.18 KERNEL_COMMIT=abcdef1234567 \
+test_expect_success 'make -C testing vm and kernel select an exact release commit' '
+ make -n -C .. -f testing/Makefile vm KERNEL=7.4 KERNEL_COMMIT=abcdef1234567 \
TEST_VM_ARCH=x86_64 TEST_VM_WORK_DIR="$WORK/commit-vm" \
>"$WORK/commit-vm-make.out" 2>&1 &&
- grep -q "artifacts/linux-v6.18-abcdef1234567-kernel-debs/bzImage" \
+ grep -q "artifacts/linux-v7.4-abcdef1234567-kernel-debs/bzImage" \
"$WORK/commit-vm-make.out" &&
grep -q "KERNEL_COMMIT=" "$WORK/commit-vm-make.out" &&
- grep -q "KERNEL_COMMIT is supported only for stable/LTS VM kernels" ../testing/Makefile &&
+ grep -q "KERNEL_COMMIT is supported only for release VM kernels" ../testing/Makefile &&
! make -n -C .. -f testing/Makefile vm KERNEL=bpf-next KERNEL_COMMIT=abcdef1234567 \
>"$WORK/commit-bpf-next.out" 2>&1 &&
- grep -q "KERNEL_COMMIT is supported only for stable/LTS VM kernels" \
+ grep -q "KERNEL_COMMIT is supported only for release VM kernels" \
"$WORK/commit-bpf-next.out" &&
- ! KERNEL_TAG=v6.18 KERNEL_COMMIT=not-a-sha \
+ ! KERNEL_TAG=v7.4 KERNEL_COMMIT=not-a-sha \
../contrib/build-kernel-package.sh >"$WORK/invalid-kernel-commit.out" 2>&1 &&
grep -q "KERNEL_COMMIT must contain 7 to 40 hexadecimal characters" \
"$WORK/invalid-kernel-commit.out"