linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Detecting kprobes generated code addresses
@ 2016-12-22  6:40 Josh Poimboeuf
  0 siblings, 0 replies; 5+ messages in thread
From: Josh Poimboeuf @ 2016-12-22  6:40 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: linux-kernel, x86

Hi Masami,

I would like to make __kernel_text_address() be able to detect whether
an address belongs to code which was generated by kprobes.  As far as I
can tell, that information seems to be in the 'pages' lists of
kprobe_insn_slots and kprobe_optinsn_slots.  But they seem to be
protected by mutexes.  Do you know if there's a sleep-free way to access
that
protected 

-- 
Josh

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Detecting kprobes generated code addresses
  2016-12-25  6:16   ` Masami Hiramatsu
@ 2016-12-26  4:30     ` Masami Hiramatsu
  0 siblings, 0 replies; 5+ messages in thread
From: Masami Hiramatsu @ 2016-12-26  4:30 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: Josh Poimboeuf, linux-kernel, x86

On Sun, 25 Dec 2016 15:16:00 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> On Sun, 25 Dec 2016 12:13:20 +0900
> Masami Hiramatsu <mhiramat@kernel.org> wrote:
> 
> > On Thu, 22 Dec 2016 00:42:19 -0600
> > Josh Poimboeuf <jpoimboe@redhat.com> wrote:
> > 
> > > Hi Masami,
> > > 
> > > I would like to make __kernel_text_address() be able to detect whether
> > > an address belongs to code which was generated by kprobes.  As far as I
> > > can tell, that information seems to be in the 'pages' lists of
> > > kprobe_insn_slots and kprobe_optinsn_slots.  But they seem to be
> > > protected by mutexes.
> > 
> > Right. It is currently under mutex because it may kick
> > page allocation. But I think it is easy to fix that :)
> 
> Hmm, IMHO, it seems that we should add a dummy (auto-generated)
> symbol for optprobe trampoline code to kallsyms so that
> __kernel_text_address() automatically returns true on it.

Sorry, I reconsidered this idea and conclude it was overkill.
As same as ftrace does, maybe it is enough to add a check
routine to __kernel_text_address().

Thanks,

-- 
Masami Hiramatsu <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Detecting kprobes generated code addresses
  2016-12-25  3:13 ` Masami Hiramatsu
@ 2016-12-25  6:16   ` Masami Hiramatsu
  2016-12-26  4:30     ` Masami Hiramatsu
  0 siblings, 1 reply; 5+ messages in thread
From: Masami Hiramatsu @ 2016-12-25  6:16 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: Josh Poimboeuf, linux-kernel, x86

On Sun, 25 Dec 2016 12:13:20 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> On Thu, 22 Dec 2016 00:42:19 -0600
> Josh Poimboeuf <jpoimboe@redhat.com> wrote:
> 
> > Hi Masami,
> > 
> > I would like to make __kernel_text_address() be able to detect whether
> > an address belongs to code which was generated by kprobes.  As far as I
> > can tell, that information seems to be in the 'pages' lists of
> > kprobe_insn_slots and kprobe_optinsn_slots.  But they seem to be
> > protected by mutexes.
> 
> Right. It is currently under mutex because it may kick
> page allocation. But I think it is easy to fix that :)

Hmm, IMHO, it seems that we should add a dummy (auto-generated)
symbol for optprobe trampoline code to kallsyms so that
__kernel_text_address() automatically returns true on it.

Thank you,

-- 
Masami Hiramatsu <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Detecting kprobes generated code addresses
  2016-12-22  6:42 Josh Poimboeuf
@ 2016-12-25  3:13 ` Masami Hiramatsu
  2016-12-25  6:16   ` Masami Hiramatsu
  0 siblings, 1 reply; 5+ messages in thread
From: Masami Hiramatsu @ 2016-12-25  3:13 UTC (permalink / raw)
  To: Josh Poimboeuf; +Cc: linux-kernel, x86

On Thu, 22 Dec 2016 00:42:19 -0600
Josh Poimboeuf <jpoimboe@redhat.com> wrote:

> Hi Masami,
> 
> I would like to make __kernel_text_address() be able to detect whether
> an address belongs to code which was generated by kprobes.  As far as I
> can tell, that information seems to be in the 'pages' lists of
> kprobe_insn_slots and kprobe_optinsn_slots.  But they seem to be
> protected by mutexes.

Right. It is currently under mutex because it may kick
page allocation. But I think it is easy to fix that :)

>  Do you know if there's a sleep-free way to access
> that information?

Hmm, no, I couldn't find that yet.

Thanks,

-- 
Masami Hiramatsu <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Detecting kprobes generated code addresses
@ 2016-12-22  6:42 Josh Poimboeuf
  2016-12-25  3:13 ` Masami Hiramatsu
  0 siblings, 1 reply; 5+ messages in thread
From: Josh Poimboeuf @ 2016-12-22  6:42 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: linux-kernel, x86

Hi Masami,

I would like to make __kernel_text_address() be able to detect whether
an address belongs to code which was generated by kprobes.  As far as I
can tell, that information seems to be in the 'pages' lists of
kprobe_insn_slots and kprobe_optinsn_slots.  But they seem to be
protected by mutexes.  Do you know if there's a sleep-free way to access
that information?

-- 
Josh

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-12-26  4:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-22  6:40 Detecting kprobes generated code addresses Josh Poimboeuf
2016-12-22  6:42 Josh Poimboeuf
2016-12-25  3:13 ` Masami Hiramatsu
2016-12-25  6:16   ` Masami Hiramatsu
2016-12-26  4:30     ` Masami Hiramatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).