Skip to contentSkip to conversation

Ease BPF signing build requirements

PATCH Applied Alan Maguire 2 participants 4 messages Nov 20, 2025 – Nov 24, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover Ease BPF signing build requirements

This series makes it easier to build bpftool and selftests with signing support, removing reliance on >= openssl v3 (supporting openssl v1) to build bpftool and not requiring latest xxd to build verification cert header in selftests.

Changes since v1 [1]:

- Updated patch 2 to add symlink test_progs_verification_cert to .gitignore, EXTRA_CLEANFILES (AI review bot)
- Added acks to patch 1 (Song, Quentin)

[1] https://lore.kernel.org/bpf/[email protected]/

Alan Maguire (2):
bpftool: Allow bpftool to build with openssl < 3 selftests/bpf: Allow selftests to build with older xxd

 tools/bpf/bpftool/sign.c               | 6 ++++++
 tools/testing/selftests/bpf/.gitignore | 1 +
 tools/testing/selftests/bpf/Makefile   | 6 ++++--
 3 files changed, 11 insertions(+), 2 deletions(-)
Signature · 1 line
2.43.5
#1 lore raw

PATCH v2 1/2 bpftool: Allow bpftool to build with openssl < 3

ERR_get_error_all()[1] is a openssl v3 API, so to make code compatible with openssl v1 utilize ERR_get_err_line_data instead. Since openssl is already a build requirement for the kernel (minimum requirement openssl 1.0.0), this will allow bpftool to compile where opensslv3 is not available. Signing-related BPF selftests pass with openssl v1.

[1] https://docs.openssl.org/3.4/man3/ERR_get_error/

Fixes 40863f4d6ef2 ("bpftool: Add support for signing BPF programs")
---
 tools/bpf/bpftool/sign.c | 6 ++++++
 1 file changed, 6 insertions(+)
tools/bpf/bpftool/sign.c +6 -0
index b34f74d210e9..f9b742f4bb10 100644
@@ -28,6 +28,12 @@
 
 #define OPEN_SSL_ERR_BUF_LEN 256
 
+/* Use deprecated in 3.0 ERR_get_error_line_data for openssl < 3 */
+#if !defined(OPENSSL_VERSION_MAJOR) || (OPENSSL_VERSION_MAJOR < 3)
+#define ERR_get_error_all(file, line, func, data, flags) \
+	ERR_get_error_line_data(file, line, data, flags)
+#endif
+
 static void display_openssl_errors(int l)
 {
 	char buf[OPEN_SSL_ERR_BUF_LEN];
Signature · 1 line
2.43.5
#2 lore raw

PATCH v2 2/2 selftests/bpf: Allow selftests to build with older xxd

In reply to Alan Maguire

Currently selftests require xxd with the "-n <name>" option which allows the user to specify a name not derived from the input object path. Instead of relying on this newer feature, older xxd can be used if we link our desired name ("test_progs_verification_cert") to the input object.

Many distros ship xxd in vim-common package and do not have the latest xxd with -n support.

Fixes b720903e2b14d ("selftests/bpf: Enable signature verification for some lskel tests")
---
 tools/testing/selftests/bpf/.gitignore | 1 +
 tools/testing/selftests/bpf/Makefile   | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/.gitignore +1 -0
index be1ee7ba7ce0..ca557e5668fd 100644
@@ -23,6 +23,7 @@ test_tcpnotify_user
 test_libbpf
 xdping
 test_cpp
+test_progs_verification_cert
 *.d
 *.subskel.h
 *.skel.h
tools/testing/selftests/bpf/Makefile +4 -2
index 34ea23c63bd5..bac22265e7ff 100644
@@ -731,7 +731,8 @@ $(VERIFICATION_CERT) $(PRIVATE_KEY): $(VERIFY_SIG_SETUP)
 	$(Q)$(VERIFY_SIG_SETUP) genkey $(BUILD_DIR)
 
 $(VERIFY_SIG_HDR): $(VERIFICATION_CERT)
-	$(Q)xxd -i -n test_progs_verification_cert $< > $@
+	$(Q)ln -fs $< test_progs_verification_cert && \
+	xxd -i test_progs_verification_cert > $@
 
 # Define test_progs test runner.
 TRUNNER_TESTS_DIR := prog_tests
@@ -905,7 +906,8 @@ EXTRA_CLEAN := $(SCRATCH_DIR) $(HOST_SCRATCH_DIR)			\
 	$(addprefix $(OUTPUT)/,*.o *.d *.skel.h *.lskel.h *.subskel.h	\
 			       no_alu32 cpuv4 bpf_gcc			\
 			       liburandom_read.so)			\
-	$(OUTPUT)/FEATURE-DUMP.selftests
+	$(OUTPUT)/FEATURE-DUMP.selftests				\
+	test_progs_verification_cert
 
 .PHONY: docs docs-clean
 
Signature · 1 line
2.43.5
#3 lore raw
In reply to Alan Maguire
This series was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:

Hello:

This series was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:

Quoted 8 lines · On Thu, 20 Nov 2025 08:47:52 +0000 you wrote:

This series makes it easier to build bpftool and selftests with signing support, removing reliance on >= openssl v3 (supporting openssl v1) to build bpftool and not requiring latest xxd to build verification cert header in selftests.

Changes since v1 [1]:

[...]

Here is the summary with links:
- [v2,1/2] bpftool: Allow bpftool to build with openssl < 3

    https://git.kernel.org/bpf/bpf-next/c/90ae54b4c7ec
  - [v2,2/2] selftests/bpf: Allow selftests to build with older xxd
    https://git.kernel.org/bpf/bpf-next/c/ad93ba02678e

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html