selftests/bpf: Add fixed vs rotating verifier log tests
authorAndrii Nakryiko <andrii@kernel.org>
Thu, 6 Apr 2023 23:41:52 +0000 (16:41 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 11 Apr 2023 16:05:43 +0000 (18:05 +0200)
commitb1a7a480a1120d4f70305f5e8859f527e0efe4a5
treeabea301d2d0cc8de04256615a5ea897d93d49a9a
parentd0d75c67c45abd3930967dcafc82fd4505400665
selftests/bpf: Add fixed vs rotating verifier log tests

Add selftests validating BPF_LOG_FIXED behavior, which used to be the
only behavior, and now default rotating BPF verifier log, which returns
just up to last N bytes of full verifier log, instead of returning
-ENOSPC.

To stress test correctness of in-kernel verifier log logic, we force it
to truncate program's verifier log to all lengths from 1 all the way to
its full size (about 450 bytes today). This was a useful stress test
while developing the feature.

For both fixed and rotating log modes we expect -ENOSPC if log contents
doesn't fit in user-supplied log buffer.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Lorenz Bauer <lmb@isovalent.com>
Link: https://lore.kernel.org/bpf/20230406234205.323208-7-andrii@kernel.org
tools/testing/selftests/bpf/prog_tests/verifier_log.c [new file with mode: 0644]