Re: [PATCH bpf-next v5 3/5] bpf: Add helper to detect indirect jump targets
From: Xu Kuohai
Date: Wed Mar 04 2026 - 07:46:08 EST
On 3/4/2026 1:19 AM, Alexei Starovoitov wrote:
[...]
- for (i = 0; i < insn_cnt; i++, insn++) {
+ for (i = 0, j = 0; i < insn_cnt; i++, j++, insn++) {
+ env->insn_aux_data[subprog_start + j].final_idx = i;
if (bpf_pseudo_func(insn)) {
/* ld_imm64 with an address of bpf subprog is not
* a user controlled constant. Don't randomize it,
@@ -1512,6 +1542,8 @@ struct bpf_prog *bpf_jit_blind_constants(struct bpf_verifier_env *env, struct bp
*/
insn++;
i++;
+ j++;
+ env->insn_aux_data[subprog_start + j].final_idx = i;
You're adding final_idx because bpf_jit_blind_constants()
doesn't call adjust_insn_aux_data() ?
Yes, I added final_idx because insn_aux is not updated here.
imo that's an ugly workaround. Just call adjust_insn_aux_data().
If we adjust the env->insn_aux_data here, should we also adjust the global
env->prog->insnsi array? I think env->insn_aux_data should remain consistent
with the global env->prog->insnsi array. Since constant blinding only rewrites
the subprog's private instruction array, updating the env->insn_aux_data
causes a mismatch with the global state.
And in the future please mention such design decisions in the commit log,
so that reviewers don't need to reverse engineer your thought process.
Sorry for the lack of clarity. I’ll make an effort to clarify things more
clearly in the future.
pw-bot: cr