Skip to content

Instantly share code, notes, and snippets.

@hfingler
Created September 30, 2022 21:54
Show Gist options
  • Save hfingler/5c2c0b713299daa6b0ba07fa92ff29de to your computer and use it in GitHub Desktop.
Save hfingler/5c2c0b713299daa6b0ba07fa92ff29de to your computer and use it in GitHub Desktop.
libbpf kfunc Permission denied
libbpf: loading object 'hello_bpf' from buffer
libbpf: elf: section(3) tc, size 152, link 0, flags 6, type=1
libbpf: sec 'tc': found program 'kfunc_call_test1' at insn offset 0 (0 bytes), code size 19 insns (152 bytes)
libbpf: elf: section(4) .reltc, size 16, link 11, flags 40, type=9
libbpf: elf: section(5) license, size 4, link 0, flags 3, type=1
libbpf: license of hello_bpf is GPL
libbpf: elf: section(6) .BTF, size 89879, link 0, flags 0, type=1
libbpf: elf: section(8) .BTF.ext, size 236, link 0, flags 0, type=1
libbpf: elf: section(11) .symtab, size 144, link 1, flags 0, type=2
libbpf: looking for externs among 6 symbols...
libbpf: collected 1 externs total
libbpf: extern (ksym) #0: symbol 4, name bpf_kfunc_call_test1
libbpf: sec '.reltc': collecting relocation for section(3) 'tc'
libbpf: sec '.reltc': relo #0: insn #13 against 'bpf_kfunc_call_test1'
libbpf: prog 'kfunc_call_test1': found extern #0 'bpf_kfunc_call_test1' (sym 4) for insn #13
libbpf: loading kernel BTF '/sys/kernel/btf/vmlinux': 0
libbpf: extern (func ksym) 'bpf_kfunc_call_test1': resolved to kernel [108667]
libbpf: sec 'tc': found 1 CO-RE relocations
libbpf: CO-RE relocating [2] struct __sk_buff: found target candidate [26333] struct __sk_buff in [vmlinux]
libbpf: prog 'kfunc_call_test1': relo #0: <byte_off> [2] struct __sk_buff.sk (0:30:0 @ offset 168)
libbpf: prog 'kfunc_call_test1': relo #0: matching candidate #0 <byte_off> [26333] struct __sk_buff.sk (0:30:0 @ offset 168)
libbpf: prog 'kfunc_call_test1': relo #0: patched insn #2 (LDX/ST/STX) off 168 -> 168
libbpf: prog 'kfunc_call_test1': BPF program load failed: Permission denied
libbpf: prog 'kfunc_call_test1': -- BEGIN PROG LOAD LOG --
0: R1=ctx(off=0,imm=0) R10=fp0
; int kfunc_call_test1(struct __sk_buff *skb)
0: (18) r6 = 0xffffffff ; R6_w=4294967295
; struct bpf_sock *sk = skb->sk;
2: (79) r1 = *(u64 *)(r1 +168) ; R1_w=sock_common_or_null(id=1,off=0,imm=0)
; if (!sk)
3: (15) if r1 == 0x0 goto pc+13 ; R1_w=sock_common(off=0,imm=0)
; sk = bpf_sk_fullsock(sk);
4: (85) call bpf_sk_fullsock#95 ; R0_w=sock_or_null(id=2,off=0,imm=0)
; if (!sk)
5: (15) if r0 == 0x0 goto pc+11 ; R0_w=sock(off=0,imm=0)
; a = bpf_kfunc_call_test1((struct sock *)sk, 1, a | 2, 3, a | 4);
6: (bf) r1 = r0 ; R0_w=sock(off=0,imm=0) R1_w=sock(off=0,imm=0)
7: (b7) r2 = 1 ; R2_w=1
8: (18) r3 = 0x100000002 ; R3_w=4294967298
10: (b7) r4 = 3 ; R4_w=3
11: (18) r5 = 0x100000004 ; R5_w=4294967300
13: (85) call bpf_kfunc_call_test1#108667
calling kernel function bpf_kfunc_call_test1 is not allowed
processed 11 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0
-- END PROG LOAD LOG --
libbpf: prog 'kfunc_call_test1': failed to load: -13
libbpf: failed to load object 'hello_bpf'
libbpf: failed to load BPF skeleton 'hello_bpf': -13
Failed to load and verify BPF skeleton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment