Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

eBPF C: cannot use strcmp and strncmp #26

Closed
duyuchao opened this issue May 5, 2019 · 2 comments
Closed

eBPF C: cannot use strcmp and strncmp #26

duyuchao opened this issue May 5, 2019 · 2 comments

Comments

@duyuchao
Copy link
Contributor

duyuchao commented May 5, 2019

   I met an issue of cannot use strcmp(strcmp(key.comm, "xxx");), eBPF verify show below error, I traced strcmp realized in strcmp.S. 
   After I rewrite the strcmp function with C language, it works well, but I think this is inconvenient, so I want ask whether you have good idea, thank you.

========================error log============================
root@localhost:/# ./submit_bio.py
bpf: Failed to load program: Invalid argument
0: (79) r6 = *(u64 *)(r1 +0)
1: (b7) r1 = 0
2: (7b) *(u64 *)(r10 -8) = r1
3: (7b) *(u64 *)(r10 -16) = r1
4: (7b) *(u64 *)(r10 -24) = r1
5: (7b) *(u64 *)(r10 -32) = r1
6: (7b) *(u64 *)(r10 -40) = r1
7: (7b) *(u64 *)(r10 -48) = r1
8: (7b) *(u64 *)(r10 -56) = r1
9: (7b) *(u64 *)(r10 -64) = r1
10: (7b) *(u64 *)(r10 -72) = r1
11: (bf) r7 = r10
12: (07) r7 += -68
13: (bf) r1 = r7
14: (b7) r2 = 16
15: (85) call bpf_get_current_comm#16
16: (85) call bpf_get_current_pid_tgid#14
17: (63) *(u32 *)(r10 -52) = r0
18: (bf) r1 = r7
19: BUG_ld_00
invalid BPF_LD_IMM insn

Traceback (most recent call last):
File "./submit_bio.py", line 92, in
b.attach_kprobe(event="submit_bio", fn_name="print_submit_bio")
File "/usr/lib/python2.7/dist-packages/bcc/init.py", line 592, in attach_kprobe
fn = self.load_func(fn_name, BPF.KPROBE)
File "/usr/lib/python2.7/dist-packages/bcc/init.py", line 377, in load_func
(func_name, errstr))
Exception: Failed to load BPF program print_submit_bio: Invalid argument

@joelagnel
Copy link
Owner

joelagnel commented May 5, 2019 via email

@duyuchao
Copy link
Contributor Author

duyuchao commented May 6, 2019

ok

@duyuchao duyuchao closed this as completed May 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants