Message ID | 20230404043659.2282536-9-andrii@kernel.org (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | BPF verifier rotating log | expand |
On Tue, Apr 4, 2023 at 5:37 AM Andrii Nakryiko <andrii@kernel.org> wrote: > > 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> Acked-by: Lorenz Bauer <lmb@isovalent.com>
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 2574cc9b3e28..a67b1b669b0c 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);
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> --- kernel/bpf/btf.c | 4 ++++ 1 file changed, 4 insertions(+)