From: Anton Protopopov <a.s.protopopov@gmail.com>
To: bot+bpf-ci@kernel.org
Cc: bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org,
aspsk@isovalent.com, daniel@iogearbox.net, eddyz87@gmail.com,
qmo@kernel.org, yonghong.song@linux.dev, martin.lau@kernel.org,
clm@meta.com, ihor.solodrai@linux.dev
Subject: Re: [PATCH v10 bpf-next 06/11] bpf, x86: add support for indirect jumps
Date: Sun, 2 Nov 2025 22:00:30 +0000 [thread overview]
Message-ID: <aQfUfiRbGb0UdLS0@mail.gmail.com> (raw)
In-Reply-To: <fff3a198c4d0f8abc33f6d1633585ccb13f1709786bb9f5080641631f69628df@mail.kernel.org>
On 25/11/02 09:20PM, bot+bpf-ci@kernel.org wrote:
>
> ```
> commit 6cb8001495faae09541d55309638b3c1920bae06
> Author: Anton Protopopov <a.s.protopopov@gmail.com>
>
> bpf, x86: add support for indirect jumps
>
> This patch adds support for indirect jumps in BPF through a new
> BPF_JMP|BPF_X|BPF_JA instruction. It introduces the PTR_TO_INSN register
> type for instruction pointers loaded from INSN_ARRAY maps, along with
> verifier support for tracking jump tables and x86 JIT implementation.
>
> > diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
>
> [ ... ]
>
> > @@ -21374,6 +21374,28 @@ static int bpf_adj_linfo_after_remove(struct bpf_verifier_env *env, u32 off,
> > return 0;
> > }
> >
> > +/*
> > + * Clean up dynamically allocated fields of aux data for instructions [start, ...]
> > + */
> > +static void clear_insn_aux_data(struct bpf_verifier_env *env, int start, int len)
> > +{
> > + struct bpf_insn_aux_data *aux_data = env->insn_aux_data;
> > + struct bpf_insn *insns = env->prog->insnsi;
> > + int end = start + len;
> > + int i;
> > +
> > + for (i = start; i < end; i++) {
> > + if (insn_is_gotox(&insns[i])) {
> > + kvfree(aux_data[i].jt);
> > + aux_data[i].jt = NULL;
> > + }
> > +
> > + if (bpf_is_ldimm64(&insns[i]))
> > + i++;
> > + }
> > +}
> > +
> > static int verifier_remove_insns(struct bpf_verifier_env *env, u32 off, u32 cnt)
> > {
> > struct bpf_insn_aux_data *aux_data = env->insn_aux_data;
> > @@ -21393,6 +21415,8 @@ static int verifier_remove_insns(struct bpf_verifier_env *env, u32 off, u32 cnt
> >
> > adjust_insn_arrays_after_remove(env, off, cnt);
> >
> > + clear_insn_aux_data(env, off, cnt);
> > +
> > memmove(aux_data + off, aux_data + off + cnt,
> > sizeof(*aux_data) * (orig_prog_len - off - cnt));
>
> Can clear_insn_aux_data() correctly identify which aux_data entries need
> cleanup when it's called after bpf_remove_insns()? After instructions are
> removed, the insns[] array has been modified - insns[off] now contains what
> was previously insns[off+cnt]. But aux_data hasn't been shifted yet, so
> clear_insn_aux_data() checks the wrong instructions when deciding which
> aux_data entries to free.
>
> For example, if instructions [1,2] are removed where insn 2 is a gotox:
> - bpf_remove_insns() removes insns[1] and insns[2], shifts later insns down
> - insns[1] now contains what was insns[3]
> - clear_insn_aux_data() checks insn_is_gotox(&insns[1]) (now insn 3!)
> - It might free aux_data[1].jt if insn 3 is a gotox, even though insn 3
> isn't being removed
> - It never checks the original insns[2] which was the actual gotox that
> needed cleanup
>
> Should clear_insn_aux_data() be called before bpf_remove_insns() instead?
Looks plausible. I will move it upper and add a comment on the call order.
>
> ```
>
> ---
> 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
>
> In-Reply-To-Subject: `bpf, x86: add support for indirect jumps`
> CI run summary: https://github.com/kernel-patches/bpf/actions/runs/19018051915
next prev parent reply other threads:[~2025-11-02 21:54 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-02 20:57 [PATCH v10 bpf-next 00/11] BPF indirect jumps Anton Protopopov
2025-11-02 20:57 ` [PATCH v10 bpf-next 01/11] bpf, x86: add new map type: instructions array Anton Protopopov
2025-11-02 20:57 ` [PATCH v10 bpf-next 02/11] selftests/bpf: add selftests for new insn_array map Anton Protopopov
2025-11-04 2:10 ` Alexei Starovoitov
2025-11-04 13:52 ` Anton Protopopov
2025-11-04 16:49 ` Alexei Starovoitov
2025-11-05 6:35 ` Anton Protopopov
2025-11-02 20:57 ` [PATCH v10 bpf-next 03/11] bpf: support instructions arrays with constants blinding Anton Protopopov
2025-11-02 20:57 ` [PATCH v10 bpf-next 04/11] selftests/bpf: test instructions arrays with blinding Anton Protopopov
2025-11-02 20:57 ` [PATCH v10 bpf-next 05/11] bpf, x86: allow indirect jumps to r8...r15 Anton Protopopov
2025-11-02 20:57 ` [PATCH v10 bpf-next 06/11] bpf, x86: add support for indirect jumps Anton Protopopov
2025-11-02 21:20 ` bot+bpf-ci
2025-11-02 22:00 ` Anton Protopopov [this message]
2025-11-02 20:57 ` [PATCH v10 bpf-next 07/11] bpf: disasm: add support for BPF_JMP|BPF_JA|BPF_X Anton Protopopov
2025-11-02 20:57 ` [PATCH v10 bpf-next 08/11] libbpf: support llvm-generated indirect jumps Anton Protopopov
2025-11-02 21:13 ` bot+bpf-ci
2025-11-02 21:36 ` Anton Protopopov
2025-11-02 21:38 ` Anton Protopopov
2025-11-03 0:32 ` Ihor Solodrai
2025-11-03 0:58 ` Chris Mason
2025-11-03 8:29 ` Anton Protopopov
2025-11-03 8:21 ` Anton Protopopov
2025-11-04 1:15 ` Eduard Zingerman
2025-11-04 1:30 ` Eduard Zingerman
2025-11-04 5:26 ` Yonghong Song
2025-11-04 18:31 ` Eduard Zingerman
2025-11-05 8:12 ` Anton Protopopov
2025-11-02 20:57 ` [PATCH v10 bpf-next 09/11] bpftool: Recognize insn_array map type Anton Protopopov
2025-11-02 20:57 ` [PATCH v10 bpf-next 10/11] selftests/bpf: add new verifier_gotox test Anton Protopopov
2025-11-02 20:57 ` [PATCH v10 bpf-next 11/11] selftests/bpf: add C-level selftests for indirect jumps Anton Protopopov
2025-11-03 20:45 ` Eduard Zingerman
2025-11-05 7:26 ` Anton Protopopov
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=aQfUfiRbGb0UdLS0@mail.gmail.com \
--to=a.s.protopopov@gmail.com \
--cc=andrii@kernel.org \
--cc=aspsk@isovalent.com \
--cc=ast@kernel.org \
--cc=bot+bpf-ci@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=clm@meta.com \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=ihor.solodrai@linux.dev \
--cc=martin.lau@kernel.org \
--cc=qmo@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.