All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Hwang <leon.hwang@linux.dev>
To: bot+bpf-ci@kernel.org, bpf@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com,
	andrii@kernel.org, eddyz87@gmail.com, memxor@gmail.com,
	martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev,
	jolsa@kernel.org, emil@etsalapatis.com, ihor.solodrai@linux.dev,
	rostedt@goodmis.org, mhiramat@kernel.org,
	mathieu.desnoyers@efficios.com, kpsingh@kernel.org,
	matt@bobrowski.net, shuah@kernel.org,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, netdev@vger.kernel.org,
	martin.lau@kernel.org, mason@kernel.org
Subject: Re: [PATCH bpf-next 5/9] libbpf: Add log_opts support for BPF_TRACE_ITER
Date: Wed, 11 Nov 2026 23:32:50 +0800	[thread overview]
Message-ID: <ab4e5c29-b835-4ea8-853b-57ae7ad2eafe@linux.dev> (raw)
In-Reply-To: <8b9e5217cbe9c192e678ce5c8d59f573c80a659d72211f5b91c905ed00ebb799@mail.kernel.org>

On 2026/11/9 22:47, bot+bpf-ci@kernel.org wrote:
>> libbpf: Add log_opts support for BPF_TRACE_ITER
> 
> TL;DR:
> - libbpf BPF_TRACE_ITER case may not reject stray bytes after iter.len
>   (missing OPTS_ZEROED check), so unknown fields could be silently ignored
> - Nit: iter.len test in the legacy branch looks like dead code
> 
>> diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
>> --- a/tools/lib/bpf/bpf.c
>> +++ b/tools/lib/bpf/bpf.c
> 
> [ ... ]
> 
>> @@ -821,6 +816,16 @@ int bpf_link_create(int prog_fd, int target_fd,
>>  			return libbpf_err(-EINVAL);
>>  	}
>>  
>> +	if (iter_info_len) {
>> +		if (OPTS_GET(opts, iter.len, 0))
>> +			return libbpf_err(-EINVAL);
>> +		iter_info = OPTS_GET(opts, iter_info, (void *)0);
>> +	} else {
>> +		log_opts = OPTS_GET(opts, log_opts, (void *)0);
>> +		iter_info = OPTS_GET(opts, iter.info, (void *)0);
>> +		iter_info_len = OPTS_GET(opts, iter.len, 0);
>> +	}
>> +
> 
> When the legacy iter_info_len is non-zero, the check above already requires
> OPTS_ZEROED(opts, target_btf_id), which covers every byte from that offset
> up to sz, including iter.info and iter.len.  Can this OPTS_GET(opts,
> iter.len, 0) test ever be true?  It looks like dead code.
> 

Will drop the iter.len check.

> [ ... ]
> 
>>  	switch (attach_type) {
>>  	case BPF_TRACE_ITER:
>>  		attr.link_create.iter_info = ptr_to_u64(iter_info);
>>  		attr.link_create.iter_info_len = iter_info_len;
>>  		break;
> 
> Every other union member's case ends with a check such as:
> 
>     if (!OPTS_ZEROED(opts, tracing_multi))
>             return libbpf_err(-EINVAL);
> 
> Should the BPF_TRACE_ITER case do the same with OPTS_ZEROED(opts, iter)?

Will add OPTS_ZEROED(opts, iter) check.

Thanks,
Leon

> 
> On the new iter.info/iter.len path, nothing checks the bytes after iter.len.
> A caller that sets opts.iter.info, opts.iter.len and opts.tracing_multi.cnt
> gets the stray field silently ignored instead of -EINVAL.  Likewise, a
> later field added to the iter struct after len, built against newer
> headers, would be silently dropped by this libbpf because sz still equals
> sizeof() and OPTS_VALID() cannot see it.
> 
> Legacy callers would be unaffected, since their union is already zero, and
> the iter.len test in the legacy branch could then be dropped.  The later
> commits in this series only touch selftests and do not address this.
> 
> 
> ---
> AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
> See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
> 
> CI run summary: https://github.com/kernel-patches/bpf/actions/runs/42633880300


  reply	other threads:[~2026-11-11 15:33 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09 14:08 [PATCH bpf-next 0/9] bpf: Add log support for tracing link_create Leon Hwang
2026-11-09 14:08 ` [PATCH bpf-next 1/9] " Leon Hwang
2026-11-09 14:47   ` bot+bpf-ci
2026-11-11 15:31     ` Leon Hwang
2026-11-09 14:08 ` [PATCH bpf-next 2/9] bpf: Add log support for tracing_multi link_create Leon Hwang
2026-11-09 14:08 ` [PATCH bpf-next 3/9] bpf: Add log support for iter link_create Leon Hwang
2026-11-09 14:22   ` sashiko-bot
2026-11-11 15:32     ` Leon Hwang
2026-11-09 14:08 ` [PATCH bpf-next 4/9] bpf: Add log support for cgroup prog link_create Leon Hwang
2026-11-09 14:47   ` bot+bpf-ci
2026-11-11 15:32     ` Leon Hwang
2026-11-09 14:08 ` [PATCH bpf-next 5/9] libbpf: Add log_opts support for BPF_TRACE_ITER Leon Hwang
2026-11-09 14:36   ` sashiko-bot
2026-11-11 15:33     ` Leon Hwang
2026-11-09 14:47   ` bot+bpf-ci
2026-11-11 15:32     ` Leon Hwang [this message]
2026-11-09 14:08 ` [PATCH bpf-next 6/9] selftests/bpf: Verify tracing link_create logs Leon Hwang
2026-11-09 14:47   ` bot+bpf-ci
2026-11-11 15:34     ` Leon Hwang
2026-11-09 14:08 ` [PATCH bpf-next 7/9] selftests/bpf: Verify tracing_multi " Leon Hwang
2026-11-09 14:08 ` [PATCH bpf-next 8/9] selftests/bpf: Verify iter " Leon Hwang
2026-11-09 14:08 ` [PATCH bpf-next 9/9] selftests/bpf: Verify cgroup prog " Leon Hwang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ab4e5c29-b835-4ea8-853b-57ae7ad2eafe@linux.dev \
    --to=leon.hwang@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bot+bpf-ci@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mason@kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=matt@bobrowski.net \
    --cc=memxor@gmail.com \
    --cc=mhiramat@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.