All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yonghong Song <yhs@fb.com>
To: asaf eitani <eitaniasaf@gmail.com>, <bpf@vger.kernel.org>
Subject: Re: Failed to attach to kprobe (non blacklisted)
Date: Tue, 6 Jul 2021 09:03:12 -0700	[thread overview]
Message-ID: <30a11562-d804-122b-97c9-27cac1a24f77@fb.com> (raw)
In-Reply-To: <CAAihumD0AOem=UhqRBDULQ6ZDL=n2vhn-3rLJq+mOm5-q2Wfjw@mail.gmail.com>



On 7/6/21 4:56 AM, asaf eitani wrote:
> Hi BPF experts,
> 
> I'm having issues to attach to certain kprobes and kretprobes that are
> not in the blacklist, like ftrace_modify_all_code.
> There are kernel modules that are capable of attaching to those
> kprobes and kretprobes but I could not attach them using libbpf.

Any details what kind of kernel modules you use to make kprobes work
for ftrace_modify_all_code()?

> 
> I tried using both tracee(https://github.com/aquasecurity/tracee) and
> bpftrace(https://github.com/iovisor/bpftrace) to attach to those
> kprobes, which to my understanding uses libbpf, but both of them
> returned an "Invalid argument" error.
> 
> As the blacklist doesn't seem to cover all the functions which are not
> attachable to kprobes, is there a way to get/compile such a list?
> Also, what is the specific problem with attaching to this function
> (ftrace_modify_all_code)?

The file trace/ftrace.c is compiled without FTRACE flag.

See trace/Makefile:
ccflags-remove-$(CONFIG_FUNCTION_TRACER) += $(CC_FLAGS_FTRACE)

ffffffff811888b0 <ftrace_modify_all_code>:
ffffffff811888b0: 41 54                 pushq   %r12
ffffffff811888b2: b8 02 00 00 00        movl    $2, %eax
ffffffff811888b7: 41 89 fc              movl    %edi, %r12d
ffffffff811888ba: 55                    pushq   %rbp
ffffffff811888bb: 89 fd                 movl    %edi, %ebp

I doesn't have a call to __fentry__ like below.
ffffffff8101cae0: e8 7b 48 be 00        callq   0xffffffff81c01360 
<__fentry__>


> 
> Thanks.
> 

      reply	other threads:[~2021-07-06 16:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-06 11:56 Failed to attach to kprobe (non blacklisted) asaf eitani
2021-07-06 16:03 ` Yonghong Song [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=30a11562-d804-122b-97c9-27cac1a24f77@fb.com \
    --to=yhs@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=eitaniasaf@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.