From 91cdd32f65b2bea7df9cd6b9bad04d8d08068bb8 Mon Sep 17 00:00:00 2001 From: Martin Lau Date: Thu, 3 Jan 2019 23:36:22 +0000 Subject: [PATCH] tests: fix prog_info initialization in bpf-obj_get_info_by_fd-prog* The sys_bpf(BPF_OBJ_GET_INFO_BY_FD, &bpf_prog_get_info_attr, ...) is called in a loop. The bpf_prog_get_info_attr.info object is in size 104 but bpf_prog_get_info_attr.info_len is in size 168. Hence, if the prog is jited, the second iteration onwards will have nr_jited_ksyms == 1 which is asking the kernel to fill the bpf_prog_get_info_attr.info.jited_ksyms and it is NULL. * tests/bpf-obj_get_info_by_fd.c (main): Clear memory beyond prog_info at the start of every iteration. Co-Authored-by: Dmitry V. Levin --- tests/bpf-obj_get_info_by_fd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/bpf-obj_get_info_by_fd.c b/tests/bpf-obj_get_info_by_fd.c index de23831a..fba0e75b 100644 --- a/tests/bpf-obj_get_info_by_fd.c +++ b/tests/bpf-obj_get_info_by_fd.c @@ -345,6 +345,7 @@ main(void) memset(prog_info, 0, PROG_INFO_SZ); for (unsigned int i = 0; i < 4; i++) { prog_info->jited_prog_len = 0; + memset(prog_info + 1, 0, PROG_INFO_SZ - sizeof(*prog_info)); switch (i) { case 1: prog_info->xlated_prog_insns = -- 2.40.0