]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: verifier: refactor check_attach_btf_id()
authorToke Høiland-Jørgensen <toke@redhat.com>
Fri, 25 Sep 2020 21:25:02 +0000 (23:25 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 29 Sep 2020 00:10:34 +0000 (17:10 -0700)
commitce314107facc98da2b3c9ab73fae6c9b178bc19b
tree3a7537bac71922fd8224d03c2d181413e1cacb65
parente4500ab0f595eae4666ae602c733e9bac2eab92d
bpf: verifier: refactor check_attach_btf_id()

The check_attach_btf_id() function really does three things:

1. It performs a bunch of checks on the program to ensure that the
   attachment is valid.

2. It stores a bunch of state about the attachment being requested in
   the verifier environment and struct bpf_prog objects.

3. It allocates a trampoline for the attachment.

This patch splits out (1.) and (3.) into separate functions which will
perform the checks, but return the computed values instead of directly
modifying the environment. This is done in preparation for reusing the
checks when the actual attachment is happening, which will allow tracing
programs to have multiple (compatible) attachments.

This also fixes a bug where a bunch of checks were skipped if a trampoline
already existed for the tracing target.

Fixes: d8e49679b261 ("bpf: Attachment verification for BPF_MODIFY_RETURN")
Fixes: 786ce0aae4f2 ("bpf: Introduce sleepable BPF programs")
Acked-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/linux/bpf.h
include/linux/bpf_verifier.h
kernel/bpf/trampoline.c
kernel/bpf/verifier.c