From: Daniel Borkmann Date: Fri, 2 Nov 2018 10:35:46 +0000 (+0100) Subject: bpf: fix bpf_prog_get_info_by_fd to return 0 func_lens for unpriv X-Git-Tag: v4.19.5~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a7ccf42cb03cd9976134eea111cfc5168a0ea31;p=thirdparty%2Fkernel%2Fstable.git 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 Cc: Sandipan Das Cc: Song Liu Signed-off-by: Alexei Starovoitov Signed-off-by: Sasha Levin --- diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 675eb6d36e474..382c09dddf93b 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -1974,6 +1974,7 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog, info.jited_prog_len = 0; info.xlated_prog_len = 0; info.nr_jited_ksyms = 0; + info.nr_jited_func_lens = 0; goto done; }