lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <7400a2b2-1e1e-0981-3966-43492305534c@linux.alibaba.com>
Date:   Sat, 17 Jul 2021 09:39:56 +0800
From:   Shuyi Cheng <chengshuyi@...ux.alibaba.com>
To:     Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc:     Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>, Martin Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        john fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...nel.org>,
        Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
        open list <linux-kernel@...r.kernel.org>,
        kernel-janitors@...r.kernel.org
Subject: Re: [PATCH bpf-next v4 3/3] selftests/bpf: Switches existing
 selftests to using open_opts for custom BTF



On 7/17/21 4:27 AM, Andrii Nakryiko wrote:
> On Tue, Jul 13, 2021 at 5:43 AM Shuyi Cheng
> <chengshuyi@...ux.alibaba.com> wrote:
>>
>> This patch mainly replaces the bpf_object_load_attr of
>> the core_autosize.c and core_reloc.c files with bpf_object_open_opts.
>>
>> Signed-off-by: Shuyi Cheng <chengshuyi@...ux.alibaba.com>
>> ---
>>   .../selftests/bpf/prog_tests/core_autosize.c       | 22 ++++++++---------
>>   .../testing/selftests/bpf/prog_tests/core_reloc.c  | 28 ++++++++++------------
>>   2 files changed, 24 insertions(+), 26 deletions(-)
>>
> 
> So I applied this, but it's obvious you haven't bothered even
> *building* selftests, because it had at least one compilation warning
> and one compilation *error*, not building test_progs at all. I've
> noted stuff I fixed (and still remember) below. I understand it might
> be your first kernel contribution, but it's not acceptable to submit
> patches that don't build. Next time please be more thorough.
> 

I'm very sorry, it was my fault. Although I learned a lot from libbpf, 
there is still a lot to learn and improve. Thank you very much for your 
advice and the very powerful libbpf.

regards,
Shuyi

> [...]
> 
>>
>> -       load_attr.obj = skel->obj;
>> -       load_attr.target_btf_path = btf_file;
>> -       err = bpf_object__load_xattr(&load_attr);
>> +       err = bpf_object__load(skel);
> 
> This didn't compile outright, because it should have been
> test_core_autosize__load(skel).
> 
>>          if (!ASSERT_ERR(err, "bad_prog_load"))
>>                  goto cleanup;
>>
>> diff --git a/tools/testing/selftests/bpf/prog_tests/core_reloc.c b/tools/testing/selftests/bpf/prog_tests/core_reloc.c
>> index d02e064..10eb2407 100644
>> --- a/tools/testing/selftests/bpf/prog_tests/core_reloc.c
>> +++ b/tools/testing/selftests/bpf/prog_tests/core_reloc.c
>> @@ -816,7 +816,7 @@ static size_t roundup_page(size_t sz)
>>   void test_core_reloc(void)
>>   {
>>          const size_t mmap_sz = roundup_page(sizeof(struct data));
>> -       struct bpf_object_load_attr load_attr = {};
>> +       struct bpf_object_open_opts open_opts = {};
>>          struct core_reloc_test_case *test_case;
>>          const char *tp_name, *probe_name;
>>          int err, i, equal;
>> @@ -846,9 +846,17 @@ void test_core_reloc(void)
>>                                  continue;
>>                  }
>>
>> -               obj = bpf_object__open_file(test_case->bpf_obj_file, NULL);
>> +               if (test_case->btf_src_file) {
>> +                       err = access(test_case->btf_src_file, R_OK);
>> +                       if (!ASSERT_OK(err, "btf_src_file"))
>> +                               goto cleanup;
>> +               }
>> +
>> +               open_opts.btf_custom_path = test_case->btf_src_file;
> 
> This was reporting a valid warning about dropping const modifier. For
> good reason, becyase btf_custom_path in open_opts should have been
> `const char *`, I fixed that.
> 
>> +               open_opts.sz = sizeof(struct bpf_object_open_opts);
>> +               obj = bpf_object__open_file(test_case->bpf_obj_file, &open_opts);
>>                  if (!ASSERT_OK_PTR(obj, "obj_open"))
>> -                       continue;
>> +                       goto cleanup;
>>
>>                  probe_name = "raw_tracepoint/sys_enter";
>>                  tp_name = "sys_enter";
> 
> [...]
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ