iovisor / bcc

BCC - Tools for BPF-based Linux IO analysis, networking, monitoring, and more
Apache License 2.0
20.58k stars 3.88k forks source link

bpf: Failed to load program: Invalid argument #4360

Open ghost opened 1 year ago

ghost commented 1 year ago

bpf: Failed to load program: Invalid argument

Traceback (most recent call last): File "examples/hello_world.py", line 12, in BPF(text='int kprobesys_clone(void *ctx) { bpf_trace_printk("Hello, World!\n"); return 0; }').trace_print() File "/usr/lib/python2.7/dist-packages/bcc/init.py", line 351, in init self._trace_autoload() File "/usr/lib/python2.7/dist-packages/bcc/init.py", line 1097, in _trace_autoload fn = self.load_func(func_name, BPF.KPROBE) File "/usr/lib/python2.7/dist-packages/bcc/init.py", line 391, in load_func (func_name, errstr)) Exception: Failed to load BPF program kprobesys_clone: Invalid argument

ghost commented 1 year ago

how to fix it ?

chenhengqi commented 1 year ago

What's the result of cat /proc/kallsyms | grep sys_clone ?

vladd12 commented 1 year ago

Maybe it's happens cause you use python 2.7? @chenhengqi, what you can say about a compability with python 2.7?

ghost commented 1 year ago

cat /proc/kallsyms | grep sys_clone result:ffffff979b554cd0 t sys_clone

ghost commented 1 year ago

root@localhost:/bcc-master# execsnoop bpf: Failed to load program: Invalid argument

Traceback (most recent call last): File "/usr/share/bcc/tools/execsnoop", line 172, in b.attach_kprobe(event=execve_fnname, fn_name="syscallexecve") File "/usr/lib/python2.7/dist-packages/bcc/init__.py", line 650, in attach_kprobe fn = self.load_func(fn_name, BPF.KPROBE) File "/usr/lib/python2.7/dist-packages/bcc/init.py", line 391, in load_func (func_name, errstr)) Exception: Failed to load BPF program syscall__execve: Invalid argument all script error is this result

ghost commented 1 year ago

i was compile android 12 ,android and open bpf kernel tracing, and run this demo is tip this text,pls brother help me

woodpenker commented 1 year ago

Does your kernel compiled with CONFIG_KPROBES enable? You can check that by zcat /proc/config.gz(if /proc/config.gz exists) or grep KPROBE /boot/config-$(uname -r)