[OT] Pseudo module name in kallsyms (Re: [PATCH V3 03/13] kprobes: Add symbols for kprobe insn pages)

From: Masami Hiramatsu
Date: Tue Mar 03 2020 - 05:47:07 EST


Hi,

On Mon, 2 Mar 2020 15:43:07 +0100
Jiri Olsa <jolsa@xxxxxxxxxx> wrote:

> On Sat, Feb 29, 2020 at 06:49:13PM -0500, Steven Rostedt wrote:
> > On Sat, 29 Feb 2020 13:49:47 +0900
> > Masami Hiramatsu <mhiramat@xxxxxxxxxx> wrote:
> >
> > > On Fri, 28 Feb 2020 18:20:04 +0100
> > > Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
> > >
> > > > > BTW, it seems to pretend to be a module, but is there no concern of
> > > > > confusing users? Shouldn't it be [*kprobes] so that it is non-exist
> > > > > module name?
> > > >
> > > > note we already have bpf symbols as [bpf] module
> > >
> > > Yeah, and this series adds [kprobe(s)] and [ftrace] too.
> > > I simply concern that the those module names implicitly become
> > > special word (rule) and embedded in the code. If such module names
> > > are not exposed to users, it is OK (but I hope to have some comments).
> > > However, it is under /proc, which means users can notice it.
> >
> > I share Masami's concerns. It would be good to have something
> > differentiate local functions that are not modules. That's one way I
> > look to see if something is a module or built in, is to see if kallsyms
> > has it as a [].
> >
> > Perhaps prepend with: '&' ?

Yeah, '*' may not good from the filename point of view.

>
> that would break some of the perf code.. IMO Arnaldo's explanation
> makes sense and we could keep it as it is

From the in-kernel API/coding point of view,

+static int get_ksymbol_kprobe(struct kallsym_iter *iter)
+{
+ strlcpy(iter->module_name, "kprobe", MODULE_NAME_LEN);
+ iter->exported = 0;
+ return kprobe_get_kallsym(iter->pos - iter->pos_bpf_end,
+ &iter->value, &iter->type,
+ iter->name) < 0 ? 0 : 1;
}

This clearly shows that is a iter->module_name.

And also, if someone make a module names "kprobes.ko", it will also
have [kprobes] in kallsyms. That is also confusing.


Thank you,

--
Masami Hiramatsu <mhiramat@xxxxxxxxxx>