]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
bpf: Pass bpf_verifier_env to JIT
authorXu Kuohai <xukuohai@huawei.com>
Thu, 16 Apr 2026 06:43:38 +0000 (06:43 +0000)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 16 Apr 2026 14:03:40 +0000 (07:03 -0700)
commitd9ef13f72711f2dad64cd4445472ded98fb6c954
treea86feb8d5661fda7f789f5fb696244bbb6373390
parentd3e945223e0158c85dbde23de4f89493a2a817f6
bpf: Pass bpf_verifier_env to JIT

Pass bpf_verifier_env to bpf_int_jit_compile(). The follow-up patch will
use env->insn_aux_data in the JIT stage to detect indirect jump targets.

Since bpf_prog_select_runtime() can be called by cbpf and lib/test_bpf.c
code without verifier, introduce helper __bpf_prog_select_runtime()
to accept the env parameter.

Remove the call to bpf_prog_select_runtime() in bpf_prog_load(), and
switch to call __bpf_prog_select_runtime() in the verifier, with env
variable passed. The original bpf_prog_select_runtime() is preserved for
cbpf and lib/test_bpf.c, where env is NULL.

Now all constants blinding calls are moved into the verifier, except
the cbpf and lib/test_bpf.c cases. The instructions arrays are adjusted
by bpf_patch_insn_data() function for normal cases, so there is no need
to call adjust_insn_arrays() in bpf_jit_blind_constants(). Remove it.

Reviewed-by: Anton Protopopov <a.s.protopopov@gmail.com> # v8
Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com> # v12
Acked-by: Hengqi Chen <hengqi.chen@gmail.com> # v14
Signed-off-by: Xu Kuohai <xukuohai@huawei.com>
Link: https://lore.kernel.org/r/20260416064341.151802-3-xukuohai@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
17 files changed:
arch/arc/net/bpf_jit_core.c
arch/arm/net/bpf_jit_32.c
arch/arm64/net/bpf_jit_comp.c
arch/loongarch/net/bpf_jit.c
arch/mips/net/bpf_jit_comp.c
arch/parisc/net/bpf_jit_core.c
arch/powerpc/net/bpf_jit_comp.c
arch/riscv/net/bpf_jit_core.c
arch/s390/net/bpf_jit_comp.c
arch/sparc/net/bpf_jit_comp_64.c
arch/x86/net/bpf_jit_comp.c
arch/x86/net/bpf_jit_comp32.c
include/linux/filter.h
kernel/bpf/core.c
kernel/bpf/fixups.c
kernel/bpf/syscall.c
kernel/bpf/verifier.c