Re: [PATCH bpf-next 2/2] selftests: bpf: crypto skcipher algo selftests

Vadim Fedorenko
2023-10-26T18:27:40Z

On 26/10/2023 15:02, Daniel Borkmann wrote:
> On 10/26/23 3:59 AM, Vadim Fedorenko wrote:
>> Add simple tc hook selftests to show the way to work with new crypto
>> BPF API. Some weird structre and map are added to setup program to make
>> verifier happy about dynptr initialization from memory. Simple AES-ECB
>> algo is used to demonstrate encryption and decryption of fixed size
>> buffers.
>>
>> Signed-off-by: Vadim Fedorenko <vadfed@meta.com>
>> ---
>>   tools/testing/selftests/bpf/config            |   1 +
>>   .../selftests/bpf/prog_tests/crypto_sanity.c  | 129 +++++++++++++++
>>   .../selftests/bpf/progs/crypto_common.h       |  98 +++++++++++
>>   .../selftests/bpf/progs/crypto_sanity.c       | 154 ++++++++++++++++++
>>   4 files changed, 382 insertions(+)
>>   create mode 100644
>> tools/testing/selftests/bpf/prog_tests/crypto_sanity.c
>>   create mode 100644 tools/testing/selftests/bpf/progs/crypto_common.h
>>   create mode 100644 tools/testing/selftests/bpf/progs/crypto_sanity.c
>>
>> diff --git a/tools/testing/selftests/bpf/config
>> b/tools/testing/selftests/bpf/config
>> index 02dd4409200e..2a5d6339831b 100644
>> --- a/tools/testing/selftests/bpf/config
>> +++ b/tools/testing/selftests/bpf/config
>> @@ -14,6 +14,7 @@ CONFIG_CGROUP_BPF=y
>>   CONFIG_CRYPTO_HMAC=y
>>   CONFIG_CRYPTO_SHA256=y
>>   CONFIG_CRYPTO_USER_API_HASH=y
>> +CONFIG_CRYPTO_SKCIPHER=y
>>   CONFIG_DEBUG_INFO=y
>>   CONFIG_DEBUG_INFO_BTF=y
>>   CONFIG_DEBUG_INFO_DWARF4=y
>
> Quick note: for upstream CI side, more config seems missing, see the GHA
> failure:

Thanks for the signal, Daniel. Looks like CONFIG_CRYPTO_ECB is missing.
I'll adjust config for v2, but I'll wait a bit longer to get more
feedback

> https://github.com/kernel-patches/bpf/actions/runs/6654055344/job/18081734522
>
> Notice: Success: 435/3403, Skipped: 32, Failed: 1
> Error: #64 crypto_sanity
>   Error: #64 crypto_sanity
>   test_crypto_sanity:PASS:skel open 0 nsec
>   test_crypto_sanity:PASS:ip netns add crypto_sanity_ns 0 nsec
>   test_crypto_sanity:PASS:ip -net crypto_sanity_ns -6 addr add
> face::1/128 dev lo nodad 0 nsec
>   test_crypto_sanity:PASS:ip -net crypto_sanity_ns link set dev lo up 0
> nsec
>   test_crypto_sanity:PASS:crypto_sanity__load 0 nsec
>   open_netns:PASS:malloc token 0 nsec
>   open_netns:PASS:open /proc/self/ns/net 0 nsec
>   open_netns:PASS:open netns fd 0 nsec
>   open_netns:PASS:setns 0 nsec
>   test_crypto_sanity:PASS:open_netns 0 nsec
>   test_crypto_sanity:PASS:if_nametoindex lo 0 nsec
>   test_crypto_sanity:PASS:crypto_sanity__attach 0 nsec
>   test_crypto_sanity:PASS:skb_crypto_setup fd 0 nsec
>   test_crypto_sanity:PASS:skb_crypto_setup 0 nsec
>   test_crypto_sanity:PASS:skb_crypto_setup retval 0 nsec
>   test_crypto_sanity:FAIL:skb_crypto_setup status unexpected error: -95
> (errno 2)
>   libbpf: Kernel error message: Parent Qdisc doesn't exists
>   close_netns:PASS:setns 0 nsec
> Test Results:
>              bpftool: PASS
>  test_progs-no_alu32: FAIL (returned 1)
>             shutdown: CLEAN
> Error: Process completed with exit code 1.