All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: chenyuan_fl@163.com
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v3 2/2] libbpf: fetch probeable prog type from token for feature probes
Date: Wed, 10 Jun 2026 15:04:15 +0000	[thread overview]
Message-ID: <20260610150415.F315F1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260610145059.113412-3-chenyuan_fl@163.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Feature probes for FEAT_BPF_COOKIE and FEAT_PROBE_READ_KERN will unconditionally fail because they test helpers unsupported by the dynamically selected BPF_PROG_TYPE_SOCKET_FILTER.
--

commit 0109a2d3173a7dbf585e1f1ba9c12c5a9120c9eb
Author: Yuan Chen <chenyuan@kylinos.cn>

libbpf: fetch probeable prog type from token for feature probes

This commit updates feature probes to dynamically select a program type
based on the provided BPF token instead of hardcoding SOCKET_FILTER or
TRACEPOINT. If no token is provided, it defaults to SOCKET_FILTER.

> diff --git a/tools/lib/bpf/features.c b/tools/lib/bpf/features.c
> index b7e388f99d0bb..f008ee50e2466 100644
> --- a/tools/lib/bpf/features.c
> +++ b/tools/lib/bpf/features.c

[ ... ]

> @@ -257,8 +318,13 @@ static int probe_kern_probe_read_kernel(int token_fd)
>  		BPF_EXIT_INSN(),
>  	};
>  	int fd, insn_cnt = ARRAY_SIZE(insns);
> +	int prog_type;
>  
> -	fd = bpf_prog_load(BPF_PROG_TYPE_TRACEPOINT, NULL, "GPL", insns, insn_cnt, &opts);
> +	prog_type = token_probeable_prog_type(token_fd);
> +	if (prog_type < 0)
> +		return 1;
> +
> +	fd = bpf_prog_load(prog_type, NULL, "GPL", insns, insn_cnt, &opts);

[Severity: High]
Will this unconditionally fail the probe for FEAT_PROBE_READ_KERN?

If no token is provided, or the token allows SOCKET_FILTER,
token_probeable_prog_type() returns BPF_PROG_TYPE_SOCKET_FILTER.

Because SOCKET_FILTER does not support the bpf_probe_read_kernel helper,
the verifier will reject the load with an unknown func error.

Does this result in libbpf falsely reporting the feature as missing for
all applications?

[ ... ]

> @@ -435,8 +507,13 @@ static int probe_kern_bpf_cookie(int token_fd)
>  		.prog_flags = token_fd ? BPF_F_TOKEN_FD : 0,
>  	);
>  	int ret, insn_cnt = ARRAY_SIZE(insns);
> +	int prog_type;
>  
> -	ret = bpf_prog_load(BPF_PROG_TYPE_TRACEPOINT, NULL, "GPL", insns, insn_cnt, &opts);
> +	prog_type = token_probeable_prog_type(token_fd);
> +	if (prog_type < 0)
> +		return 1;
> +
> +	ret = bpf_prog_load(prog_type, NULL, "GPL", insns, insn_cnt, &opts);

[Severity: High]
Similarly, will this break the FEAT_BPF_COOKIE probe?

If prog_type resolves to BPF_PROG_TYPE_SOCKET_FILTER, it will not support
the bpf_get_attach_cookie helper being tested here, causing the verifier
to reject the probe program.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260610145059.113412-1-chenyuan_fl@163.com?part=2

  reply	other threads:[~2026-06-10 15:04 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-29  3:16 [PATCH] selftests/bpf: fix token tests for bpf_object__prepare() probe_loading chenyuan_fl
2026-05-29  3:39 ` sashiko-bot
2026-05-29  3:57 ` bot+bpf-ci
2026-06-04  3:10 ` [PATCH bpf-next v2 0/3] libbpf: fix implicit BPF token handling in loading and feature probes chenyuan_fl
2026-06-04  3:10   ` [PATCH bpf-next v2 1/3] libbpf: Skip bpf_object__probe_loading() when BPF token is in use chenyuan_fl
2026-06-04  4:05     ` bot+bpf-ci
2026-06-04 11:16     ` Mykyta Yatsenko
2026-06-08 18:17       ` Andrii Nakryiko
2026-06-09 13:11         ` [PATCH bpf] " chenyuan_fl
2026-06-09 13:35           ` Mykyta Yatsenko
2026-06-09 13:42           ` bot+bpf-ci
2026-06-04  3:10   ` [PATCH bpf-next v2 2/3] selftests/bpf: Add ARRAY map type to token tests that use struct_ops global data chenyuan_fl
2026-06-04  3:25     ` sashiko-bot
2026-06-08 18:14     ` Andrii Nakryiko
2026-06-04  3:10   ` [PATCH bpf-next v2 3/3] libbpf: fix feature probe failures for implicit BPF tokens chenyuan_fl
2026-06-04  3:27     ` sashiko-bot
2026-06-04  4:05     ` bot+bpf-ci
2026-06-04 14:40     ` Mykyta Yatsenko
2026-06-08 18:18       ` Andrii Nakryiko
2026-06-10 14:50   ` [PATCH bpf-next v3 0/2] libbpf: fix implicit BPF token feature probe failures chenyuan_fl
2026-06-10 14:50     ` [PATCH bpf-next v3 1/2] libbpf: Skip bpf_object__probe_loading() when BPF token is in use chenyuan_fl
2026-06-10 16:30       ` bot+bpf-ci
2026-06-10 14:50     ` [PATCH bpf-next v3 2/2] libbpf: fetch probeable prog type from token for feature probes chenyuan_fl
2026-06-10 15:04       ` sashiko-bot [this message]
2026-06-10 16:30       ` bot+bpf-ci

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=20260610150415.F315F1F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=chenyuan_fl@163.com \
    --cc=sashiko-reviews@lists.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.