BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Toke Høiland-Jørgensen" <toke@toke.dk>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 2/7] libbpf: Add bpf_*_get_next_id_opts() functions
Date: Wed, 25 Nov 2026 15:46:12 +0000	[thread overview]
Message-ID: <sashiko-outbox-233673@kernel.org> (raw)
In-Reply-To: <20261125-bpf-relax-get-next-id-v1-2-49175227c8cf@toke.dk>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] libbpf: wrong opts struct type in OPTS_VALID() in
  bpf_obj_get_next_id()
- [Medium] libbpf: new bpf_*_get_next_id_opts() symbols placed in
  LIBBPF_1.8.0
--

commit b7df30f0fa741fff328c3a531ed16f0239f39016
Author: Toke Høiland-Jørgensen <toke@toke.dk>

libbpf: Add bpf_*_get_next_id_opts() functions

This commit adds opts-based variants of the bpf_*_get_next_id() functions
that accept a struct bpf_get_next_id_opts with a token_fd field.

> diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
> index 38dcb31e8c0ed..059c358c97444 100644
> --- a/tools/lib/bpf/bpf.c
> +++ b/tools/lib/bpf/bpf.c
> @@ -1149,14 +1149,21 @@ int bpf_prog_test_run_opts(int prog_fd, struct bpf_test_run_opts *opts)
>  	return libbpf_err_errno(ret);
>  }
>  
> -static int bpf_obj_get_next_id(__u32 start_id, __u32 *next_id, int cmd)
> +static int bpf_obj_get_next_id(__u32 start_id, __u32 *next_id, int cmd,
> +			       const struct bpf_get_next_id_opts *opts)
>  {
> -	const size_t attr_sz = offsetofend(union bpf_attr, open_flags);
> +	const size_t attr_sz = offsetofend(union bpf_attr, get_next_id_token_fd);
>  	union bpf_attr attr;
>  	int err;
>  
> +	if (!OPTS_VALID(opts, bpf_get_fd_by_id_opts))
> +		return libbpf_err(-EINVAL);

[Severity: Medium]
Should OPTS_VALID() check bpf_get_next_id_opts instead of
bpf_get_fd_by_id_opts?  struct bpf_get_fd_by_id_opts has an extra __u32
open_flags field before token_fd, so validating against it skips checking
that the 4 bytes following token_fd in struct bpf_get_next_id_opts are
zeroed.

[ ... ]

> diff --git a/tools/lib/bpf/libbpf.map b/tools/lib/bpf/libbpf.map
> index a45666f546fae..899264fbb42d0 100644
> --- a/tools/lib/bpf/libbpf.map
> +++ b/tools/lib/bpf/libbpf.map
> @@ -458,7 +458,11 @@ LIBBPF_1.7.0 {
>  
>  LIBBPF_1.8.0 {
>  	global:
> +		bpf_btf_get_next_id_opts;
> +		bpf_link_get_next_id_opts;
>  		bpf_map__attach_cgroup_opts;
> +		bpf_map_get_next_id_opts;
> +		bpf_prog_get_next_id_opts;
>  		bpf_prog_stream_open;
>  		bpf_program__add_flags;
>  		bpf_program__attach_tracing_multi;

[Severity: Medium]
Should these new symbols be added to the LIBBPF_1.9.0 section rather than
the already-released LIBBPF_1.8.0 section?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261125-bpf-relax-get-next-id-v1-0-49175227c8cf@toke.dk?part=2

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

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 15:31 [PATCH bpf-next 0/7] Improvements to access module BTF with bpf_token Toke Høiland-Jørgensen
2026-11-25 15:31 ` [PATCH bpf-next 1/7] bpf: Relax BPF_*_GET_NEXT_ID permission checks to CAP_BPF and bpf_token Toke Høiland-Jørgensen
2026-11-25 15:31 ` [PATCH bpf-next 2/7] libbpf: Add bpf_*_get_next_id_opts() functions Toke Høiland-Jørgensen
2026-11-25 15:46   ` sashiko-bot [this message]
2026-11-26  9:48     ` Toke Høiland-Jørgensen
2026-11-25 15:31 ` [PATCH bpf-next 3/7] libbpf: Automatically set BPF_F_TOKEN_FD when getting BTF fd Toke Høiland-Jørgensen
2026-11-25 15:31 ` [PATCH bpf-next 4/7] libbpf: Move bpf_object_prepare_token() to object creation Toke Høiland-Jørgensen
2026-11-25 15:31 ` [PATCH bpf-next 5/7] libbpf: Pass in token_fd when iterating kernel BTF objects Toke Høiland-Jørgensen
2026-11-25 15:56   ` sashiko-bot
2026-11-25 15:31 ` [PATCH bpf-next 6/7] selftests/bpf: Explicitly disable token in token/obj_priv_freplace_prog_fail test Toke Høiland-Jørgensen
2026-11-25 15:40   ` sashiko-bot
2026-11-25 15:31 ` [PATCH bpf-next 7/7] selftests/bpf: Add test for attaching fentry to a module with bpf_token Toke Høiland-Jørgensen

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=sashiko-outbox-233673@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=toke@toke.dk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox