Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1316167

Re: [PATCH 2/2] perf bpf: Check relocation target section

From "Wangnan (F)" <wangnan0@huawei.com>
Newsgroups linux.kernel
Subject Re: [PATCH 2/2] perf bpf: Check relocation target section
Date 2016-01-25 03:10 +0100
Message-ID <qUELp-5lG-23@gated-at.bofh.it> (permalink)
References <qTGcy-25g-19@gated-at.bofh.it> <qTGcy-25g-17@gated-at.bofh.it> <qTNxp-77w-27@gated-at.bofh.it> <qUEBI-513-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



On 2016/1/25 9:56, Wangnan (F) wrote:
>
>
> On 2016/1/23 1:11, Alexei Starovoitov wrote:
>> On Fri, Jan 22, 2016 at 09:27:21AM +0000, Wang Nan wrote:
>>> Libbpf should check target section before doing relocation to ensure
>>> the relocation is correct. If not, a bug in LLVM causes error. See [1].
>>> Also, if an incorrect BPF script uses both global variable and
>>> map, global variable whould be treated as map and be relocated
>>> without error.
>>>
>>> This patch saves id of map section into obj->efile and compare
>>> target section of a relocation symbol against it during relocation.
>> ...
>>> [1] https://llvm.org/bugs/show_bug.cgi?id=26243
>> ...
>>> Signed-off-by: Wang Nan <wangnan0@huawei.com>
>>>   +        if (sym.st_shndx != maps_shndx) {
>>> +            pr_warning("Program '%s' contains non-map related relo 
>>> data pointing to section %u\n",
>>> +                   prog->section_name, sym.st_shndx);
>>> +            return -LIBBPF_ERRNO__RELOC;

There's a trailing whitespace. Sorry.

>>> +        }
>> May be 'pr_err' instead of 'pr_warning', since such program will fail
>> to load by kernel anyway.
>
> Libbpf doesn't issue pr_error even in fatal exception because it 
> doesn't define
> pr_err at all. It reports error code and let perf deal with error.
>
> Thank you.
>
>>   Looks good otherwise.
>> Acked-by: Alexei Starovoitov <ast@kernel.org>
>>
>

Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

[PATCH 2/2] perf bpf: Check relocation target section Wang Nan <wangnan0@huawei.com> - 2016-01-22 10:30 +0100
  Re: [PATCH 2/2] perf bpf: Check relocation target section Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-01-22 18:20 +0100
    Re: [PATCH 2/2] perf bpf: Check relocation target section "Wangnan (F)" <wangnan0@huawei.com> - 2016-01-25 03:00 +0100
      Re: [PATCH 2/2] perf bpf: Check relocation target section "Wangnan (F)" <wangnan0@huawei.com> - 2016-01-25 03:10 +0100

csiph-web