Skip to content

Commit d24dd0b

Browse files
Geliang TangKernel Patches Daemon
authored andcommitted
bpf: verifier: Fix return value of fixup_call_args
Run bloom_filter_map selftests (./test_progs -t bloom_filter_map) on a Loongarch platform, an error message "JIT doesn't support bpf-to-bpf calls" is got in user space, together with an unexpected errno EINVAL (22), not ENOTSUPP (524): libbpf: prog 'inner_map': BPF program load failed: Invalid argument libbpf: prog 'inner_map': -- BEGIN PROG LOAD LOG -- JIT doesn't support bpf-to-bpf calls callbacks are not allowed in non-JITed programs processed 37 insns (limit 1000000) max_states_per_insn 1 total_states -- END PROG LOAD LOG -- libbpf: prog 'inner_map': failed to load: -22 libbpf: failed to load object 'bloom_filter_map' libbpf: failed to load BPF skeleton 'bloom_filter_map': -22 setup_progs:FAIL:bloom_filter_map__open_and_load unexpected error: -22 #16 bloom_filter_map:FAIL Although the return value of jit_subprogs() does be set as "ENOTSUPP": verbose(env, "JIT doesn't support bpf-to-bpf calls\n"); err = -ENOTSUPP; goto out_free; But afterwards in fixup_call_args(), the return value of jit_subprogs() is ignored, and overwritten as "-EINVAL": verbose(env, "callbacks are not allowed in non-JITed programs\n"); return -EINVAL; This patch fixes this by changing return values of fixup_call_args() from "-EINVAL" to "err ?: -EINVAL". With this change, errno 524 is got in user space now: libbpf: prog 'inner_map': BPF program load failed: unknown error (-524) libbpf: prog 'inner_map': -- BEGIN PROG LOAD LOG -- JIT doesn't support bpf-to-bpf calls processed 37 insns (limit 1000000) max_states_per_insn 1 total_states -- END PROG LOAD LOG -- libbpf: prog 'inner_map': failed to load: -524 libbpf: failed to load object 'bloom_filter_map' libbpf: failed to load BPF skeleton 'bloom_filter_map': -524 setup_progs:FAIL:bloom_filter_map__open_and_load unexpected error: -524 Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
1 parent 055095d commit d24dd0b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/bpf/verifier.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19717,22 +19717,22 @@ static int fixup_call_args(struct bpf_verifier_env *env)
1971719717
#ifndef CONFIG_BPF_JIT_ALWAYS_ON
1971819718
if (has_kfunc_call) {
1971919719
verbose(env, "calling kernel functions are not allowed in non-JITed programs\n");
19720-
return -EINVAL;
19720+
return err ?: -EINVAL;
1972119721
}
1972219722
if (env->subprog_cnt > 1 && env->prog->aux->tail_call_reachable) {
1972319723
/* When JIT fails the progs with bpf2bpf calls and tail_calls
1972419724
* have to be rejected, since interpreter doesn't support them yet.
1972519725
*/
1972619726
verbose(env, "tail_calls are not allowed in non-JITed programs with bpf-to-bpf calls\n");
19727-
return -EINVAL;
19727+
return err ?: -EINVAL;
1972819728
}
1972919729
for (i = 0; i < prog->len; i++, insn++) {
1973019730
if (bpf_pseudo_func(insn)) {
1973119731
/* When JIT fails the progs with callback calls
1973219732
* have to be rejected, since interpreter doesn't support them yet.
1973319733
*/
1973419734
verbose(env, "callbacks are not allowed in non-JITed programs\n");
19735-
return -EINVAL;
19735+
return err ?: -EINVAL;
1973619736
}
1973719737

1973819738
if (!bpf_pseudo_call(insn))

0 commit comments

Comments
 (0)