[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <b16deef3-c736-1979-2ce8-6b03b426be67@fb.com>
Date: Sat, 12 Oct 2019 04:53:16 +0000
From: Alexei Starovoitov <ast@...com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
CC: Alexei Starovoitov <ast@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Daniel Borkmann <daniel@...earbox.net>,
"x86@...nel.org" <x86@...nel.org>,
Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
Kernel Team <Kernel-team@...com>
Subject: Re: [PATCH v2 bpf-next 05/12] libbpf: auto-detect btf_id of
raw_tracepoint
On 10/11/19 9:38 PM, Andrii Nakryiko wrote:
> On Fri, Oct 11, 2019 at 6:29 PM Alexei Starovoitov <ast@...com> wrote:
>>
>> On 10/11/19 5:40 PM, Alexei Starovoitov wrote:
>>>> But even if kernel supports attach_btf_id, I think users still need to
>>>> opt in into specifying attach_btf_id by libbpf. Think about existing
>>>> raw_tp programs that are using bpf_probe_read() because they were not
>>>> created with this kernel feature in mind. They will suddenly stop
>>>> working without any of user's fault.
>>>
>>> This one is excellent catch.
>>> loop1.c should have caught it, since it has
>>> SEC("raw_tracepoint/kfree_skb")
>>> {
>>> int nested_loops(volatile struct pt_regs* ctx)
>>> .. = PT_REGS_RC(ctx);
>>>
>>> and verifier would have rejected it.
>>> But the way the test is written it's not using libbpf's autodetect
>>> of program type, so everything is passing.
>>
>> With:
>> diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_verif_scale.c
>> b/tools/testing/selftests/bpf/prog_tests/bpf_verif_scale.c
>> index 1c01ee2600a9..e27156dce10d 100644
>> --- a/tools/testing/selftests/bpf/prog_tests/bpf_verif_scale.c
>> +++ b/tools/testing/selftests/bpf/prog_tests/bpf_verif_scale.c
>> @@ -67,7 +67,7 @@ void test_bpf_verif_scale(void)
>> */
>> { "pyperf600_nounroll.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
>>
>> - { "loop1.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
>> + { "loop1.o", BPF_PROG_TYPE_UNSPEC},
>> { "loop2.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
>>
>> libbpf prog auto-detection kicks in and ...
>> # ./test_progs -n 3/10
>> libbpf: load bpf program failed: Permission denied
>> libbpf: -- BEGIN DUMP LOG ---
>> libbpf:
>> raw_tp 'kfree_skb' doesn't have 10-th argument
>> invalid bpf_context access off=80 size=8
>>
>> Good :) The verifier is doing its job.
>
> oh, another super intuitive error from verifier ;) 10th argument, what?..
I know, but there is no env->linfo and no insn_idx to call
verbose_linfo() from there. That's even bigger refactoring
that I'd rather to later.
Powered by blists - more mailing lists