Ease BPF signing build requirements
Subsystems (4)
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.
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/Makefile | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-)
Signature · 1 line
2.43.5
PATCH 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/
--- tools/bpf/bpftool/sign.c | 6 ++++++ 1 file changed, 6 insertions(+)
tools/bpf/bpftool/sign.c +6 -0
@@ -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
Song Liu
reviewerRe: [PATCH bpf-next 1/2] bpftool: Allow bpftool to build with openssl < 3
Quoted 21 lines · Alan Maguire
ERR_get_error_all()[1] is a openssl v3 API, so to make code compatible with openssl v1 utilize
ERR_get_err_line_datainstead. 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")Signed-off-by Alan Maguire <[email protected]>--- tools/bpf/bpftool/sign.c | 6 ++++++ 1 file changed, 6 insertions(+)tools/bpf/bpftool/sign.c +0
-0
tools/bpf/bpftool/sign.c line 36
Quoted 9 lines
tools/bpf/bpftool/sign.c +6
-0@@ -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 +
We have func=NULL in display_openssl_errors(). Shall we just use ERR_get_error_line_data instead?
Thanks,
Song
Quoted 6 lines
tools/bpf/bpftool/sign.c +0
-1static void display_openssl_errors (int l) {char buf[OPEN_SSL_ERR_BUF_LEN ]; --2.43.5
Re: [PATCH bpf-next 1/2] bpftool: Allow bpftool to build with openssl < 3
Quoted 25 lines · Song Liu
Quoted 24 lines · Alan Maguire
ERR_get_error_all()[1] is a openssl v3 API, so to make code compatible with openssl v1 utilize
ERR_get_err_line_datainstead. 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")Signed-off-by Alan Maguire <[email protected]>--- tools/bpf/bpftool/sign.c | 6 ++++++ 1 file changed, 6 insertions(+)tools/bpf/bpftool/sign.c +0
-0@@ -28,6 +28,12 @@#define OPEN_SSL_ERR_BUF_LEN 256
Quoted 10 lines
tools/bpf/bpftool/sign.c line 36
Quoted 6 lines
tools/bpf/bpftool/sign.c +6
-0+/* 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 +We have func=NULL in
display_openssl_errors(). Shall we just useERR_get_error_line_datainstead?
It's a good idea, and I tried it - unfortunately we then get a "deprecated in v3" warning when we build with opensslv3. So this was the only way I could think of to build on v1 and not get warnings with v3.
Thanks!
Alan
Quoted 9 lines
Thanks,
SongQuoted 6 lines
tools/bpf/bpftool/sign.c +0
-1static void display_openssl_errors (int l) {char buf[OPEN_SSL_ERR_BUF_LEN ]; --2.43.5
Re: [PATCH bpf-next 1/2] bpftool: Allow bpftool to build with openssl < 3
Quoted 38 lines · Alan Maguire
Quoted 25 lines · Song Liu
Quoted 24 lines · Alan Maguire
ERR_get_error_all()[1] is a openssl v3 API, so to make code compatible with openssl v1 utilize
ERR_get_err_line_datainstead. 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")Signed-off-by Alan Maguire <[email protected]>--- tools/bpf/bpftool/sign.c | 6 ++++++ 1 file changed, 6 insertions(+)tools/bpf/bpftool/sign.c +0
-0@@ -28,6 +28,12 @@#define OPEN_SSL_ERR_BUF_LEN 256Quoted 10 lines
tools/bpf/bpftool/sign.c line 36
Quoted 6 lines
tools/bpf/bpftool/sign.c +6
-0+/* 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 +We have func=NULL in
display_openssl_errors(). Shall we just useERR_get_error_line_datainstead?
Quoted 3 lines
It's a good idea, and I tried it - unfortunately we then get a "deprecated in v3" warning when we build with opensslv3. So this was the only way I could think of to build on v1 and not get warnings with v3.
I see. Thanks for the explanation. This looks good to me.
Re: [PATCH bpf-next 1/2] bpftool: Allow bpftool to build with openssl < 3
2025-11-14 15:17 UTC-0800 ~ Song Liu <[email protected]>
Quoted 39 lines · Alan Maguire
Quoted 38 lines · Song Liu
Quoted 35 lines · Alan Maguire
Quoted 21 lines
ERR_get_error_all()[1] is a openssl v3 API, so to make code compatible with openssl v1 utilize
ERR_get_err_line_datainstead. 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")Signed-off-by Alan Maguire <[email protected]>--- tools/bpf/bpftool/sign.c | 6 ++++++ 1 file changed, 6 insertions(+)tools/bpf/bpftool/sign.c +0
-0tools/bpf/bpftool/sign.c line 36
Quoted 9 lines
tools/bpf/bpftool/sign.c +6
-0@@ -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 +We have func=NULL in
display_openssl_errors(). Shall we just useERR_get_error_line_datainstead?
Quoted 7 lines
Quoted 3 lines
It's a good idea, and I tried it - unfortunately we then get a "deprecated in v3" warning when we build with opensslv3. So this was the only way I could think of to build on v1 and not get warnings with v3.
I see. Thanks for the explanation. This looks good to me.
Acked-by Song Liu <[email protected]>
Thank you Alan!
PATCH 2/2 selftests/bpf: Allow selftests to build with older xxd
In reply to Alan MaguireCurrently 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.
--- tools/testing/selftests/bpf/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/Makefile +2 -1
@@ -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
Signature · 1 line
2.43.5
[email protected]
AI reviewRe: [PATCH bpf-next 2/2] selftests/bpf: Allow selftests to build with older xxd
Should the symlink test_progs_verification_cert be added to the cleanup targets? Currently it's not included in EXTRA_CLEAN (lines 903-909), so after running "make clean" the symlink will remain as…
tools/testing/selftests/bpf/Makefile $(VERIFICATION_CERT) $(PRIVATE_KEY): $(VERIFY_SIG_SETUP) · line 735
Quoted 11 lines
tools/testing/selftests/bpf/Makefile +2
-1@@ -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 > $@
Should the symlink test_progs_verification_cert be added to the cleanup targets? Currently it's not included in EXTRA_CLEAN (lines 903-909), so after running "make clean" the symlink will remain as a dangling link in the source tree. This will appear as an untracked file in git status and is not present in .gitignore.
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/19379374420
Re: [PATCH bpf-next 2/2] selftests/bpf: Allow selftests to build with older xxd
Quoted 7 lines · On 14/11/2025 23:06, [email protected] wrote:
Quoted 7 lines
tools/testing/selftests/bpf/Makefile +0
-0@@ -731,7 +731,8 @@ $(VERIFICATION_CERT) $(PRIVATE_KEY): $(VERIFY_SIG_SETUP) $(Q)$(VERIFY_SIG_SETUP) genkey $(BUILD_DIR)
Quoted 11 lines
tools/testing/selftests/bpf/Makefile $(VERIFICATION_CERT) $(PRIVATE_KEY): $(VERIFY_SIG_SETUP) · line 735
Quoted 4 lines
tools/testing/selftests/bpf/Makefile +2
-1$(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 > $@Should the symlink
test_progs_verification_certbe added to the cleanup targets? Currently it's not included inEXTRA_CLEAN(lines 903-909), so after running "make clean" the symlink will remain as a dangling link in the source tree. This will appear as an untracked file in git status and is not present in .gitignore.
yep, adding the symlink to EXTRA_CLEAN in Makefile and .gitignore is a good catch; I'll wait to see if there's additional feedback before sending a v2 with those changes.
Alan
Quoted 6 lines
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.mdCI run summary: https://github.com/kernel-patches/bpf/actions/runs/19379374420