Re: [PATCH v2 bpf-next 6/6] selftests/bpf: add fixed vs rotating verifier log tests

Lorenz Bauer
2023-03-30T17:13:13Z

On Wed, Mar 29, 2023 at 12:56 AM Andrii Nakryiko <andrii@kernel.org> wrote:
>
> 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>

Acked-by: Lorenz Bauer <lmb@isovalent.com>

> + /* validate BPF_LOG_FIXED works as verifier log used to work, that is:
> + * we get -ENOSPC and beginning of the full verifier log. This only
> + * works for log_level 2 and log_level 1 + failed program. For log
> + * level 2 we don't reset log at all. For log_level 1 + failed program
> + * we don't get to verification stats output. With log level 1
> + * for successful program final result will be just verifier stats.
> + * But if provided too short log buf, kernel will NULL-out log->ubuf

Out of curiousity: why is ubuf NULLed? Is that something we could change?