Skip to content

eBPF-based security platform

testing: switch CI to pinned public kernel bundles

Andrea Lattuada42d88967b3d4
diff --git a/.agents/skills/security-audit/SKILL.md b/.agents/skills/security-audit/SKILL.md
index 319a392e..a63b1a17 100644
--- a/.agents/skills/security-audit/SKILL.md
+++ b/.agents/skills/security-audit/SKILL.md
@@ -103,8 +103,8 @@ of `bpf/` the list of who writes and reads it, set against its flags.
Hunt each class in both halves, the BPF programs and the userspace C,
and with the kernel source open: a checkout of the kernel the test VM
-boots, which the `shirudo-dev/kernel` project builds with its patch
-set. Neither half can be judged without it. For a hook,
+boots, which `testing/kernel/build-kernel.sh` builds with the carried
+patch set. Neither half can be judged without it. For a hook,
read the callers of `security_<hook>()`, what each does with the return
value and what it holds while it calls; for a helper or kfunc, what it
returns, when it fails and whether it sleeps; for a system call, a
diff --git a/.agents/skills/testing/SKILL.md b/.agents/skills/testing/SKILL.md
index d1de605a..ca6346ea 100644
--- a/.agents/skills/testing/SKILL.md
+++ b/.agents/skills/testing/SKILL.md
@@ -102,14 +102,19 @@ parser of input from outside the host gets a target in `testing/fuzz/`.
## Before a VM goal
-- `vm`, `test-vm-bundle` and every family with target tests require the
- kernel artifact from `shirudo-dev/kernel` under
- `artifacts/bpf-next-kernel-debs/`. `testing/vm/kernel-artifact.sh`
- pins a kernel run; the CI setup script stages its artifact, and a
- local VM goal that finds no kernel there downloads and stages it with
- `gh` (`testing/vm/kernel-artifact.sh fetch`). A kernel already staged
- is left alone: remove the directory to get the pinned one. No goal
- builds a kernel from this checkout.
+- `vm`, `test-vm-bundle` and every family with target tests require a CI
+ kernel artifact under `artifacts/bpf-next-kernel-debs/`.
+ `testing/vm/kernel-artifact.sh` pins a build run and a SHA-256 for each
+ architecture. Dispatch Build kernel packages and Publish test kernel
+ on shirudo's main branch for a new pin. Update the run ID and both
+ checksums together. CI builds x86-64 and arm64 from `testing/kernel/`
+ for a run that changes the kernel inputs. Otherwise it downloads the pinned
+ prerelease. Local VM goals use `testing/vm/kernel-artifact.sh fetch`
+ when the kernel is missing. It downloads the prerelease ZIP with
+ `curl` and verifies its checksum before extraction. Use authenticated
+ `gh` with `KERNEL_RUN_ID` for a specific shirudo Actions run. A kernel
+ already staged is left alone: remove the directory to get the pinned
+ one.
- The bundle builds in the build container (`testing/container/`) from
a copy of the files git sees in the checkout, tracked and untracked but
not ignored, so uncommitted changes are tested; edit nothing until the
diff --git a/.github/scripts/select-test-kernel.sh b/.github/scripts/select-test-kernel.sh
new file mode 100644
index 00000000..38fe8847
--- /dev/null
+++ b/.github/scripts/select-test-kernel.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+
+set -eu
+
+if [ -n "${KERNEL_RUN_ID:-}" ]; then
+ testing/vm/kernel-artifact.sh run-id >/dev/null
+ echo "build=false" >>"$GITHUB_OUTPUT"
+ exit 0
+fi
+
+base=${BASE_SHA:-}
+case "$base" in
+''|0000000000000000000000000000000000000000)
+ base=HEAD
+ ;;
+*)
+ if ! git cat-file -e "$base^{commit}" 2>/dev/null; then
+ git fetch --no-tags --depth=1 origin "$base"
+ fi
+ ;;
+esac
+
+changed=$(git diff --name-only "$base" HEAD -- testing/kernel \
+ .github/scripts/build-test-kernel.sh .github/workflows/build-kernel-packages.yml)
+if [ -n "$changed" ]; then
+ echo "build=true" >>"$GITHUB_OUTPUT"
+else
+ echo "build=false" >>"$GITHUB_OUTPUT"
+fi
diff --git a/.github/scripts/tests.sh b/.github/scripts/tests.sh
index a4ae528d..60d0738c 100755
--- a/.github/scripts/tests.sh
+++ b/.github/scripts/tests.sh
@@ -11,7 +11,7 @@
# ci-checks tests, functional and end2end the tier of that name.
# With VM=0, setup installs only host test dependencies using the kernel
# CI artifact's BTF, and run leaves out target VMs. CI supplies this artifact
-# from github.com/shirudo-dev/kernel.
+# built from testing/kernel.
#
# .github/scripts/tests.sh setup|run [unit|functional|end2end]
#
@@ -59,7 +59,7 @@ setup() {
fi
if [ -z "${KERNEL_CI_ARTIFACT_DIR:-}" ]; then
- echo 'KERNEL_CI_ARTIFACT_DIR must name the downloaded artifact from github.com/shirudo-dev/kernel' >&2
+ echo 'KERNEL_CI_ARTIFACT_DIR must name the downloaded CI kernel artifact' >&2
exit 1
fi
testing/vm/kernel-artifact.sh stage "$KERNEL_CI_ARTIFACT_DIR" || exit 1
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index f166830c..ffce970a 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -22,7 +22,33 @@ concurrency:
cancel-in-progress: true
jobs:
+ kernel-plan:
+ name: Select the test kernel
+ runs-on: ubuntu-latest
+ outputs:
+ build: ${{ steps.select.outputs.build }}
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ fetch-depth: 2
+ persist-credentials: false
+
+ - name: Check whether the kernel inputs changed
+ id: select
+ env:
+ BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }}
+ KERNEL_RUN_ID: ${{ inputs.kernel_run_id }}
+ run: sh .github/scripts/select-test-kernel.sh
+
+ kernel-build:
+ needs: kernel-plan
+ if: needs.kernel-plan.outputs.build == 'true'
+ uses: ./.github/workflows/build-kernel-packages.yml
+
tests:
+ needs: [kernel-plan, kernel-build]
+ if: ${{ !cancelled() }}
name: ${{ matrix.name }}
runs-on: ${{ matrix.runner }}
timeout-minutes: 150
@@ -40,28 +66,30 @@ jobs:
VM: ${{ matrix.vm }}
steps:
+ - name: Require successful kernel preparation
+ if: >-
+ needs.kernel-plan.result != 'success' ||
+ (needs.kernel-plan.outputs.build == 'true' && needs.kernel-build.result != 'success')
+ run: /usr/bin/false
+
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- - name: Resolve kernel package artifact
- id: kernel-run
- env:
- GH_TOKEN: ${{ secrets.KERNEL_REPO_READ_TOKEN }}
- REQUESTED_RUN_ID: ${{ inputs.kernel_run_id }}
- run: |
- run_id=$(KERNEL_RUN_ID="$REQUESTED_RUN_ID" testing/vm/kernel-artifact.sh run-id)
- echo "Using kernel package run $run_id"
- echo "run_id=$run_id" >> "$GITHUB_OUTPUT"
-
- - name: Download kernel CI artifact
+ - name: Download the kernel built for this run
+ if: needs.kernel-plan.outputs.build == 'true'
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: kernel-packages-x86-64-ci
- repository: shirudo-dev/kernel
- run-id: ${{ steps.kernel-run.outputs.run_id }}
- github-token: ${{ secrets.KERNEL_REPO_READ_TOKEN }}
path: build/kernel-ci-artifact
+ - name: Download the pinned or selected kernel
+ if: needs.kernel-plan.outputs.build != 'true'
+ env:
+ GH_TOKEN: ${{ github.token }}
+ KERNEL_RUN_ID: ${{ inputs.kernel_run_id }}
+ TEST_VM_ARCH: x86_64
+ run: testing/vm/kernel-artifact.sh download
+
- name: Restore the static target dependencies
if: matrix.vm == '1'
id: target-deps
diff --git a/Documentation/concepts/background/tpm.rst b/Documentation/concepts/background/tpm.rst
index d69afb1d..4c30ce49 100644
--- a/Documentation/concepts/background/tpm.rst
+++ b/Documentation/concepts/background/tpm.rst
@@ -369,7 +369,7 @@ The signature alone does not keep other processes out. The bytes the
writer key derives from are not a secret, so any process that recreates
the key could ask the TPM to sign. An LSM hook in the kernel keeps
them out. The companion kernel change in the
-`shirudo-dev/kernel project <https://github.com/shirudo-dev/kernel>`_
+:src:`testing/kernel/`
adds an LSM hook, ``tpm_command``, that sees every command written to
``/dev/tpm0`` or ``/dev/tpmrm0`` before the driver sends or queues it.
shirudo's ``lsm/tpm_command``
diff --git a/Documentation/concepts/background/xattrs.rst b/Documentation/concepts/background/xattrs.rst
index 0f20d40a..a8427b35 100644
--- a/Documentation/concepts/background/xattrs.rst
+++ b/Documentation/concepts/background/xattrs.rst
@@ -74,7 +74,7 @@ kfuncs:
Read an xattr whose name starts with ``user.`` or ``security.bpf.``.
They first check that the current task may read the inode
(``inode_permission()`` with ``MAY_READ``) and return its error if
- not; kernel project patch 0002 skips that check for
+ not; carried patch 0021 skips that check for
``security.bpf.`` names (:doc:`/internals/kernel-patches`). Both
may sleep, so only sleepable programs call them.
@@ -298,7 +298,7 @@ Limits
------
Upstream, the read kfuncs check the calling task's read permission even
-for ``security.bpf.`` names; kernel project patch 0002 drops that check
+for ``security.bpf.`` names; carried patch 0021 drops that check
for them. On a kernel without the patch, when another LSM, an ACL
or an idmapped mount denies that task read access, the seal decides by
the record of the inode, or of the directory the operation changes, and
diff --git a/Documentation/contribute/code/developer-guide.rst b/Documentation/contribute/code/developer-guide.rst
index a3c434ab..0b8d902a 100644
--- a/Documentation/contribute/code/developer-guide.rst
+++ b/Documentation/contribute/code/developer-guide.rst
@@ -134,7 +134,7 @@ The build takes the first of these sources:
- Generates the header from a BTF file or an ELF file with a
``.BTF`` section.
* - ``artifacts/bpf-next-kernel-debs/vmlinux.btf``
- - The BTF staged from the pinned kernel project artifact.
+ - The BTF staged from the pinned CI kernel artifact.
* - ``/sys/kernel/btf/vmlinux``
- The running kernel.
@@ -419,9 +419,9 @@ Project layout
- Vendored libbpf and BPF UAPI headers.
* - ``vendor/linux/``
- The generated ``vmlinux.h``. Not tracked.
- * - ``shirudo-dev/kernel``
- - Kernel source, configuration, patches and built artifacts used
- by CI. See :doc:`/internals/kernel-patches`.
+ * - :src:`testing/kernel/`
+ - The upstream kernel pin, configuration, patches and build script
+ used by CI. See :doc:`/internals/kernel-patches`.
* - :src:`upatches/`
- The shipped packages: ``kernel-obs`` with its Beefile, and the
three ``kernel-cve`` detectors and the ``kernel-cve``
diff --git a/Documentation/contribute/testing/testing.rst b/Documentation/contribute/testing/testing.rst
index c2e03d6c..0aec6cb9 100644
--- a/Documentation/contribute/testing/testing.rst
+++ b/Documentation/contribute/testing/testing.rst
@@ -52,30 +52,30 @@ Before you begin
operator's build dependencies, a JDK among them, 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: the
-``kernel-packages-x86-64-ci`` artifact of the run that
-:src:`testing/vm/kernel-artifact.sh` 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 packages,
-checks BTF for the signed-loader ABI and every LSM hook a
-program of ``bpf/`` attaches to, and stages the result for the test VM.
-The kernel project owns the kernel source, configuration and patch
-application. Changes to those inputs need a successful kernel project
-run and an updated pin before CI can boot the series.
-
-Publish a CI kernel prerelease
-------------------------------
-
-Dispatch ``Build kernel packages`` on shirudo's ``main``. It builds
-x86-64 and arm64 from the bpf-next commit in
-:src:`testing/kernel/bpf-next.commit` and the patches and configuration
-in :src:`testing/kernel/`. Dispatch ``Publish test kernel`` with the
-successful run ID. The prerelease ``test-kernel-<run-id>`` includes both
-bundle ZIPs, their matching ``kernel-ci-source.tar.zst`` and
-``SHA256SUMS``. Verify the public downloads against ``SHA256SUMS``.
+The ``CI suite`` workflow uses the x86-64 CI kernel package.
+:src:`testing/vm/kernel-artifact.sh` pins its build run ID and checksums.
+When a change touches the kernel build inputs, CI builds packages for
+x86-64 and arm64 using the bpf-next commit recorded in
+:src:`testing/kernel/bpf-next.commit` and the patches and configuration in
+:src:`testing/kernel/`. Both builds must pass and the test VM uses the
+x86-64 package from that run. For a manual CI run, set ``kernel_run_id``
+to use a ``kernel-packages-x86-64-ci`` artifact from a shirudo Actions run.
+Setup extracts the packages, checks BTF for the signed-loader ABI and
+every LSM hook a program of ``bpf/`` attaches to, and stages the result
+for the test VM.
+
+To update the published pin, dispatch ``Build kernel packages`` on
+shirudo's ``main``, then dispatch ``Publish test kernel`` with the
+successful build run ID. The workflow publishes ``test-kernel-<run-id>``
+with the original x86-64 and arm64 bundle ZIPs and
+``kernel-ci-source.tar.zst``. The source archive contains the patched
+kernel, the patch series, the CI configuration fragments and the build
+script. The bundles contain the generated configurations and build
+metadata. Use the release's ``SHA256SUMS`` to update both architecture
+checksums and the run ID in :src:`testing/vm/kernel-artifact.sh` together.
+Land kernel input changes first. After publishing their bundles, update
+the pin in the same change as any shirudo code that requires the new
+kernel.
Check the quickstart and quick guides
-------------------------------------
@@ -488,8 +488,8 @@ end-to-end test has no TPM and no shirudo kernel arguments; it builds
and installs the operator package and serves the end-to-end run. The
interactive VM stays up until you stop it.
-Use a kernel project artifact
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Use a CI kernel artifact
+~~~~~~~~~~~~~~~~~~~~~~~~
The kernel CI artifacts contain the kernel image, BTF, configuration and
modules. :src:`testing/vm/kernel-artifact.sh` pins the run the tests use.
@@ -497,15 +497,17 @@ A goal of ``make -C testing`` that finds no kernel under
``artifacts/bpf-next-kernel-debs/`` downloads and stages the CI artifact
for the VM architecture. A target VM goal uses its kernel image, and a
build uses its BTF unless ``BPF_VMLINUX_BTF`` or ``BPF_VMLINUX_H`` names
-another source. Fetching needs ``gh`` logged in with read access to the
-kernel repository:
+another source. ``fetch`` downloads the architecture's ZIP from the
+pinned run's ``test-kernel-<run-id>`` prerelease in
+``shirudo-dev/shirudo`` with ``curl``. It checks the pinned SHA-256 before
+extracting the ZIP with Python 3.
.. code-block:: console
$ testing/vm/kernel-artifact.sh fetch
-``KERNEL_RUN_ID=<run>`` takes another run that publishes the CI artifact
-for the architecture. A kernel that is staged is
+``KERNEL_RUN_ID=<run>`` selects a shirudo Actions run that has the CI
+artifact for the architecture and fetches it using authenticated ``gh``. A kernel that is staged is
left as it is, whatever run it came from, and
``artifacts/bpf-next-kernel-debs/kernel-run-id`` names the run of one
that was fetched: remove the directory to get the pinned kernel after
diff --git a/Documentation/internals/enforcement.rst b/Documentation/internals/enforcement.rst
index 349f8c78..847f9cf6 100644
--- a/Documentation/internals/enforcement.rst
+++ b/Documentation/internals/enforcement.rst
@@ -532,7 +532,7 @@ Hooks in seal
``mm_access()`` would grant ``CAP_PERFMON`` after the ptrace check
refused it: ``environ``, ``maps``, ``smaps``, ``pagemap``.
- ``EACCES``, uncounted
- - Closed, with kernel project patch 0005.
+ - Closed, with carried patch 0024.
* - ``lsm/perf_event_alloc``
- A perf event bound to a marked task. CPU-wide events have no task
and are not checked.
diff --git a/Documentation/internals/kernel-interfaces.rst b/Documentation/internals/kernel-interfaces.rst
index 34954cee..3f0de963 100644
--- a/Documentation/internals/kernel-interfaces.rst
+++ b/Documentation/internals/kernel-interfaces.rst
@@ -54,7 +54,7 @@ Kernel baseline
- 7.4 cycle
bpf-next contains the signed-loader ABI at merge ``0867b7bfa9de``.
-The test suite uses the pinned artifact built by ``shirudo-dev/kernel``.
+The test suite uses the pinned artifact built from :src:`testing/kernel/`.
shirudo defines ``KEY_SPEC_DM_VERITY_KEYRING`` (-10) itself when
the UAPI headers lack it. The ``tpm_command`` LSM hook, the label reads
without the calling task's permission, the sleepable form of six inode
@@ -386,7 +386,7 @@ Kfuncs and helpers
- Read ``security.bpf.shirudo``, ``security.bpf.shirudo.policy``
and ``security.bpf.shirudo.ancestor``.
Sleepable; upstream they check ``MAY_READ`` for the calling task
- first, which kernel project patch 0002 skips for ``security.bpf.``
+ first, which carried patch 0021 skips for ``security.bpf.``
names.
* - ``bpf_inode_init_xattr()``
- Add the label in ``inode_init_security``.
@@ -581,7 +581,7 @@ function only the option builds, ``__module_address`` for
Without ``CONFIG_MODULE_SIG``, ``module_sig_check()`` is a stub that
asks no LSM about an unsigned module.
-The kernel project configures the test kernel with these options and the
+The test kernel configuration sets these options and the
additional options the test fixtures and VM need.
Kernel command line
diff --git a/Documentation/internals/kernel-patches.rst b/Documentation/internals/kernel-patches.rst
index 7eed7a86..f71072fe 100644
--- a/Documentation/internals/kernel-patches.rst
+++ b/Documentation/internals/kernel-patches.rst
@@ -8,10 +8,9 @@
Carried kernel patches
======================
-The kernel changes shirudo needs and the external project that builds
-them. The ``shirudo-dev/kernel`` repository carries these changes and
-publishes the kernel artifacts used by the test suite. A production
-kernel needs the same changes.
+The kernel changes shirudo needs. :src:`testing/kernel/patches/` carries
+these changes for the test suite. A production kernel needs the same
+changes.
Summary
-------
@@ -24,23 +23,23 @@ Summary
- Author
- In bpf-next
- Architectures
- * - ``0001-tpm-Let-LSMs-inspect-userspace-commands.patch``
+ * - ``0020-tpm-Let-LSMs-inspect-userspace-commands.patch``
- KP Singh
- No
- All
- * - ``0002-bpf-Read-security.bpf-xattrs-for-LSM-programs-without-the-caller-s-permission.patch``
+ * - ``0021-bpf-Read-security.bpf-xattrs-for-LSM-programs-without-the-callers-permission.patch``
- Daniel Borkmann
- No
- All
- * - ``0003-bpf-Let-sleepable-LSM-programs-attach-to-the-remaining-inode-hooks.patch``
+ * - ``0022-bpf-Let-sleepable-LSM-programs-attach-to-the-remaining-inode-hooks.patch``
- Daniel Borkmann
- No
- All
- * - ``0004-bpf-Treat-dentry-d_parent-as-a-trusted-pointer.patch``
+ * - ``0023-bpf-Treat-dentry-d_parent-as-a-trusted-pointer.patch``
- Daniel Borkmann
- No
- All
- * - ``0005-mm-Let-LSMs-check-read-only-remote-mm-access-under-CAP_PERFMON.patch``
+ * - ``0024-mm-Let-LSMs-check-read-only-remote-mm-access-under-CAP_PERFMON.patch``
- Daniel Borkmann
- No
- All
@@ -64,10 +63,10 @@ why.
How the test kernel includes them
---------------------------------
-The kernel project maintains and builds the patches. CI downloads its
-kernel package artifact and checks the BTF ABI and LSM hooks before it
-stages the image for the test VM. The kernel configuration and patch
-application are owned by that project.
+:src:`testing/kernel/build-kernel.sh` applies the patches to the pinned
+bpf-next commit and builds the kernel package with the configuration in
+:src:`testing/kernel/`. CI checks the BTF ABI and LSM hooks before it
+stages the image for the test VM.
TPM command LSM hook
--------------------
diff --git a/Documentation/internals/seal.rst b/Documentation/internals/seal.rst
index 3ad1c2d1..f3aeb836 100644
--- a/Documentation/internals/seal.rst
+++ b/Documentation/internals/seal.rst
@@ -174,7 +174,7 @@ task. It counts one whose mode includes ``PTRACE_MODE_ATTACH``
``pidfd_getfd()`` and ``process_vm_readv()``, and refuses a read-mode
one uncounted, because journald reads ``/proc/<pid>/exe`` of every
process it logs for and a counted read would rise on an honest node.
-``lsm/mm_read_access``, a hook of kernel project patch 0005, refuses the
+``lsm/mm_read_access``, a hook of carried patch 0024, refuses the
read-only access ``mm_access()`` grants ``CAP_PERFMON`` after that
refusal, to ``environ``, ``maps`` and the other memory files. ``lsm/perf_event_alloc``
refuses a perf event bound to a marked task (``SealPerf``).
@@ -397,11 +397,11 @@ Marks are a cache
entry's parent dentry and refresh its mark on the way, which
``inode_init_security``, the one hook without a dentry, labels the
new inode from in the same operation. On a kernel without the
- kernel project patches 0003 and 0004, the seal's entry hooks do not load
+ carried patches 0022 and 0023, the seal's entry hooks do not load
and ``init`` fails.
Label reads on an upstream kernel
- Without kernel project patch 0002, the kfuncs check that the calling
+ Without carried patch 0021, the kfuncs check that the calling
task may read the inode, and every LSM's ``inode_permission`` hook
takes part. A read that fails for the caller, through an idmapped
mount, an ACL or another LSM's policy, makes a labeled inode
diff --git a/Documentation/operate/plan/overhead.rst b/Documentation/operate/plan/overhead.rst
index c6b336e4..84e1ac23 100644
--- a/Documentation/operate/plan/overhead.rst
+++ b/Documentation/operate/plan/overhead.rst
@@ -40,7 +40,7 @@ Measurement setup
- A test VM: ``q35`` machine, 4 vCPUs (``-cpu host``), 4 GiB of
memory, Ubuntu 26.04 with systemd 259.
* - Kernel
- - The pinned bpf-next artifact from ``shirudo-dev/kernel``.
+ - The pinned bpf-next artifact built from :src:`testing/kernel/`.
* - TPM
- swtpm 0.7.3, a software TPM, through ``/dev/tpmrm0``.
* - Method
diff --git a/Documentation/operate/plan/system-requirements.rst b/Documentation/operate/plan/system-requirements.rst
index 18f559c6..2cd0ac21 100644
--- a/Documentation/operate/plan/system-requirements.rst
+++ b/Documentation/operate/plan/system-requirements.rst
@@ -103,9 +103,10 @@ Kernel source
there, and ``init`` fails without the hook.
:doc:`/internals/kernel-patches` describes the required changes and
-their status. The `shirudo-dev/kernel repository
-<https://github.com/shirudo-dev/kernel>`_ maintains the patches and
-builds the test and production kernel artifacts.
+their status. :src:`testing/kernel/` carries the patches and builds the
+test kernel artifacts. The `shirudo-dev/kernel repository
+<https://github.com/shirudo-dev/kernel>`_ builds the production kernel
+artifacts.
Identify the kernel
~~~~~~~~~~~~~~~~~~~
@@ -118,14 +119,13 @@ Identify the kernel
the kernel has every LSM hook the embedded programs attach to
(``kernel_lsm_hooks``), and names the hooks a kernel built without
the kernel project patch set lacks.
-- The test harness uses the pinned kernel build artifact from
- `shirudo-dev/kernel <https://github.com/shirudo-dev/kernel>`_. The
- kernel project owns its source, configuration and patch application.
+- The test harness uses the pinned artifact built from
+ :src:`testing/kernel/`.
Kernel configuration
~~~~~~~~~~~~~~~~~~~~
-shirudo needs every option below. The kernel project's CI profile sets
+shirudo needs every option below. The CI kernel configuration sets
these options and additional ones that the tests use.
.. list-table::
diff --git a/Documentation/security/threat-model.rst b/Documentation/security/threat-model.rst
index 109ff510..52412a24 100644
--- a/Documentation/security/threat-model.rst
+++ b/Documentation/security/threat-model.rst
@@ -159,8 +159,7 @@ without the protection.
``inode_remove_acl``, ``inode_file_setattr`` and
``inode_copy_up``, a ``dentry->d_parent`` the verifier trusts,
and the ``mm_read_access`` LSM hook. Upstream has none of these,
- and the `shirudo-dev/kernel project
- <https://github.com/shirudo-dev/kernel>`_ carries them in the
+ and :src:`testing/kernel/` carries them in the
target kernel build.
- T1 needs the ABI, T5 the hook, T3 the label read, the sleepable
hooks, the trusted parent and the read-only mm access hook.
@@ -797,7 +796,7 @@ receive no binding to these maps.
A labeled directory takes new entries, by create, mkdir, symlink,
mknod, hard link or rename, only from authorized tasks (``SealEntry``):
each entry hook reads the directory's label from the new entry's parent
-dentry, which the kernel project patches 0003 and 0004 (A3) make possible by
+dentry, which the carried patches 0022 and 0023 (A3) make possible by
letting a sleepable program attach to ``inode_mkdir`` and ``inode_link``
and by trusting ``dentry->d_parent``, and refreshes the directory's
mark on the way, from which ``lsm/inode_init_security`` gives the new
@@ -876,7 +875,7 @@ An authorized process is protected against being taken over:
``/proc/<pid>/exe``, ``environ``, ``maps`` and the ``fd`` links,
without a counter. ``lsm/mm_read_access`` refuses the read-only
access ``mm_access()`` would otherwise grant ``CAP_PERFMON`` past that
- refusal (kernel project patch 0005, A3).
+ refusal (carried patch 0024, A3).
- ``lsm/perf_event_alloc`` refuses a perf event bound to a marked task
(``SealPerf``). Events on all tasks of a CPU, and events opened on a
task before the exec that marks it, are not checked (D9).
diff --git a/Documentation/start/quickstart.rst b/Documentation/start/quickstart.rst
index 9cc1b960..31fb3ecc 100644
--- a/Documentation/start/quickstart.rst
+++ b/Documentation/start/quickstart.rst
@@ -40,8 +40,8 @@ Before you begin
and ``tss2-tctildr``) and LuaJIT.
- OpenSSL 3.5 or newer (``openssl version``). If it reports an older
version, follow :ref:`the developer guide's steps <dev-openssl>` first.
-- ``dpkg-deb`` to extract the test kernel, and Docker or Podman to build
- the test VM bundle.
+- ``curl``, Python 3 and ``dpkg-deb`` to fetch and extract the test
+ kernel, and Docker or Podman to build the test VM bundle.
- For the test VM, with their Debian and Ubuntu names: QEMU
(``qemu-system-x86`` or ``qemu-system-arm``), ``qemu-utils``, ``swtpm``,
``swtpm-tools``, ``tpm2-tools``, ``libtss2-tcti-swtpm0t64``,
@@ -68,12 +68,12 @@ From the checkout root, download and stage the CI kernel for your host:
operator$ testing/vm/kernel-artifact.sh fetch
-``fetch`` needs ``gh`` logged in with read access to the kernel
-repository. It selects ``kernel-packages-x86-64-ci`` or
-``kernel-packages-arm64-ci`` from the run pinned in
-:src:`testing/vm/kernel-artifact.sh`. Use ``KERNEL_RUN_ID=<run>`` to
-select another run that publishes the CI artifact for your architecture.
-If you downloaded the artifact separately, run
+``fetch`` selects the kernel bundle for your architecture from the run
+pinned in :src:`testing/vm/kernel-artifact.sh` and checks its SHA-256
+before extracting it. It downloads the prerelease ZIP from
+``shirudo-dev/shirudo`` with ``curl``. Set ``KERNEL_RUN_ID=<run>`` to
+fetch a CI artifact from a shirudo Actions run using authenticated ``gh``.
+If you downloaded the bundle separately, extract it and run
``testing/vm/kernel-artifact.sh stage <artifact-dir>``.
The artifact includes the kernel, its BTF, configuration and modules.
diff --git a/testing/Makefile b/testing/Makefile
index 3f93c83c..62f85961 100644
--- a/testing/Makefile
+++ b/testing/Makefile
@@ -63,7 +63,7 @@ TEST_VM_MEMORY ?= 4G
TEST_VM_DISK_SIZE ?= 30G
TEST_VM_UBUNTU_CODENAME ?= resolute
TEST_VM_VERBOSE ?= 0
-# Test VMs use kernel artifacts built by github.com/shirudo-dev/kernel.
+# Test VMs use kernel artifacts built from testing/kernel.
VM_KERNEL ?= $(if $(strip $(KERNEL)),$(KERNEL),bpf-next)
VM_KERNEL_VERSION := $(patsubst v%,%,$(VM_KERNEL))
VM_KERNEL_MIN := 7.4
@@ -181,7 +181,7 @@ require-vm-kernel:
[ "$(VM_KERNEL)" = bpf-next ] && \
$(ROOT)/testing/vm/kernel-artifact.sh fetch; \
} || { \
- echo "kernel artifact is missing; use github.com/shirudo-dev/kernel packages in $(VM_KERNEL_ARTIFACT_DIR)" >&2; \
+ echo "kernel artifact is missing; use CI kernel packages in $(VM_KERNEL_ARTIFACT_DIR)" >&2; \
exit 1; \
}
@@ -438,8 +438,8 @@ help:
' make -C testing fuzz [FUZZ_SECONDS=60] [FUZZ_CORPUS=<dir>] [FUZZERS=<target>...]' \
' make -C testing afl [AFL_SECONDS=600] [FUZZ_CORPUS=<dir>] [FUZZERS=<target>...]' \
' make -C testing vm, vm-console, vm-ssh, vm-enroll, vm-sbom, vm-stop, or vm-clean' \
- ' VM_KERNEL=bpf-next (default) selects the shirudo-dev/kernel artifact,' \
- ' downloaded with gh when artifacts/bpf-next-kernel-debs has none' \
+ ' VM_KERNEL=bpf-next (default) selects the pinned CI kernel artifact,' \
+ ' fetched when artifacts/bpf-next-kernel-debs has none' \
' make -C testing bundle or test-helpers' \
' make -C testing stack-up, oci, telemetry, xtop or stack-down' \
' make -C testing clean'
diff --git a/testing/functional/build/t1007-test-vm-cli.sh b/testing/functional/build/t1007-test-vm-cli.sh
index a5dde5bc..080e13ce 100755
--- a/testing/functional/build/t1007-test-vm-cli.sh
+++ b/testing/functional/build/t1007-test-vm-cli.sh
@@ -628,8 +628,8 @@ test_expect_success 'an operator VM serves without a TPM and alone gets the key'
grep -q "the operator VM has a TPM" vm/guest.sh &&
grep -q "bindeb-pkg PKG_ROLES=operator" vm/guest.sh
'
-test_expect_success 'test VMs require a kernel project artifact' '
- grep -q "github.com/shirudo-dev/kernel" ../testing/Makefile &&
+test_expect_success 'test VMs require a CI kernel artifact' '
+ grep -q "testing/kernel" ../testing/Makefile &&
grep -q "^require-vm-kernel:" ../testing/Makefile &&
! grep -q "build-kernel.sh\|KERNEL_CONFIG\|KERNEL_PATCHES" ../testing/Makefile &&
grep -q "KERNEL_CI_ARTIFACT_DIR" ../.github/scripts/tests.sh &&
@@ -638,7 +638,7 @@ test_expect_success 'test VMs require a kernel project artifact' '
test "$(KERNEL_RUN_ID=12 vm/kernel-artifact.sh run-id)" = 12 &&
test "$id" -gt 0 &&
! KERNEL_RUN_ID=1x vm/kernel-artifact.sh run-id 2>/dev/null &&
- grep -q "kernel-artifact.sh run-id" ../.github/workflows/tests.yml
+ grep -q "select-test-kernel.sh" ../.github/workflows/tests.yml
'
test_expect_success 'prepared VM runtime includes ripgrep' '
grep -qx "ripgrep" vm/runtime-packages &&
diff --git a/testing/vm/kernel-artifact.sh b/testing/vm/kernel-artifact.sh
index ecfcaab1..7ac6395d 100755
--- a/testing/vm/kernel-artifact.sh
+++ b/testing/vm/kernel-artifact.sh
@@ -2,11 +2,12 @@
# SPDX-License-Identifier: BSD-2-Clause
# Copyright (c) 2026 Authors of shirudo
#
-# testing/vm/kernel-artifact.sh -- the test VM's kernel, which
-# github.com/shirudo-dev/kernel builds and this checkout does not.
+# testing/vm/kernel-artifact.sh -- download and stage the test VM kernel.
#
# kernel-artifact.sh fetch download and stage the CI artifact for
# the test VM architecture
+# kernel-artifact.sh download download and extract it into build/
+# kernel-ci-artifact without staging
# kernel-artifact.sh stage <dir> stage an artifact already downloaded
# kernel-artifact.sh run-id print the pinned run
#
@@ -18,17 +19,19 @@
# With VM=0 it stages the BTF alone and invalidates the staged VM kernel
# if the BTF changes.
#
-# KERNEL_RUN_ID another run of the kernel project's package workflow
-# than the pinned one.
+# KERNEL_RUN_ID another run of shirudo's Build kernel packages workflow.
#
-# fetch needs gh, logged in with read access to the kernel repository.
+# Fetch the pinned prerelease with curl and python3, or an explicit
+# run override with gh and Actions read access to shirudo.
set -eu
# The run every trigger of the CI suite tests on, so that a new build of
# the kernel does not change what a series is tested on.
-PINNED_RUN_ID=45062075601
-REPOSITORY=shirudo-dev/kernel
+PINNED_RUN_ID=45212180772
+PINNED_ARM64_SHA256=13967ee9310eca1d175e9d17ee2f06254de4a9e4ab90e8b9a2f992fcba4b599b
+PINNED_AMD64_SHA256=f3e660ce7b1e0cea8d3d1c19d8f3a75097c8aa9cf1dbc10b7ad81abfa2134a9b
+KERNEL_REPOSITORY=shirudo-dev/shirudo
# A directory named from where the caller stands.
[ "${1:-}" != stage ] || [ $# -ne 2 ] || staged_from=$(realpath -- "$2")
@@ -48,7 +51,7 @@ require_lsm_hooks() {
done)
rm -f "$names"
[ -z "$missing" ] && return 0
- printf 'kernel BTF lacks the LSM hooks%s: use a shirudo-dev/kernel build\n' \
+ printf 'kernel BTF lacks the LSM hooks%s: use a build from testing/kernel\n' \
"$missing" >&2
return 1
}
@@ -195,7 +198,7 @@ run_id() {
printf '%s\n' "$id"
}
-fetch() {
+download_ci_artifact() {
id=$(run_id) || return 1
# shellcheck source=testing/vm/arch.sh
. testing/vm/arch.sh
@@ -203,20 +206,39 @@ fetch() {
echo "no CI kernel artifact for $TEST_VM_ARCH" >&2
return 1
}
- artifact="$TEST_VM_ARCH_CI_ARTIFACT"
- command -v gh >/dev/null 2>&1 || {
- echo "gh is needed to download $artifact of $REPOSITORY run $id" >&2
- return 1
- }
+ artifact=$TEST_VM_ARCH_CI_ARTIFACT
download=build/kernel-ci-artifact
- rm -rf "$download"
+ rm -rf "$download" || return 1
mkdir -p "$download" || return 1
- echo "downloading $artifact of $REPOSITORY run $id" >&2
- gh run download "$id" --repo "$REPOSITORY" --name "$artifact" \
- --dir "$download" || {
- echo "cannot download $artifact of $REPOSITORY run $id" >&2
+ echo "downloading $artifact from kernel build run $id" >&2
+
+ if [ "$id" != "$PINNED_RUN_ID" ]; then
+ command -v gh >/dev/null 2>&1 || {
+ echo "gh is needed to download $artifact of $KERNEL_REPOSITORY run $id" >&2
+ return 1
+ }
+ gh run download "$id" --repo "$KERNEL_REPOSITORY" --name "$artifact" --dir "$download"
+ return
+ fi
+
+ asset=$artifact.zip
+ archive=$download/$asset
+ url=https://github.com/$KERNEL_REPOSITORY/releases/download/test-kernel-$id/$asset
+ curl --fail --silent --show-error --location --output "$archive" "$url" || return 1
+ case "$TEST_VM_ARCH_DEB" in
+ arm64) checksum=$PINNED_ARM64_SHA256 ;;
+ amd64) checksum=$PINNED_AMD64_SHA256 ;;
+ esac
+ printf '%s %s\n' "$checksum" "$archive" | sha256sum --check --status || {
+ echo "SHA-256 mismatch for $asset from run $id" >&2
return 1
}
+ python3 -m zipfile -e "$archive" "$download" || return 1
+ rm -f "$archive"
+}
+
+fetch() {
+ download_ci_artifact || return 1
stage_kernel_ci_artifact "$download" "$TEST_VM_ARCH_DEB" || return 1
if [ "${VM:-1}" = 0 ] && [ -s "$kernel/$kernel_image_name.sha256sum" ]; then
return 0
@@ -224,20 +246,28 @@ fetch() {
printf '%s\n' "$id" >"$kernel/kernel-run-id"
}
+usage() {
+ echo "usage: kernel-artifact.sh fetch|download|stage <dir>|run-id" >&2
+ exit 2
+}
+
case "${1:-}" in
fetch)
- [ $# -eq 1 ] || { echo "usage: kernel-artifact.sh fetch" >&2; exit 2; }
+ [ $# -eq 1 ] || usage
fetch
;;
+download)
+ [ $# -eq 1 ] || usage
+ download_ci_artifact
+ ;;
stage)
- [ $# -eq 2 ] || { echo "usage: kernel-artifact.sh stage <dir>" >&2; exit 2; }
+ [ $# -eq 2 ] || usage
stage_kernel_ci_artifact "$staged_from"
;;
run-id)
run_id
;;
*)
- echo "usage: kernel-artifact.sh fetch|stage <dir>|run-id" >&2
- exit 2
+ usage
;;
esac
diff --git a/testing/vm/run.sh b/testing/vm/run.sh
index 650baf64..ad00284b 100755
--- a/testing/vm/run.sh
+++ b/testing/vm/run.sh
@@ -466,7 +466,7 @@ validate_kernel_selection()
die "kernel image not found: $KERNEL_OVERRIDE"
else
[[ -s "$DEFAULT_KERNEL" ]] ||
- die "kernel image not found: $DEFAULT_KERNEL; place a shirudo-dev/kernel build artifact there"
+ die "kernel image not found: $DEFAULT_KERNEL; stage a CI kernel artifact there"
fi
}
@@ -1493,7 +1493,7 @@ resolve_kernel()
fi
[[ -s "$DEFAULT_KERNEL" ]] ||
- die "kernel image not found: $DEFAULT_KERNEL; place a shirudo-dev/kernel build artifact there"
+ die "kernel image not found: $DEFAULT_KERNEL; stage a CI kernel artifact there"
if [[ -s "${DEFAULT_KERNEL}.sha256sum" ]]; then
(cd "$(dirname "$DEFAULT_KERNEL")" &&
sha256sum -c "${DEFAULT_KERNEL##*/}.sha256sum" >/dev/null)