On Thu, Mar 30, 2023 at 10:12 AM Lorenz Bauer <lmb@xxxxxxxxxxxxx> wrote: > > On Wed, Mar 29, 2023 at 12:56 AM Andrii Nakryiko <andrii@xxxxxxxxxx> wrote: > > > > It's not clear why we have 128 as minimum size, but it makes testing > > harder and seems unnecessary, as we carefully handle truncation > > scenarios and use proper snprintf variants. So remove this limitation > > and just enfore positive length for log buffer. > > Nit: enforce life is boring without typos, will fix in the next revision (if there has to be another one) :) > > > > > Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > > Acked-by: Lorenz Bauer <lmb@xxxxxxxxxxxxx> > > > --- > > kernel/bpf/log.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/kernel/bpf/log.c b/kernel/bpf/log.c > > index 920061e38d2e..1974891fc324 100644 > > --- a/kernel/bpf/log.c > > +++ b/kernel/bpf/log.c > > @@ -11,7 +11,7 @@ > > > > bool bpf_verifier_log_attr_valid(const struct bpf_verifier_log *log) > > { > > - return log->len_total >= 128 && log->len_total <= UINT_MAX >> 2 && > > + return log->len_total > 0 && log->len_total <= UINT_MAX >> 2 && > > log->level && log->ubuf && !(log->level & ~BPF_LOG_MASK); > > Probably discussion for your second series. Thought experiment, could > this be len_total >= 0? I'm still after a way to get the correct log > buffer size from the first PROG_LOAD call. If the kernel could handle > this I could mmap a PROT_NONE page, set len_total to 0 and later read > out the correct buffer size. > > I'm guessing that the null termination logic would have to be > adjusted, anything else though? I haven't tried, but I'll check if anything needs to be adjusted. But I don't mind this semantics, it matches other places, like when getting JIT dump for program info, etc.