OSDN Git Service

bpf: Add bpf_verifier_vlog() and bpf_verifier_log_needed()
authorMartin KaFai Lau <kafai@fb.com>
Sat, 24 Mar 2018 18:44:23 +0000 (11:44 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 26 Mar 2018 07:58:17 +0000 (09:58 +0200)
commit77d2e05abd45886dcad2b632c738cf46b9f7c19e
treedab2d5beef6275329e8ed3dbaff7f720d6f05f6c
parentb9193c1b61ddb97da4713155b0d580e41fb544ac
bpf: Add bpf_verifier_vlog() and bpf_verifier_log_needed()

The BTF (BPF Type Format) verifier needs to reuse the current
BPF verifier log.  Hence, it requires the following changes:

(1) Expose log_write() in verifier.c for other users.
    Its name is renamed to bpf_verifier_vlog().

(2) The BTF verifier also needs to check
'log->level && log->ubuf && !bpf_verifier_log_full(log);'
independently outside of the current log_write().  It is
because the BTF verifier will do one-check before
making multiple calls to btf_verifier_vlog to log
the details of a type.

Hence, this check is also re-factored to a new function
bpf_verifier_log_needed().  Since it is re-factored,
we can check it before va_start() in the current
bpf_verifier_log_write() and verbose().

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Acked-by: Alexei Starovoitov <ast@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
include/linux/bpf_verifier.h
kernel/bpf/verifier.c