On Thu, Mar 30, 2023 at 10:13 AM Lorenz Bauer <lmb@xxxxxxxxxxxxx> wrote: > > On Wed, Mar 29, 2023 at 12:56 AM Andrii Nakryiko <andrii@xxxxxxxxxx> 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@xxxxxxxxxx> > > Acked-by: Lorenz Bauer <lmb@xxxxxxxxxxxxx> > > > + /* 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? This is internal kernel implementation detail. That's how the verifier signals that there was an error during copy_to_user(). This is behavior not observable from user space at all. Why would you like to change that? bpf_attr's log_buf field will never be NULLed out, if that's what you are worried about.