]> granicus.if.org Git - strace/commitdiff
tests: fix prog_info initialization in bpf-obj_get_info_by_fd-prog*
authorMartin Lau <kafai@fb.com>
Thu, 3 Jan 2019 23:36:22 +0000 (23:36 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sat, 5 Jan 2019 21:14:42 +0000 (21:14 +0000)
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 <ldv@altlinux.org>
tests/bpf-obj_get_info_by_fd.c

index de23831a09acd6514f9f38aa97f7aed138153b1e..fba0e75b0f263c64f651f979ae4ecf71f6736103 100644 (file)
@@ -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 =