diff options
author | Andrii Nakryiko <andrii@kernel.org> | 2023-04-07 02:41:56 +0300 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2023-04-11 19:05:43 +0300 |
commit | 8a6ca6bc553e3c878fa53c506bc6ec281efdc039 (patch) | |
tree | 909f38061d67bc33561cb8d80f850df7db2b2804 /kernel | |
parent | cbedb42a0da3bb48819b2200af4b4cb5d922c518 (diff) | |
download | linux-8a6ca6bc553e3c878fa53c506bc6ec281efdc039.tar.xz |
bpf: Simplify logging-related error conditions handling
Move log->level == 0 check into bpf_vlog_truncated() instead of doing it
explicitly. Also remove unnecessary goto in kernel/bpf/verifier.c.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Lorenz Bauer <lmb@isovalent.com>
Link: https://lore.kernel.org/bpf/20230406234205.323208-11-andrii@kernel.org
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/bpf/btf.c | 2 | ||||
-rw-r--r-- | kernel/bpf/log.c | 4 | ||||
-rw-r--r-- | kernel/bpf/verifier.c | 6 |
3 files changed, 6 insertions, 6 deletions
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 6372c144a294..5aa540ee611f 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -5594,7 +5594,7 @@ static struct btf *btf_parse(bpfptr_t btf_data, u32 btf_data_size, } bpf_vlog_finalize(log); - if (log->level && bpf_vlog_truncated(log)) { + if (bpf_vlog_truncated(log)) { err = -ENOSPC; goto errout_meta; } diff --git a/kernel/bpf/log.c b/kernel/bpf/log.c index d99a50f07187..c778f3b290cb 100644 --- a/kernel/bpf/log.c +++ b/kernel/bpf/log.c @@ -169,7 +169,9 @@ static int bpf_vlog_reverse_ubuf(struct bpf_verifier_log *log, int start, int en bool bpf_vlog_truncated(const struct bpf_verifier_log *log) { - if (log->level & BPF_LOG_FIXED) + if (!log->level) + return false; + else if (log->level & BPF_LOG_FIXED) return bpf_log_used(log) >= log->len_total - 1; else return log->start_pos > 0; diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 0323149803f5..a98cbc046d1e 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -18861,12 +18861,10 @@ skip_full_check: env->prog->aux->verified_insns = env->insn_processed; bpf_vlog_finalize(log); - if (log->level && bpf_vlog_truncated(log)) + if (bpf_vlog_truncated(log)) ret = -ENOSPC; - if (log->level && log->level != BPF_LOG_KERNEL && !log->ubuf) { + if (log->level && log->level != BPF_LOG_KERNEL && !log->ubuf) ret = -EFAULT; - goto err_release_maps; - } if (ret) goto err_release_maps; |