Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1554544

Re: [PATCH tip/master v4] kprobes: extable: Identify kprobes' insn-slots as kernel text area

From Josh Poimboeuf <jpoimboe@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH tip/master v4] kprobes: extable: Identify kprobes' insn-slots as kernel text area
Date 2017-01-09 18:40 +0100
Message-ID <sXM5k-77I-33@gated-at.bofh.it> (permalink)
References <sVQG6-3e8-1@gated-at.bofh.it> <sXngB-80n-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sun, Jan 08, 2017 at 11:58:09PM +0900, Masami Hiramatsu wrote:
> Make __kernel_text_address()/kernel_text_address() returns
> true if the given address is on a kprobe's instruction slot,
> which is generated by kprobes as a trampoline code.
> This can help stacktraces to determine the address is on a
> text area or not.
> 
> To implement this without any sleep in is_kprobe_*_slot(),
> this also modify insn_cache page list as a rcu list. It may
> increase processing deley (not processing time) for garbage
> slot collection, because it requires to wait an additional
> rcu grance period when freeing a page from the list.
> However, since it is not a hot path, we may not take care of it.
> 
> Note: this can give a small overhead to stack unwinders because
> this adds 2 checks in __kernel_text_address(). However, the
> impact should be very small, kprobe_insn_pages list has 1 entry
> per 256 probes(on x86, on arm/arm64 it will be 1024 probes),
> and kprobe_optinsn_pages has 1 entry per 32 probes(on x86).
> In most use cases, the number of kprobe events may be less
> than 20, this means is_kprobe_*_slot() will check just 1 entry.
> 
> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>

Thanks for doing this Masami!  I verified that it works:

  Tested-by: Josh Poimboeuf <jpoimboe@redhat.com>

I suspect that BPF generated code also has the same issue, so I'll leave
the unwinder warning disabled for now.

BTW, I think we'll have more problems with generated code if/when we
move to an x86 DWARF unwinder, because it won't have any idea how to
unwind past generated code.  Long term I wonder if it would make sense
to create some kind of framework for creating or registering generated
code, so we can solve these types of problems in a single place.

-- 
Josh

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH tip/master v3] kprobes: extable: Identify kprobes'  insn-slots as kernel text area Masami Hiramatsu <mhiramat@kernel.org> - 2017-01-04 06:10 +0100
  Re: [PATCH tip/master v3] kprobes: extable: Identify kprobes'  insn-slots as kernel text area Peter Zijlstra <peterz@infradead.org> - 2017-01-04 11:10 +0100
    Re: [PATCH tip/master v3] kprobes: extable: Identify kprobes'  insn-slots as kernel text area Masami Hiramatsu <mhiramat@kernel.org> - 2017-01-08 05:30 +0100
      Re: [PATCH tip/master v3] kprobes: extable: Identify kprobes'  insn-slots as kernel text area Masami Hiramatsu <mhiramat@kernel.org> - 2017-01-08 13:40 +0100
    [PATCH tip/master v4] kprobes: extable: Identify kprobes' insn-slots as kernel text area Masami Hiramatsu <mhiramat@kernel.org> - 2017-01-08 16:10 +0100
      Re: [PATCH tip/master v4] kprobes: extable: Identify kprobes'  insn-slots as kernel text area Josh Poimboeuf <jpoimboe@redhat.com> - 2017-01-09 18:40 +0100
        Re: [PATCH tip/master v4] kprobes: extable: Identify kprobes'  insn-slots as kernel text area Masami Hiramatsu <mhiramat@kernel.org> - 2017-01-10 02:20 +0100
        Re: [PATCH tip/master v4] kprobes: extable: Identify kprobes'  insn-slots as kernel text area Peter Zijlstra <peterz@infradead.org> - 2017-01-10 10:00 +0100
          Re: [PATCH tip/master v4] kprobes: extable: Identify kprobes'  insn-slots as kernel text area Josh Poimboeuf <jpoimboe@redhat.com> - 2017-01-10 22:50 +0100
            Re: [PATCH tip/master v4] kprobes: extable: Identify kprobes'  insn-slots as kernel text area Masami Hiramatsu <mhiramat@kernel.org> - 2017-01-11 11:00 +0100
      [tip:perf/core] kprobes, extable: Identify kprobes trampolines as  kernel text area tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2017-01-14 11:00 +0100

csiph-web