bpf: Remove !func_info and !line_info check from test_btf and bpftool
authorMartin KaFai Lau <kafai@fb.com>
Wed, 12 Dec 2018 18:18:22 +0000 (10:18 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 13 Dec 2018 11:16:31 +0000 (12:16 +0100)
kernel can provide the func_info and line_info even
it fails the btf_dump_raw_ok() test because they don't contain
kernel address.  This patch removes the corresponding '== 0'
test.

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/bpf/bpftool/prog.c
tools/lib/bpf/bpf_prog_linfo.c
tools/testing/selftests/bpf/test_btf.c

index eddf7fba41c6f4ebf3abf0afa40b83274d5f08ae..ee51279be9c7efb45d086c314864b4ab3857974c 100644 (file)
@@ -596,13 +596,6 @@ static int do_dump(int argc, char **argv)
                goto err_free;
        }
 
-       if (func_info && !info.func_info) {
-               /* kernel.kptr_restrict is set.  No func_info available. */
-               free(func_info);
-               func_info = NULL;
-               nr_finfo = 0;
-       }
-
        if (linfo && info.nr_line_info != nr_linfo) {
                p_err("incorrect nr_line_info %u vs. expected %u",
                      info.nr_line_info, nr_linfo);
index addd6e9971cc08c67e895d462ce5ab647c91410a..6978314ea7f688da21823bba2c58f564f8aea1f1 100644 (file)
@@ -107,11 +107,7 @@ struct bpf_prog_linfo *bpf_prog_linfo__new(const struct bpf_prog_info *info)
 
        nr_linfo = info->nr_line_info;
 
-       /*
-        * Test !info->line_info because the kernel may NULL
-        * the ptr if kernel.kptr_restrict is set.
-        */
-       if (!nr_linfo || !info->line_info)
+       if (!nr_linfo)
                return NULL;
 
        /*
index f570e0a39959ec3b87e8bae29366d72e1af5da97..8478316aaf9a9d74e53163972b3d79ba8c3fd830 100644 (file)
@@ -3948,12 +3948,6 @@ static int test_get_finfo(const struct prog_info_raw_test *test,
                goto done;
        }
 
-       if (CHECK(!info.func_info,
-                 "info.func_info == 0. kernel.kptr_restrict is set?")) {
-               err = -1;
-               goto done;
-       }
-
        finfo = func_info;
        for (i = 0; i < test->func_info_cnt; i++) {
                if (CHECK(finfo->type_id != test->func_info[i][1],
@@ -4077,7 +4071,6 @@ static int test_get_linfo(const struct prog_info_raw_test *test,
         * Other fields are not the concern of this test.
         */
        if (CHECK(err == -1 ||
-                 !info.line_info ||
                  info.nr_line_info != cnt ||
                  (jited_cnt && !info.jited_line_info) ||
                  info.nr_jited_line_info != jited_cnt ||