From: Alan Maguire <alan.maguire@oracle.com>
To: Quentin Monnet <qmo@kernel.org>
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org,
yonghong.song@linux.dev, john.fastabend@gmail.com,
kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com,
jolsa@kernel.org, terrelln@fb.com, dsterba@suse.com,
acme@redhat.com, irogers@google.com, leo.yan@arm.com,
namhyung@kernel.org, tglozar@redhat.com, blakejones@google.com,
charlie@rivosinc.com, ebiggers@kernel.org, bpf@vger.kernel.org,
linux-crypto@vger.kernel.org
Subject: bpftool BPF signing supported using openssl v1? (Was Re: [RFC bpf-next 2/2] bpftool: Use libcrypto feature test to optionally support signing)
Date: Fri, 31 Oct 2025 10:11:39 +0000 [thread overview]
Message-ID: <c0350a10-b924-4a16-94fe-c7bc21af26a0@oracle.com> (raw)
In-Reply-To: <fc3a12bf-8b79-4ba9-8129-a4ad11c4852e@kernel.org>
On 30/10/2025 13:58, Quentin Monnet wrote:
> 2025-10-29 11:22 UTC+0000 ~ Alan Maguire <alan.maguire@oracle.com>
>> On 29/10/2025 10:40, Quentin Monnet wrote:
>>> 2025-10-29 09:46 UTC+0000 ~ Alan Maguire <alan.maguire@oracle.com>
>>>> New libcrypto test verifies presence of openssl3 needed for BPF
>>>> signing; use that feature to conditionally compile signing-related
>>>> code so bpftool build will not break in the absence of libcrypto v3.
>>>
>>>
>>> Hi Alan, thanks for this work!
>>>
>>>
>>>>
>>>> Fixes: 40863f4d6ef2 ("bpftool: Add support for signing BPF programs")
>>>> Suggested-by: Quentin Monnet <qmo@kernel.org>
>>>
>>>
>>> This is not exactly what I suggested, I mentioned adding such a feature
>>> check and printing a more user-friendly error message at build time if
>>> the dependency is missing, not leaving out the program signing feature.
>>>
>>> I've got reservations about the current approach: my concern is that
>>> people packaging bpftool may prefer to compile and ship it without
>>> program signing, if their build environment does not include the OpenSSL
>>> dependency. But it seems to me that it will be an important feature
>>> going forward, and that bpftool should ship with it.
>>>
>>> Regarding the OpenSSL v3 vs. older version concern (from the build
>>> failure report thread):
>>>
>>>> One issue here is that some distros package openssl v3 such that the
>>>> #include files are in /usr/include/openssl3 and libraries in
>>>> /usr/lib64/openssl3 so that older versions can co-exist. Maybe we could
>>>> figure out a feature test that handles that too?
>>>
>>> In that case, we should have a feature probe that gives us the right
>>> build parameters to ensure that v3, and not some older version, is
>>> picked when building bpftool? (We could imagine falling back to an older
>>> version, but I see v3.0 is now the oldest OpenSSL supported version so
>>> it's probably not worth it?)
>>>
>>
>> Actually there may be a simpler solution here; compilation at least
>> succeeds for openssl < 3 with the following change
>>
>> diff --git a/tools/bpf/bpftool/sign.c b/tools/bpf/bpftool/sign.c
>> index b34f74d210e9..f9b742f4bb10 100644
>> --- a/tools/bpf/bpftool/sign.c
>> +++ b/tools/bpf/bpftool/sign.c
>> @@ -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];
>>
>>
>> Given that openssl is already a build requirement for the kernel, that
>> may well be enough to resolve this issue without feature tests etc.
>> However I can't speak to whether there are other issues with using
>> openssl v1 aside from compile-time problem this solves.
>
>
> I'm equally unfamiliar with the risks associated with older OpenSSL
> versions. Other than that, it sounds like a good solution to me. As
> Namhyung pointed out, bpftool's build affects other things like perf, or
> kernel build itself (for preloaded BPF iterators), so aligning
> requirements with the ones from the kernel would make sense. From
> Documentation/process/changes.rst I see that the minimal requirement for
> OpenSSL is v1.0.0, so your suggestion is probably acceptable?
>
Sounds good to me! Would be good to get clarification from KP if
opensslv1 is acceptable as I couldn't find any openssl versioning
specific discussion in the threads; changed the subject line
accordingly. KP is openssl v1 ok? FWIW the BPF fentry_fexit tests that
use signed lskels do pass when run using bpftool+openssl v1 for me:
$ sudo ./test_progs -vvv -t fentry_fexit
bpf_testmod.ko is already unloaded.
Loading bpf_testmod.ko...
Successfully loaded bpf_testmod.ko.
test_fentry_fexit:PASS:fentry_skel_load 0 nsec
test_fentry_fexit:PASS:fentry_skel_load 0 nsec
test_fentry_fexit:PASS:fexit_skel_load 0 nsec
test_fentry_fexit:PASS:fexit_skel_load 0 nsec
test_fentry_fexit:PASS:fentry_attach 0 nsec
test_fentry_fexit:PASS:fexit_attach 0 nsec
test_fentry_fexit:PASS:ipv6 test_run 0 nsec
test_fentry_fexit:PASS:ipv6 test retval 0 nsec
test_fentry_fexit:PASS:fentry result 0 nsec
test_fentry_fexit:PASS:fexit result 0 nsec
test_fentry_fexit:PASS:fentry result 0 nsec
test_fentry_fexit:PASS:fexit result 0 nsec
test_fentry_fexit:PASS:fentry result 0 nsec
test_fentry_fexit:PASS:fexit result 0 nsec
test_fentry_fexit:PASS:fentry result 0 nsec
test_fentry_fexit:PASS:fexit result 0 nsec
test_fentry_fexit:PASS:fentry result 0 nsec
test_fentry_fexit:PASS:fexit result 0 nsec
test_fentry_fexit:PASS:fentry result 0 nsec
test_fentry_fexit:PASS:fexit result 0 nsec
test_fentry_fexit:PASS:fentry result 0 nsec
test_fentry_fexit:PASS:fexit result 0 nsec
test_fentry_fexit:PASS:fentry result 0 nsec
test_fentry_fexit:PASS:fexit result 0 nsec
#108 fentry_fexit:OK
Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED
$ ldd tools/sbin/bpftool
linux-vdso.so.1 (0x00007f5497efc000)
libelf.so.1 => /usr/lib64/libelf.so.1 (0x00007f5497800000)
libz.so.1 => /usr/lib64/libz.so.1 (0x00007f5497400000)
libcrypto.so.1.1 => /usr/lib64/libcrypto.so.1.1 (0x00007f5496e00000)
^^^^^^^^^^^^^^
openssl v1
prev parent reply other threads:[~2025-10-31 10:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-29 9:46 [RFC bpf-next 0/2] bpftool signing feature check Alan Maguire
2025-10-29 9:46 ` [RFC bpf-next 1/2] tools-build: Add feature test for openssl3 Alan Maguire
2025-10-29 9:46 ` [RFC bpf-next 2/2] bpftool: Use libcrypto feature test to optionally support signing Alan Maguire
2025-10-29 10:15 ` bot+bpf-ci
2025-10-29 10:40 ` Quentin Monnet
2025-10-29 11:22 ` Alan Maguire
2025-10-30 13:58 ` Quentin Monnet
2025-10-31 10:11 ` Alan Maguire [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c0350a10-b924-4a16-94fe-c7bc21af26a0@oracle.com \
--to=alan.maguire@oracle.com \
--cc=acme@redhat.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=blakejones@google.com \
--cc=bpf@vger.kernel.org \
--cc=charlie@rivosinc.com \
--cc=daniel@iogearbox.net \
--cc=dsterba@suse.com \
--cc=ebiggers@kernel.org \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=irogers@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=leo.yan@arm.com \
--cc=linux-crypto@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=namhyung@kernel.org \
--cc=qmo@kernel.org \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=terrelln@fb.com \
--cc=tglozar@redhat.com \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox