Re: [RFC bpf-next 4/4] selftests/bpf: Add attach bench test

From: Steven Rostedt
Date: Thu Apr 28 2022 - 20:09:58 EST


On Thu, 28 Apr 2022 19:53:03 -0400
Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

> > But that __fentry__ call is not part of __bpf_tramp_exit, actually.
> > Whether to call it a bug or limitation is secondary. It marks
> > __bpf_tramp_exit as attachable through kprobe/ftrace while it really
> > isn't.
>
> I'm confused by what you mean by "marks __bpf_tramp_exit as attachable"?
> What does? Where does it get that information? Does it read
> available_filter_functions?

OK, I think I see the issue you have. Because the functions shown in
available_filter_functions which uses the simple "%ps" to show the function
name:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/trace/ftrace.c#n3692

And the code that does the actual matching uses kallsyms_lookup()

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/trace/ftrace.c#n4017

Which appears not to match the function for the address, you can't pass in
__bpf_tramp_exit because it wont match the symbol returned by
kallsyms_lookup.

This does indeed look like a bug in %ps.

But in the mean time, I could open code %ps and see if that fixes it. I'll
give it try.

-- Steve