]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Add abnormal return checks.
authorAlexei Starovoitov <ast@kernel.org>
Fri, 18 Sep 2020 02:09:18 +0000 (19:09 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 18 Sep 2020 02:56:07 +0000 (19:56 -0700)
commitd2077ab5b210c9fb7f34b8b85cb6673c5855884e
tree2be3e375d9a88923b63ac9c3fda927d25073483a
parent745d4b9fcf149264f9200ee6ff8a924b31fd0dab
bpf: Add abnormal return checks.

LD_[ABS|IND] instructions may return from the function early. bpf_tail_call
pseudo instruction is either fallthrough or return. Allow them in the
subprograms only when subprograms are BTF annotated and have scalar return
types. Allow ld_abs and tail_call in the main program even if it calls into
subprograms. In the past that was not ok to do for ld_abs, since it was JITed
with special exit sequence. Since bpf_gen_ld_abs() was introduced the ld_abs
looks like normal exit insn from JIT point of view, so it's safe to allow them
in the main program.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/linux/bpf_verifier.h
kernel/bpf/verifier.c
tools/testing/selftests/bpf/verifier/calls.c