Commit 8a6ca6bc authored by Andrii Nakryiko's avatar Andrii Nakryiko Committed by Daniel Borkmann

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: default avatarAndrii Nakryiko <andrii@kernel.org>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarLorenz Bauer <lmb@isovalent.com>
Link: https://lore.kernel.org/bpf/20230406234205.323208-11-andrii@kernel.org
parent cbedb42a
...@@ -5594,7 +5594,7 @@ static struct btf *btf_parse(bpfptr_t btf_data, u32 btf_data_size, ...@@ -5594,7 +5594,7 @@ static struct btf *btf_parse(bpfptr_t btf_data, u32 btf_data_size,
} }
bpf_vlog_finalize(log); bpf_vlog_finalize(log);
if (log->level && bpf_vlog_truncated(log)) { if (bpf_vlog_truncated(log)) {
err = -ENOSPC; err = -ENOSPC;
goto errout_meta; goto errout_meta;
} }
......
...@@ -169,7 +169,9 @@ static int bpf_vlog_reverse_ubuf(struct bpf_verifier_log *log, int start, int en ...@@ -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) 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; return bpf_log_used(log) >= log->len_total - 1;
else else
return log->start_pos > 0; return log->start_pos > 0;
......
...@@ -18861,12 +18861,10 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, bpfptr_t uattr) ...@@ -18861,12 +18861,10 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, bpfptr_t uattr)
env->prog->aux->verified_insns = env->insn_processed; env->prog->aux->verified_insns = env->insn_processed;
bpf_vlog_finalize(log); bpf_vlog_finalize(log);
if (log->level && bpf_vlog_truncated(log)) if (bpf_vlog_truncated(log))
ret = -ENOSPC; ret = -ENOSPC;
if (log->level && log->level != BPF_LOG_KERNEL && !log->ubuf) { if (log->level && log->level != BPF_LOG_KERNEL && !log->ubuf)
ret = -EFAULT; ret = -EFAULT;
goto err_release_maps;
}
if (ret) if (ret)
goto err_release_maps; goto err_release_maps;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment