]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Set the number of exception entries properly for subprograms
authorYonghong Song <yhs@fb.com>
Wed, 24 Jun 2020 00:10:54 +0000 (17:10 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 24 Jun 2020 00:27:37 +0000 (17:27 -0700)
commit9e5b365f27b27a7ff5fcc7a498194a1e0d6cf4e7
tree111b9157be6a6cf063521db22c32d2c7ea14f67a
parentd027187797b70a5bb01b86b2d2a59af6cae068bf
bpf: Set the number of exception entries properly for subprograms

Currently, if a bpf program has more than one subprograms, each program will be
jitted separately. For programs with bpf-to-bpf calls the
prog->aux->num_exentries is not setup properly. For example, with
bpf_iter_netlink.c modified to force one function to be not inlined and with
CONFIG_BPF_JIT_ALWAYS_ON the following error is seen:
   $ ./test_progs -n 3/3
   ...
   libbpf: failed to load program 'iter/netlink'
   libbpf: failed to load object 'bpf_iter_netlink'
   libbpf: failed to load BPF skeleton 'bpf_iter_netlink': -4007
   test_netlink:FAIL:bpf_iter_netlink__open_and_load skeleton open_and_load failed
   #3/3 netlink:FAIL
The dmesg shows the following errors:
   ex gen bug
which is triggered by the following code in arch/x86/net/bpf_jit_comp.c:
   if (excnt >= bpf_prog->aux->num_exentries) {
     pr_err("ex gen bug\n");
     return -EFAULT;
   }

This patch fixes the issue by computing proper num_exentries for each
subprogram before calling JIT.

Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c