summaryrefslogtreecommitdiffstats
path: root/kernel/bpf/syscall.c
diff options
context:
space:
mode:
authorYafang Shao <laoar.shao@gmail.com>2023-08-13 16:18:59 +0200
committerDaniel Borkmann <daniel@iogearbox.net>2023-08-16 16:44:23 +0200
commit0aa35162d2a1ed7ae5303b8d91f7290d3b8b9219 (patch)
tree6f024ce8ddafb7a080a191ebc7dd479aa90b2baa /kernel/bpf/syscall.c
parentnet: Fix slab-out-of-bounds in inet[6]_steal_sock (diff)
downloadlinux-0aa35162d2a1ed7ae5303b8d91f7290d3b8b9219.tar.xz
linux-0aa35162d2a1ed7ae5303b8d91f7290d3b8b9219.zip
bpf: Fix uninitialized symbol in bpf_perf_link_fill_kprobe()
The commit 1b715e1b0ec5 ("bpf: Support ->fill_link_info for perf_event") leads to the following Smatch static checker warning: kernel/bpf/syscall.c:3416 bpf_perf_link_fill_kprobe() error: uninitialized symbol 'type'. That can happens when uname is NULL. So fix it by verifying the uname when we really need to fill it. Fixes: 1b715e1b0ec5 ("bpf: Support ->fill_link_info for perf_event") Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Yafang Shao <laoar.shao@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Yonghong Song <yonghong.song@linux.dev> Acked-by: Jiri Olsa <jolsa@kernel.org> Closes: https://lore.kernel.org/bpf/85697a7e-f897-4f74-8b43-82721bebc462@kili.mountain Link: https://lore.kernel.org/bpf/20230813141900.1268-2-laoar.shao@gmail.com
Diffstat (limited to '')
-rw-r--r--kernel/bpf/syscall.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 7f4e8c357a6a..cb658543bdb4 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -3378,14 +3378,13 @@ static int bpf_perf_link_fill_common(const struct perf_event *event,
if (!ulen ^ !uname)
return -EINVAL;
- if (!uname)
- return 0;
err = bpf_get_perf_event_info(event, &prog_id, fd_type, &buf,
probe_offset, probe_addr);
if (err)
return err;
-
+ if (!uname)
+ return 0;
if (buf) {
len = strlen(buf);
err = bpf_copy_to_user(uname, buf, ulen, len);