[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ec2ca725-6228-b9e9-e9fc-34e4b34d8a1a@fb.com>
Date: Sat, 12 Oct 2019 01:29:39 +0000
From: Alexei Starovoitov <ast@...com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>,
Alexei Starovoitov <ast@...nel.org>
CC: "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 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.
Powered by blists - more mailing lists