Re: [syzbot] WARNING in bpf_verifier_vlog

From: sdf
Date: Fri Sep 09 2022 - 17:43:29 EST

On 09/09, Peilin Ye wrote:
Hi all,

On Fri, Sep 09, 2022 at 12:54:06PM -0700, sdf@xxxxxxxxxx wrote:
> On 09/09, Benjamin Tissoires wrote:
> Yeah, good point. I've run the repro. I think the issue is that
> syzkaller is able to pass btf with a super long random name which
> then hits BPF_VERIFIER_TMP_LOG_SIZE while printing the verifier
> log line. Seems like a non-issue to me, but maybe we need to
> add some extra validation..

In btf_func_proto_check_meta():

if (t->name_off) {
btf_verifier_log_type(env, t, "Invalid name");
return -EINVAL;

In the verifier log, maybe we should just say that BTF_KIND_FUNC_PROTO "must
not have a name" [1], instead of printing out the user-provided
(potentially very long) name and say it's "Invalid" ?

Similarly, for name-too-long errors, should we truncate the name to
KSYM_NAME_LEN bytes (see __btf_name_valid()) in the log ?

Both suggestions sound good to me. Care to cook and send a patch with a

[1] commit 2667a2626f4d ("bpf: btf: Add BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO")

Peilin Ye