joelagnel / adeb

A debian-based shell environment designed for Android and adb
Apache License 2.0
319 stars 100 forks source link

eBPF C: cannot use strcmp and strncmp #26

Closed duyuchao closed 5 years ago

duyuchao commented 5 years ago
   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 commented 5 years ago

Could you open an issue on BCC project directly and we discuss there?

On Sun, May 5, 2019 at 5:57 AM duyuchao notifications@github.com wrote:

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

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/joelagnel/adeb/issues/26, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAJEVHF5EWSCEDTB4TLX7TPT2VRVANCNFSM4HK23YCQ .

duyuchao commented 5 years ago

ok