JiaHuann / libbpf-bootstrap-android

Do something to fit android aarch64 to develop ebpf programs using libbpf-bootstrap framework
BSD 3-Clause "New" or "Revised" License
32 stars 4 forks source link

BPF program load failed: Permission denied #1

Open lyg4795 opened 1 year ago

lyg4795 commented 1 year ago

按照文档编译运行了一下 报错了 有个Permission denied 但是我是root环境下跑的 raven:/data/local/tmp # ./myringbuffer libbpf: prog 'update_rq_clock': BPF program load failed: Permission denied libbpf: prog 'update_rq_clock': -- BEGIN PROG LOAD LOG -- Unrecognized arg#0 type PTR ; int BPF_KPROBE(update_rq_clock,struct rq rq){ 0: (79) r7 = (u64 )(r1 +0) ; mydata = bpf_ringbuf_reserve(&rb, sizeof(mydata), 0); 1: (18) r1 = 0xffffff89c0982600 3: (b7) r2 = 8 4: (b7) r3 = 0 5: (85) call bpf_ringbuf_reserve#131 6: (bf) r6 = r0 ; if(!mydata){//错误处理 7: (15) if r6 == 0x0 goto pc+7 R0_w=mem(id=0,ref_obj_id=2,off=0,imm=0) R6_w=mem(id=0,ref_obj_id=2,off=0,imm=0) R7_w=inv(id=0) R10=fp0 refs=2 ; mydata->__nr_running = rq->nr_running; //其他的先不管 8: (61) r1 = (u32 )(r7 +4) R7 invalid mem access 'inv' processed 8 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0 -- END PROG LOAD LOG -- libbpf: prog 'update_rq_clock': failed to load: -13 libbpf: failed to load object 'myringbuffer_bpf' libbpf: failed to load BPF skeleton 'myringbuffer_bpf': -13

JiaHuann commented 1 year ago

按照文档编译运行了一下 报错了 有个Permission denied 但是我是root环境下跑的 raven:/data/local/tmp # ./myringbuffer libbpf: prog 'update_rq_clock': BPF program load failed: Permission denied libbpf: prog 'update_rq_clock': -- BEGIN PROG LOAD LOG -- Unrecognized arg#0 type PTR ; int BPF_KPROBE(update_rq_clock,struct rq rq){ 0: (79) r7 = (u64 )(r1 +0) ; mydata = bpf_ringbuf_reserve(&rb, sizeof(mydata), 0); 1: (18) r1 = 0xffffff89c0982600 3: (b7) r2 = 8 4: (b7) r3 = 0 5: (85) call bpf_ringbuf_reserve#131 6: (bf) r6 = r0 ; if(!mydata){//错误处理 7: (15) if r6 == 0x0 goto pc+7 R0_w=mem(id=0,ref_obj_id=2,off=0,imm=0) R6_w=mem(id=0,ref_obj_id=2,off=0,imm=0) R7_w=inv(id=0) R10=fp0 refs=2 ; mydata->__nr_running = rq->nr_running; //其他的先不管 8: (61) r1 = (u32 )(r7 +4) R7 invalid mem access 'inv' processed 8 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0 -- END PROG LOAD LOG -- libbpf: prog 'update_rq_clock': failed to load: -13 libbpf: failed to load object 'myringbuffer_bpf' libbpf: failed to load BPF skeleton 'myringbuffer_bpf': -13

Hi,可以给我更多关于你的环境的信息吗,这个myringbuffer是我另外写的,如果运行不了可以先删除这个,看看其他的libbpf-bootstrap上游自带的能否可以正常运行

lyg4795 commented 1 year ago

系统是 pixel6 pro 5.10.107内核 Linux localhost 5.10.107 #1 SMP PREEMPT Wed Aug 9 11:34:27 UTC 2023 aarch64 Toybox 编译的pc是Ubuntu Linux lin 5.19.0-45-generic #46~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Jun 7 15:06:04 UTC 20 x86_64 x86_64 x86_64 GNU/Linux 我试了一下主要问题的 bpf_ringbuf_reserve函数导致的, 如果删了ringbuf相关函数就OK.

arg#0 type is not a struct
Unrecognized arg#0 type PTR
; e = bpf_ringbuf_reserve(&rb, sizeof(*e), 0);
0: (18) r1 = 0xffffff89b5760200
2: (b7) r2 = 8
3: (b7) r3 = 0
4: (85) call bpf_ringbuf_reserve#131
; bpf_ringbuf_submit(e, 0);
5: (bf) r1 = r0
6: (b7) r2 = 0
7: (85) call bpf_ringbuf_submit#132
R1 type=mem_or_null expected=mem
processed 7 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0
-- END PROG LOAD LOG --

我试了下perf 有类似的问题

libbpf: map 'minimal_.bss': created successfully, fd=6
libbpf: prog 'handle_tp': BPF program load failed: Permission denied
libbpf: prog 'handle_tp': -- BEGIN PROG LOAD LOG --
arg#0 type is not a struct
Unrecognized arg#0 type PTR
; bpf_perf_event_output(ctx, &events, BPF_F_CURRENT_CPU, e, sizeof(*e));
0: (18) r2 = 0xffffff805ee0a600
2: (18) r3 = 0xffffffff
4: (b7) r5 = 8
5: (85) call bpf_perf_event_output#25
R4 !read_ok
processed 4 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0
-- END PROG LOAD LOG --
libbpf: prog 'handle_tp': failed to load: -13