From: bot+bpf-ci@kernel.org
To: gnq25@mails.tsinghua.edu.cn,bpf@vger.kernel.org
Cc: ast@kernel.org,daniel@iogearbox.net,andrii@kernel.org,eddyz87@gmail.com,a.s.protopopov@gmail.com,shuah@kernel.org,linux-kselftest@vger.kernel.org,linux-kernel@vger.kernel.org,gnq25@mails.tsinghua.edu.cn,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,clm@meta.com,ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next 1/2] bpf: Fix gotox target validation against CFG
Date: Tue, 9 Jun 2026 15:42:57 +0000 (UTC) [thread overview]
Message-ID: <7ec49cbf243822be83aa8d47da10b3d8a739952e544fcd86aeab6b1ccd447d90@mail.kernel.org> (raw)
In-Reply-To: <20260609-f01-02-gotox-bpf-next-v1-1-b441d63a1559@mails.tsinghua.edu.cn>
[-- Attachment #1: Type: text/plain, Size: 2339 bytes --]
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index ed7ba0e6a9ce..25fa90e731e3 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -17124,6 +17124,23 @@ static int indirect_jump_min_max_index(struct bpf_verifier_env *env,
> return 0;
> }
>
> +static bool is_cfg_indirect_jump_target(struct bpf_verifier_env *env,
> + u32 target)
> +{
> + struct bpf_iarray *jt = env->insn_aux_data[env->insn_idx].jt;
> + int i;
> +
> + if (!jt)
> + return false;
> +
> + for (i = 0; i < jt->cnt; i++) {
> + if (jt->items[i] == target)
> + return true;
> + }
> +
> + return false;
> +}
> +
> /* gotox *dst_reg */
> static int check_indirect_jump(struct bpf_verifier_env *env, struct bpf_insn *insn)
> {
[ ... ]
> @@ -17171,6 +17188,15 @@ static int check_indirect_jump(struct bpf_verifier_env *env, struct bpf_insn *in
> return -EINVAL;
> }
>
> + for (i = 0; i < n; i++) {
> + if (!is_cfg_indirect_jump_target(env, env->gotox_tmp_buf->items[i])) {
> + verbose(env,
> + "gotox target %u from map id=%d is not in the CFG jump table\n",
> + env->gotox_tmp_buf->items[i], map->id);
> + return -EINVAL;
> + }
> + }
> +
Could this nested loop create an O(N * M) algorithmic complexity that
bypasses verifier complexity limits?
The outer loop iterates n times, and is_cfg_indirect_jump_target()
performs a linear scan over jt->cnt items. Both n and jt->cnt are bounded
by the map's max_entries, which can be very large.
Since there is no cond_resched() here, this creates a synchronous
iteration sequence that could trigger the kernel watchdog panic or lead to
CPU soft lockup.
Given that both gotox_tmp_buf->items and jt->items are strictly sorted
arrays, could this be optimized to O(N + M) using a two-pointer merge
approach or O(N log M) using binary search?
Raised by sashiko-bot@kernel.org in v1:
https://lore.kernel.org/bpf/20260609151359.3C6F51F00893@smtp.kernel.org/
> for (i = 0; i < n - 1; i++) {
> mark_indirect_target(env, env->gotox_tmp_buf->items[i]);
> other_branch = push_stack(env, env->gotox_tmp_buf->items[i],
[ ... ]
---
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/27216356316
next prev parent reply other threads:[~2026-06-09 15:42 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 15:03 [PATCH bpf-next 0/2] " Nuoqi Gui
2026-06-09 15:03 ` [PATCH bpf-next 1/2] " Nuoqi Gui
2026-06-09 15:42 ` bot+bpf-ci [this message]
2026-06-09 15:56 ` Anton Protopopov
2026-06-09 17:27 ` Eduard Zingerman
2026-06-10 12:22 ` Nuoqi Gui
2026-06-09 15:03 ` [PATCH bpf-next 2/2] selftests/bpf: Add cross-subprog gotox target coverage Nuoqi Gui
2026-06-09 15:42 ` bot+bpf-ci
2026-06-09 16:14 ` Anton Protopopov
2026-06-13 9:33 ` [PATCH bpf-next v2 0/2] bpf: Enforce gotox targets against subprog bounds Nuoqi Gui
2026-06-13 9:33 ` [PATCH bpf-next v2 1/2] " Nuoqi Gui
2026-06-21 15:20 ` Yonghong Song
2026-06-22 15:08 ` Anton Protopopov
2026-06-22 18:06 ` Eduard Zingerman
2026-06-13 9:33 ` [PATCH bpf-next v2 2/2] selftests/bpf: Add cross-subprog gotox target coverage Nuoqi Gui
2026-06-13 10:08 ` bot+bpf-ci
2026-06-21 15:21 ` Yonghong Song
2026-06-22 14:40 ` Anton Protopopov
2026-06-23 9:11 ` Nuoqi Gui
2026-06-22 15:17 ` [PATCH bpf-next v2 0/2] bpf: Enforce gotox targets against subprog bounds Anton Protopopov
2026-06-23 8:56 ` Nuoqi Gui
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=7ec49cbf243822be83aa8d47da10b3d8a739952e544fcd86aeab6b1ccd447d90@mail.kernel.org \
--to=bot+bpf-ci@kernel.org \
--cc=a.s.protopopov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=clm@meta.com \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=gnq25@mails.tsinghua.edu.cn \
--cc=ihor.solodrai@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@kernel.org \
--cc=shuah@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox