bpf: fix bpf_prog_get_info_by_fd to return 0 func_lens for unpriv
authorDaniel Borkmann <daniel@iogearbox.net>
Fri, 2 Nov 2018 10:35:46 +0000 (11:35 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 27 Nov 2018 15:13:03 +0000 (16:13 +0100)
commit1a7ccf42cb03cd9976134eea111cfc5168a0ea31
tree5b505cb086d2fc384963dcf52483127930e9564a
parent5e4ad7cec8f81ce022d51e6e2d4059d45cc3ac12
bpf: fix bpf_prog_get_info_by_fd to return 0 func_lens for unpriv

[ Upstream commit 28c2fae726bf5003cd209b0d5910a642af98316f ]

While dbecd7388476 ("bpf: get kernel symbol addresses via syscall")
zeroed info.nr_jited_ksyms in bpf_prog_get_info_by_fd() for queries
from unprivileged users, commit 815581c11cc2 ("bpf: get JITed image
lengths of functions via syscall") forgot about doing so and therefore
returns the #elems of the user set up buffer which is incorrect. It
also needs to indicate a info.nr_jited_func_lens of zero.

Fixes: 815581c11cc2 ("bpf: get JITed image lengths of functions via syscall")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Sandipan Das <sandipan@linux.vnet.ibm.com>
Cc: Song Liu <songliubraving@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/bpf/syscall.c