When patching instructions with the bpf_patch_insn_data() function patch env->prog->aux->func_info[i].insn_off as well. Currently this doesn't seem to break anything, but this filed will be used in a consequent patch. Signed-off-by: Anton Protopopov <aspsk@xxxxxxxxxxxxx> --- kernel/bpf/verifier.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index bf94ba50c6ee..5d38ee2e74a1 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -18181,6 +18181,20 @@ static void adjust_insn_aux_data(struct bpf_verifier_env *env, vfree(old_data); } +static void adjust_func_info(struct bpf_verifier_env *env, u32 off, u32 len) +{ + int i; + + if (len == 1) + return; + + for (i = 0; i < env->prog->aux->func_info_cnt; i++) { + if (env->prog->aux->func_info[i].insn_off <= off) + continue; + env->prog->aux->func_info[i].insn_off += len - 1; + } +} + static void adjust_subprog_starts(struct bpf_verifier_env *env, u32 off, u32 len) { int i; @@ -18232,6 +18246,7 @@ static struct bpf_prog *bpf_patch_insn_data(struct bpf_verifier_env *env, u32 of return NULL; } adjust_insn_aux_data(env, new_data, new_prog, off, len); + adjust_func_info(env, off, len); adjust_subprog_starts(env, off, len); adjust_poke_descs(new_prog, off, len); return new_prog; -- 2.34.1