[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <f8470b35-dac3-fc11-50a5-06760754a944@fb.com>
Date: Tue, 23 Jun 2020 18:23:55 -0700
From: Yonghong Song <yhs@...com>
To: Alexei Starovoitov <alexei.starovoitov@...il.com>
CC: Andrii Nakryiko <andriin@...com>, bpf <bpf@...r.kernel.org>,
Network Development <netdev@...r.kernel.org>,
Alexei Starovoitov <ast@...com>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii.nakryiko@...il.com>,
Kernel Team <kernel-team@...com>
Subject: Re: [PATCH bpf] libbpf: fix CO-RE relocs against .text section
On 6/23/20 5:40 PM, Alexei Starovoitov wrote:
> On Sat, Jun 20, 2020 at 12:06 AM Yonghong Song <yhs@...com> wrote:
>>
>>
>>
>> On 6/19/20 4:04 PM, Andrii Nakryiko wrote:
>>> bpf_object__find_program_by_title(), used by CO-RE relocation code, doesn't
>>> return .text "BPF program", if it is a function storage for sub-programs.
>>> Because of that, any CO-RE relocation in helper non-inlined functions will
>>> fail. Fix this by searching for .text-corresponding BPF program manually.
>>>
>>> Adjust one of bpf_iter selftest to exhibit this pattern.
>>>
>>> Reported-by: Yonghong Song <yhs@...com>
>>> Fixes: ddc7c3042614 ("libbpf: implement BPF CO-RE offset relocation algorithm")
>>> Signed-off-by: Andrii Nakryiko <andriin@...com>
>>
>> Acked-by: Yonghong Song <yhs@...com>
>>
>> But the fix here only fixed the issue for interpreter mode.
>> For jit only mode, we still have issues. The following patch can fix
>> the jit mode issue,
>>
>> =============
>>
>> From 4d66814513ec45b86a30a1231b8a000d4bfc6f1a Mon Sep 17 00:00:00 2001
>> From: Yonghong Song <yhs@...com>
>> Date: Fri, 19 Jun 2020 23:26:13 -0700
>> Subject: [PATCH bpf] bpf: set the number of exception entries properly for
>> subprograms
>>
>> Currently, if a bpf program has more than one subprograms, each
>> program will be jitted separately. For tracing problem, the
>> prog->aux->num_exentries is not setup properly. For example,
>> with bpf_iter_netlink.c modified to force one function not inlined,
>> and with proper libbpf fix, with CONFIG_BPF_JIT_ALWAYS_ON,
>> we will have error like below:
>> $ ./test_progs -n 3/3
>> ...
>> libbpf: failed to load program 'iter/netlink'
>> libbpf: failed to load object 'bpf_iter_netlink'
>> libbpf: failed to load BPF skeleton 'bpf_iter_netlink': -4007
>> test_netlink:FAIL:bpf_iter_netlink__open_and_load skeleton
>> open_and_load failed
>> #3/3 netlink:FAIL
>> The dmesg shows the following errors:
>> ex gen bug
>> which is triggered by the following code in arch/x86/net/bpf_jit_comp.c:
>> if (excnt >= bpf_prog->aux->num_exentries) {
>> pr_err("ex gen bug\n");
>> return -EFAULT;
>> }
>>
>> If the program has more than one subprograms, num_exentries is actually
>> 0 since it is not setup.
>>
>> This patch fixed the issue by setuping proper num_exentries for
>> each subprogram before calling jit function.
>>
>> Signed-off-by: Yonghong Song <yhs@...com>
>
> Thanks for fixing. Applied both to bpf tree.
> Yonghong, next time please submit the patch properly.
> It was very awkward to copy-paste it manually from the thread.
> I've edited the commit log a bit.
Thanks. I posted original commit as I am not sure how to proceed as
this and Andrii's patch belongs to the same patch set to fix
bpf_iter_netlink problem. I guess next time I will go ahead with
patch submit with proper description in the patch, which
sounds better for review and to get notice from other people.
Powered by blists - more mailing lists