All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 06/17] bpf: Add callx calls to the call graph
Date: Thu, 24 Sep 2026 03:26:27 +0000	[thread overview]
Message-ID: <20260924032628.795CF1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260924031042.1690890-7-alexei.starovoitov@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] bpf: sort_subprogs_topo() misses callback edges, failing to detect bounded recursion
--

commit 1cc83e74951c3df35b0b794cf4a90e325a1cff05
Author: Alexei Starovoitov <ast@kernel.org>

bpf: Add callx calls to the call graph

This commit updates the verifier to record caller to callee edges for callx
and sync callbacks during the main verification pass. It then uses these
recorded edges in sort_subprogs_topo() to detect bounded recursion via
indirect calls, and in check_max_stack_depth_subprog() to walk the callees.

> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index eb014bf6a2e87..d00d0ecab17cf 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c

[ ... ]

> @@ -3195,12 +3233,22 @@ static int sort_subprogs_topo(struct bpf_verifier_env *env)
>  				int idx = insn_postorder[j];
>  				int callee;
>  
> -				if (!bpf_pseudo_call(&insn[idx]) && !bpf_pseudo_func(&insn[idx]))
> +				if (bpf_is_callx(&insn[idx])) {

[Severity: Medium]
Does this code miss callback edges when checking for cycles?

The commit message mentions that sync callback edges are recorded, and
check_max_stack_depth_subprog() checks both bpf_is_callx() and
bpf_calls_callback().

However, this condition only checks for bpf_is_callx(). If a BPF program
uses a sync callback (e.g., bpf_loop) to call a subprogram, which then
recursively calls the original subprogram, and neither subprogram contains a
callx instruction, would sort_subprogs_topo() silently ignore the callback
edges and fail to detect the cycle here?

Should this condition be expanded to check for bpf_calls_callback(env, idx)
so that callback edges are correctly registered during topological sorting?

> +					/* find a callee that is not explored yet */
> +					callee = -1;
> +					do {
> +						callee = next_callx_callee(env, cur, callee + 1);
> +					} while (callee >= 0 && color[callee] == 2);
> +					if (callee < 0)
> +						continue;
> +				} else if (bpf_pseudo_call(&insn[idx]) || bpf_pseudo_func(&insn[idx])) {
> +					callee = bpf_find_subprog(env, idx + insn[idx].imm + 1);

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260924031042.1690890-1-alexei.starovoitov@gmail.com?part=6

  reply	other threads:[~2026-09-24  3:26 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24  3:10 [PATCH bpf-next v2 00/17] bpf: Indirect calls of bpf subprogs (callx) Alexei Starovoitov
2026-09-24  3:10 ` [PATCH bpf-next v2 01/17] bpf: Fix infinite loop in check_max_stack_depth() Alexei Starovoitov
2026-09-24  3:10 ` [PATCH bpf-next v2 02/17] selftests/bpf: Test recursion through a global function and a callback Alexei Starovoitov
2026-09-24  3:10 ` [PATCH bpf-next v2 03/17] bpf: Keep functions with address taken when removing dead code Alexei Starovoitov
2026-09-24  3:10 ` [PATCH bpf-next v2 04/17] bpf: Prepare static analysis passes for callx instruction Alexei Starovoitov
2026-09-24  3:56   ` bot+bpf-ci
2026-09-24  4:18   ` Eduard Zingerman
2026-09-24  3:10 ` [PATCH bpf-next v2 05/17] bpf: Add callx instruction to call bpf subprogs indirectly Alexei Starovoitov
2026-09-24  3:28   ` sashiko-bot
2026-09-24  3:10 ` [PATCH bpf-next v2 06/17] bpf: Add callx calls to the call graph Alexei Starovoitov
2026-09-24  3:26   ` sashiko-bot [this message]
2026-09-24  3:56   ` bot+bpf-ci
2026-09-24  5:00   ` Eduard Zingerman
2026-09-24  3:10 ` [PATCH bpf-next v2 07/17] bpf, x86: Add JIT support for callx Alexei Starovoitov
2026-09-24  5:33   ` Eduard Zingerman
2026-09-24  3:10 ` [PATCH bpf-next v2 08/17] bpf, arm64: " Alexei Starovoitov
2026-09-24  3:10 ` [PATCH bpf-next v2 09/17] bpf: Discover subprogs described by func_info Alexei Starovoitov
2026-09-24  5:42   ` Eduard Zingerman
2026-09-24  3:10 ` [PATCH bpf-next v2 10/17] bpf: Recognize pointers to functions in read-only maps Alexei Starovoitov
2026-09-24  3:10 ` [PATCH bpf-next v2 11/17] libbpf: Support pointers to static functions in data when linking Alexei Starovoitov
2026-09-24  3:10 ` [PATCH bpf-next v2 12/17] libbpf: Resolve pointers to functions in read-only data Alexei Starovoitov
2026-09-24  3:27   ` sashiko-bot
2026-09-24  3:10 ` [PATCH bpf-next v2 13/17] libbpf: Treat .data.rel.ro as " Alexei Starovoitov
2026-09-24  3:10 ` [PATCH bpf-next v2 14/17] libbpf: Support pointers to functions in read-only data in light skeleton Alexei Starovoitov
2026-09-24  3:10 ` [PATCH bpf-next v2 15/17] selftests/bpf: Add tests for callx Alexei Starovoitov
2026-09-24  3:56   ` bot+bpf-ci
2026-09-24  3:10 ` [PATCH bpf-next v2 16/17] selftests/bpf: Add tests for callx through pointers in read-only data Alexei Starovoitov
2026-09-24  3:10 ` [PATCH bpf-next v2 17/17] bpf, docs: Document callx instruction Alexei Starovoitov
2026-09-24  5:50 ` [PATCH bpf-next v2 00/17] bpf: Indirect calls of bpf subprogs (callx) patchwork-bot+netdevbpf
2026-09-24  5:55   ` Eduard Zingerman
2026-09-24  6:00     ` Alexei Starovoitov
2026-09-24 17:50   ` Ihor Solodrai
2026-09-24 18:09     ` Alexei Starovoitov
2026-09-28 23:13   ` Ihor Solodrai
2026-09-29  6:04     ` Alexei Starovoitov
2026-09-29 16:40       ` Ihor Solodrai

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=20260924032628.795CF1F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alexei.starovoitov@gmail.com \
    --cc=bpf@vger.kernel.org \
    --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.