aboutsummaryrefslogtreecommitdiff
path: root/kernel/bpf
diff options
context:
space:
mode:
authorAndrii Nakryiko2023-04-06 16:41:54 -0700
committerDaniel Borkmann2023-04-11 18:05:43 +0200
commit971fb5057d787d0a7e7c8cb910207c82e2db920e (patch)
tree9e4340cffdef789e1df368ee3087c0d73b882011 /kernel/bpf
parent24bc80887adb4d6fc0057d4f14fabeaa4502b2a0 (diff)
bpf: Fix missing -EFAULT return on user log buf error in btf_parse()
btf_parse() is missing -EFAULT error return if log->ubuf was NULL-ed out due to error while copying data into user-provided buffer. Add it, but handle a special case of BPF_LOG_KERNEL in which log->ubuf is always NULL. 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-9-andrii@kernel.org
Diffstat (limited to 'kernel/bpf')
-rw-r--r--kernel/bpf/btf.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index 20a05b8932db..6372c144a294 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -5598,6 +5598,10 @@ static struct btf *btf_parse(bpfptr_t btf_data, u32 btf_data_size,
err = -ENOSPC;
goto errout_meta;
}
+ if (log->level && log->level != BPF_LOG_KERNEL && !log->ubuf) {
+ err = -EFAULT;
+ goto errout_meta;
+ }
btf_verifier_env_free(env);
refcount_set(&btf->refcnt, 1);