Skip to content

eBPF-based security platform

packaging: make the operator packages depend on clang 23

Daniel Borkmann20c4a93c1b0e
diff --git a/.github/workflows/deb.yml b/.github/workflows/deb.yml
index fd569760..6cc0bfa7 100644
--- a/.github/workflows/deb.yml
+++ b/.github/workflows/deb.yml
@@ -296,7 +296,7 @@ jobs:
SHIRUDO_GIT_DESCRIBE='printenv SHIRUDO_CI_VERSION'
cmp bpf-next/vmlinux.h build/rpm/operator/usr/share/shirudo/vmlinux.h
rpm -qpi shirudo-operator-*.rpm
- rpm -qp --requires shirudo-operator-*.rpm | grep -qx clang
+ rpm -qp --requires shirudo-operator-*.rpm | grep -qx 'clang >= 23'
.github/scripts/gen-sbom.sh shirudo-operator-*.rpm
- name: Install, exercise and remove both packages
diff --git a/.github/workflows/kernel-obs.yml b/.github/workflows/kernel-obs.yml
index 0c636b63..9ec8700e 100644
--- a/.github/workflows/kernel-obs.yml
+++ b/.github/workflows/kernel-obs.yml
@@ -164,7 +164,6 @@ jobs:
/bin/sh /host/.github/scripts/kernel-obs-apt-diagnostics.sh
exit 1
fi
- sh /host/.github/scripts/install-clang.sh
keys_dir=/host/.ci/kernel-obs-keys
version=\$(cat /host/build/kernel-obs-version)
diff --git a/Documentation/contribute/testing/test-coverage.rst b/Documentation/contribute/testing/test-coverage.rst
index c78eb44d..7d4d87af 100644
--- a/Documentation/contribute/testing/test-coverage.rst
+++ b/Documentation/contribute/testing/test-coverage.rst
@@ -80,7 +80,9 @@ signed config image.
* - ``t1004-target-system-libdir``
- Where ``make target-deps`` finds the system static archives
* - ``t1005-binrpm-pkg``
- - rpm packages: metadata, file lists, requirements and scriptlets
+ - rpm packages: metadata, file lists, requirements and scriptlets;
+ the clang 23 requirement of both operator packages and the clang
+ path of the Debian one
* - ``t1006-gen-initrd-cli``
- Initrd generator and installer options, the installer's
``--dry-run`` plan
diff --git a/Documentation/operate/plan/system-requirements.rst b/Documentation/operate/plan/system-requirements.rst
index 0803624d..e3c1e8ee 100644
--- a/Documentation/operate/plan/system-requirements.rst
+++ b/Documentation/operate/plan/system-requirements.rst
@@ -411,10 +411,11 @@ keyrings. Any Linux kernel on which the tools below run serves.
``tss2-tctildr``, ``libelf``, ``zlib``, LuaJIT
- Linked by the ``shirudo`` binary, which is the same program on
both roles.
- * - ``clang`` and LLVM 23 with the BPF target, ``clang`` installed as
- ``/usr/bin/clang``
- - ``shirudo build`` runs that path and does not search ``PATH``.
- It compiles for BPF instruction set v4.
+ * - ``clang`` and LLVM 23 with the BPF target
+ - ``shirudo build`` runs ``/usr/bin/clang``, and the helper of the
+ Debian package ``/usr/lib/llvm-23/bin/clang``. It does not search
+ ``PATH``; ``make SHIRUDO_CLANG_PATH=<path>`` builds a helper that
+ runs another. It compiles for BPF instruction set v4.
* - The target kernel's ``vmlinux.h``
- The one kernel-derived input of a build. ``shirudo build`` takes
``--vmlinux``, else ``./vmlinux.h``, else
@@ -431,10 +432,14 @@ keyrings. Any Linux kernel on which the tools below run serves.
- ``shirudo`` and ``shirudo-build`` lock all their memory before
they dispatch a command.
-The operator package depends on ``clang``, ``llvm`` and the
-``veritysetup`` package. Where the distribution's ``clang`` is older than
-23, install clang 23 and point ``/usr/bin/clang`` at it. The operator and
-target packages conflict, so one host cannot install both.
+The operator package depends on clang 23, as ``clang-23`` in the Debian
+package and ``clang >= 23`` in the RPM, and on ``llvm`` and the
+``veritysetup`` package. Debian unstable, Fedora 45 and apt.llvm.org
+ship clang 23. On Debian testing or Ubuntu 24.04, add Debian unstable or
+apt.llvm.org as a package source before you install the package. A
+build from source runs ``/usr/bin/clang``, so point that at clang 23.
+The operator and target packages conflict, so one host cannot install
+both.
Build host for the target binary
--------------------------------
diff --git a/Documentation/reference/cli/build.rst b/Documentation/reference/cli/build.rst
index 166dddc6..1e8a18bc 100644
--- a/Documentation/reference/cli/build.rst
+++ b/Documentation/reference/cli/build.rst
@@ -13,7 +13,7 @@ unload directive for a loaded upatch.
Runs on: operator host, without the image gate. Requires: the
``shirudo-build`` helper, the signing key and certificate, and for a
-``.bpf.c`` input ``/usr/bin/clang`` and a ``vmlinux.h``. Changes measured
+``.bpf.c`` input clang 23 and a ``vmlinux.h``. Changes measured
state: no.
Usage
@@ -65,7 +65,8 @@ Building a upatch
directory, the libbpf headers and the shirudo BPF headers on the
include path, plus ``--extra-cflags``. ``-mcpu=v4`` selects BPF
instruction set v4, the newest clang knows and one every target kernel
- runs. The clang path is fixed when the helper is built, and ``PATH`` is
+ runs. The clang path is fixed when the helper is built,
+ ``/usr/lib/llvm-23/bin/clang`` in the Debian package, and ``PATH`` is
not searched. The object goes to a temporary file in
``/tmp``, or with ``--emit-artifacts`` beside the output.
#. A ``.bpf.o`` or ``.o`` input is packaged as it is. Any other input is
diff --git a/Documentation/reference/environment.rst b/Documentation/reference/environment.rst
index 2a768dfd..6347f740 100644
--- a/Documentation/reference/environment.rst
+++ b/Documentation/reference/environment.rst
@@ -73,8 +73,9 @@ shirudo and shirudo-build
* - ``PATH``
- ``shirudo`` looking up ``shirudo-build``; ``shirudo-build``
running ``veritysetup``; the generator scripts
- - Search path. ``shirudo-build`` runs ``clang`` from the fixed path
- ``/usr/bin/clang`` only.
+ - Search path. ``shirudo-build`` runs ``clang`` only from the path
+ fixed when it was built: ``/usr/bin/clang``, or
+ ``/usr/lib/llvm-23/bin/clang`` in the Debian package.
* - ``SHIRUDO_INIT_ARGS``
- ``shirudo.service``, from ``/etc/shirudo/init.env``
- Arguments appended to ``init``. ``init`` accepts only
diff --git a/Documentation/reference/files.rst b/Documentation/reference/files.rst
index f2c9d307..b09843ba 100644
--- a/Documentation/reference/files.rst
+++ b/Documentation/reference/files.rst
@@ -55,10 +55,12 @@ Operator host
- none
- none
- Searched in this order when ``--vmlinux`` is not given.
- * - ``/usr/bin/clang``
+ * - ``/usr/bin/clang``, ``/usr/lib/llvm-23/bin/clang`` in the Debian
+ package
- none
- none
- - The compiler ``shirudo-build`` executes for ``.bpf.c`` input.
+ - The compiler ``shirudo-build`` executes for ``.bpf.c`` input,
+ clang 23.
* - ``/tmp/shirudo-build-XXXXXX.bpf.o``
- ``build``
- none
diff --git a/Documentation/start/install.rst b/Documentation/start/install.rst
index 9fc4ba4e..c4912ee2 100644
--- a/Documentation/start/install.rst
+++ b/Documentation/start/install.rst
@@ -50,8 +50,10 @@ Packages
- the BPF headers under ``/usr/share/shirudo/bpf/include/``
- bash completion
- It depends on clang, LLVM and ``veritysetup`` (``cryptsetup-bin``
- or ``cryptsetup``) and installs no systemd unit.
+ It depends on clang 23, LLVM and ``veritysetup``
+ (``cryptsetup-bin`` or ``cryptsetup``) and installs no systemd
+ unit. :doc:`/operate/plan/system-requirements` says where clang 23
+ comes from.
* - ``shirudo-target``
- Target
- - ``/usr/bin/shirudo``, a static PIE
diff --git a/Documentation/start/quickstart.rst b/Documentation/start/quickstart.rst
index def7a7cd..b04bb4fe 100644
--- a/Documentation/start/quickstart.rst
+++ b/Documentation/start/quickstart.rst
@@ -27,7 +27,7 @@ Before you begin
- Network access. The first boot clones the bpf-next kernel tree and
downloads an Ubuntu cloud image.
- To build shirudo: a C toolchain with ``make`` and ``pkg-config``, a
- current clang and LLVM with the BPF target, installed as
+ clang and LLVM 23 with the BPF target, ``clang`` installed as
``/usr/bin/clang``, and the development files of OpenSSL 3.5 or later,
libelf, zlib, libcurl 7.75 or later, tpm2-tss (``tss2-esys`` 4.0 or later
and ``tss2-tctildr``) and LuaJIT.
diff --git a/Documentation/upatches/learn/kernel-fix-tutorial.rst b/Documentation/upatches/learn/kernel-fix-tutorial.rst
index 829e0699..7677abf3 100644
--- a/Documentation/upatches/learn/kernel-fix-tutorial.rst
+++ b/Documentation/upatches/learn/kernel-fix-tutorial.rst
@@ -19,7 +19,8 @@ Before you begin
----------------
- A shirudo checkout built with ``make`` and ``make shirudo-build``, and
- clang installed as ``/usr/bin/clang``, the path the build helper runs.
+ clang 23 installed as ``/usr/bin/clang``, the path the build helper
+ runs.
- A test VM running from that checkout, as :doc:`/upatches/test/testing`
describes. The
steps below use the default ``bpf-next`` VM and the signing key its
diff --git a/Makefile.shirudo b/Makefile.shirudo
index c658c44d..23cffd72 100644
--- a/Makefile.shirudo
+++ b/Makefile.shirudo
@@ -72,6 +72,8 @@ SHIRUDO_LIBEXEC_DIR ?= $(libexecdir)/shirudo
SHIRUDO_BPF_INCDIR ?= $(sharedir)/shirudo/bpf/include
# Installed kernel BTF types used as the default vmlinux.h fallback.
SHIRUDO_VMLINUX_PATH ?= $(sharedir)/shirudo/vmlinux.h
+# The clang shirudo-build runs, as it never searches PATH.
+SHIRUDO_CLANG_PATH ?= /usr/bin/clang
# A warning fails the build, ours and that of the vendored libbpf and
# the BPF objects alike; WERROR=0 lets a compiler newer than the tree
@@ -134,7 +136,8 @@ CFLAGS_BASE := -O2 $(DEBUG_CFLAGS) -std=gnu11 $(WARNINGS) $(CC_WARNINGS) \
-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE \
-DLIBEXEC_DIR='"$(SHIRUDO_LIBEXEC_DIR)"' \
-DBPF_INCDIR='"$(SHIRUDO_BPF_INCDIR)"' \
- -DVMLINUX_PATH='"$(SHIRUDO_VMLINUX_PATH)"'
+ -DVMLINUX_PATH='"$(SHIRUDO_VMLINUX_PATH)"' \
+ -DCLANG_PATH='"$(SHIRUDO_CLANG_PATH)"'
# make SANITIZE=address,undefined instruments the host-side binaries and
# the test helpers; BPF objects come from clang -target bpf and are never
diff --git a/packaging/Makefile b/packaging/Makefile
index 7b2286dd..4669bf61 100644
--- a/packaging/Makefile
+++ b/packaging/Makefile
@@ -96,6 +96,11 @@ RPM_STAGE_PATH := $(call root-path,$(RPM_STAGE))
RPM_TARGET_PKG_PATH := $(call root-path,$(RPM_TARGET_PKG))
RPM_OPERATOR_PKG_PATH := $(call root-path,$(RPM_OPERATOR_PKG))
+# Debian's clang-23, which the operator package depends on, installs clang
+# under /usr/lib/llvm-23 and leaves /usr/bin/clang to the distribution's
+# default release, so the helper of that package runs it from there.
+DEB_CLANG := SHIRUDO_CLANG_PATH=/usr/lib/llvm-23/bin/clang
+
PKG_PATHS := prefix=$(PKG_PREFIX) exec_prefix=$(PKG_PREFIX) \
bindir=$(PKG_PREFIX)/bin libexecdir=$(PKG_PREFIX)/libexec \
sharedir=$(PKG_PREFIX)/share libdir=$(PKG_PREFIX)/lib \
@@ -150,14 +155,14 @@ bindeb-pkg:
exit 1; }
@printf ' CLEAN (rebuild with prefix=$(PKG_PREFIX) for packaging)\n'
+$(Q)$(MAKE) -C $(ROOT) clean
- +$(Q)$(MAKE) -C $(ROOT) $(PKG_PATHS) all $(if $(filter operator,$(PKG_ROLES)),shirudo-build)
+ +$(Q)$(MAKE) -C $(ROOT) $(PKG_PATHS) $(DEB_CLANG) all $(if $(filter operator,$(PKG_ROLES)),shirudo-build)
$(Q)rm -rf $(DEB_STAGE_PATH) \
$(if $(filter target,$(PKG_ROLES)),$(DEB_TARGET_PKG_PATH)) \
$(if $(filter operator,$(PKG_ROLES)),$(DEB_OPERATOR_PKG_PATH))
$(if $(filter target,$(PKG_ROLES)),@printf ' STAGE $(DEB_STAGE_PATH)/target\n')
$(if $(filter target,$(PKG_ROLES)),+$(Q)$(MAKE) -C $(ROOT) $(PKG_PATHS) DESTDIR=$(DEB_STAGE_PATH)/target install-target)
$(if $(filter operator,$(PKG_ROLES)),@printf ' STAGE $(DEB_STAGE_PATH)/operator\n')
- $(if $(filter operator,$(PKG_ROLES)),+$(Q)$(MAKE) -C $(ROOT) $(PKG_PATHS) DESTDIR=$(DEB_STAGE_PATH)/operator install-operator)
+ $(if $(filter operator,$(PKG_ROLES)),+$(Q)$(MAKE) -C $(ROOT) $(PKG_PATHS) $(DEB_CLANG) DESTDIR=$(DEB_STAGE_PATH)/operator install-operator)
$(if $(filter target,$(PKG_ROLES)),$(Q)$(ROOT)/packaging/deb/builddeb.sh target $(DEB_STAGE_PATH)/target \
'$(DEB_VERSION)' '$(DEB_ARCH)' '$(PKG_MAINTAINER)' $(DEB_TARGET_PKG_PATH))
$(if $(filter operator,$(PKG_ROLES)),$(Q)$(ROOT)/packaging/deb/builddeb.sh operator $(DEB_STAGE_PATH)/operator \
diff --git a/packaging/deb/builddeb.sh b/packaging/deb/builddeb.sh
index c4084195..d47f6c24 100755
--- a/packaging/deb/builddeb.sh
+++ b/packaging/deb/builddeb.sh
@@ -60,7 +60,7 @@ esac
depends=$("$here/depends.sh" $bins || true)
if [ "$role" = operator ]; then
# Operator-only compilers and the standard image format/verify tool.
- depends="${depends:+$depends, }clang, llvm, cryptsetup-bin"
+ depends="${depends:+$depends, }clang-23, llvm, cryptsetup-bin"
fi
# Installed-Size is in KiB, computed before DEBIAN/ exists.
diff --git a/packaging/rpm/buildrpm.sh b/packaging/rpm/buildrpm.sh
index 937c3512..4d69e001 100755
--- a/packaging/rpm/buildrpm.sh
+++ b/packaging/rpm/buildrpm.sh
@@ -86,7 +86,7 @@ dirs=$(cd "$stage" && find . -mindepth 1 -type d -path '*/shirudo*' | sed 's#^\.
printf 'Conflicts: %s\n' "$other"
if [ "$role" = operator ]; then
# Operator-only compilers and the standard image format/verify tool.
- printf 'Requires: bash, coreutils, clang, llvm, cryptsetup\n'
+ printf 'Requires: bash, coreutils, clang >= 23, llvm, cryptsetup\n'
fi
printf '\n%%description\n'
if [ "$role" = target ]; then
diff --git a/testing/functional/build/t1005-binrpm-pkg.sh b/testing/functional/build/t1005-binrpm-pkg.sh
index f22d36c3..806382cf 100644
--- a/testing/functional/build/t1005-binrpm-pkg.sh
+++ b/testing/functional/build/t1005-binrpm-pkg.sh
@@ -114,7 +114,7 @@ test_expect_success 'buildrpm.sh gives the operator its compiler and verity tool
rpm -qp --qf "%{NAME} %{VERSION} %{RELEASE}\n" "$WORK/operator.rpm" |
grep -qx "shirudo-operator 1.2.3 1" &&
rpm -qp --conflicts "$WORK/operator.rpm" | grep -qx "shirudo-target" &&
- rpm -qp --requires "$WORK/operator.rpm" | grep -qx clang &&
+ rpm -qp --requires "$WORK/operator.rpm" | grep -qx "clang >= 23" &&
rpm -qp --requires "$WORK/operator.rpm" | grep -qx llvm &&
rpm -qp --requires "$WORK/operator.rpm" | grep -qx cryptsetup &&
rpm -qpl "$WORK/operator.rpm" >"$WORK/operator.files" &&
@@ -127,7 +127,7 @@ test_expect_success 'buildrpm.sh gives the operator its compiler and verity tool
'
if command -v dpkg-deb >/dev/null 2>&1; then
- test_expect_success 'Debian packages require veritysetup only for the operator' '
+ test_expect_success 'Debian packages require clang 23 and veritysetup only for the operator' '
arch=$(dpkg --print-architecture) &&
../packaging/deb/builddeb.sh target "$WORK/target" 1.2.3 "$arch" \
"Test <[email protected]>" "$WORK/target.deb" >/dev/null &&
@@ -136,11 +136,13 @@ if command -v dpkg-deb >/dev/null 2>&1; then
dpkg-deb -f "$WORK/target.deb" Depends >"$WORK/target.deb.requires" &&
dpkg-deb -f "$WORK/operator.deb" Depends >"$WORK/operator.deb.requires" &&
! grep -q cryptsetup "$WORK/target.deb.requires" &&
- grep -Eq "(^|, )cryptsetup-bin(,|$)" "$WORK/operator.deb.requires"
+ ! grep -q clang "$WORK/target.deb.requires" &&
+ grep -Eq "(^|, )cryptsetup-bin(,|$)" "$WORK/operator.deb.requires" &&
+ grep -Eq "(^|, )clang-23(,|$)" "$WORK/operator.deb.requires"
'
else
TAP_COUNT=$((TAP_COUNT + 1))
- printf 'ok %d - Debian operator verity dependency # SKIP no dpkg-deb\n' "$TAP_COUNT"
+ printf 'ok %d - Debian operator clang and verity dependencies # SKIP no dpkg-deb\n' "$TAP_COUNT"
fi
test_expect_success 'buildrpm.sh rejects a dash in version or release and an unknown role' '
@@ -175,6 +177,14 @@ test_expect_success 'PKG_ROLES=operator leaves the target package and its static
! grep -q "builddeb.sh operator" "$WORK/plan-deb"
'
+test_expect_success 'only the Debian helper runs clang 23 from /usr/lib/llvm-23' '
+ (cd .. && make -n -C packaging bindeb-pkg PKG_ROLES=operator \
+ >"$WORK/plan-deb-op" 2>&1) &&
+ test "$(grep -c "SHIRUDO_CLANG_PATH=/usr/lib/llvm-23/bin/clang" \
+ "$WORK/plan-deb-op")" -eq 2 &&
+ ! grep -q SHIRUDO_CLANG_PATH "$WORK/plan-op"
+'
+
test_expect_success 'static PIE target packages do not require a shared runtime or loader' '
cc -static-pie -static-libgcc -o "$WORK/static-stub" "$WORK/stub.c" &&
install -m 0755 "$WORK/static-stub" "$WORK/target/usr/bin/shirudo" &&