bpf: btf: limit logging of ignored BTF mismatches
authorConnor O'Brien <connoro@google.com>
Sat, 7 Jan 2023 02:53:31 +0000 (02:53 +0000)
committerMartin KaFai Lau <martin.lau@kernel.org>
Tue, 10 Jan 2023 23:58:30 +0000 (15:58 -0800)
commit9cb61e50bf6bf54db712bba6cf20badca4383f96
tree6e006bfe6f75aa5fe72ee89e92ad1731c88b529c
parent7f7880495770329d095d402c2865bfa7089192f8
bpf: btf: limit logging of ignored BTF mismatches

Enabling CONFIG_MODULE_ALLOW_BTF_MISMATCH is an indication that BTF
mismatches are expected and module loading should proceed
anyway. Logging with pr_warn() on every one of these "benign"
mismatches creates unnecessary noise when many such modules are
loaded. Instead, handle this case with a single log warning that BTF
info may be unavailable.

Mismatches also result in calls to __btf_verifier_log() via
__btf_verifier_log_type() or btf_verifier_log_member(), adding several
additional lines of logging per mismatched module. Add checks to these
paths to skip logging for module BTF mismatches in the "allow
mismatch" case.

All existing logging behavior is preserved in the default
CONFIG_MODULE_ALLOW_BTF_MISMATCH=n case.

Signed-off-by: Connor O'Brien <connoro@google.com>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/r/20230107025331.3240536-1-connoro@google.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
kernel/bpf/btf.c