Re: [PATCH -tip 0/5] kprobes: Fix stacktrace in kretprobes

2021-03-11 Thread Masami Hiramatsu
On Thu, 11 Mar 2021 10:51:10 -0600 Josh Poimboeuf wrote: > On Thu, Mar 11, 2021 at 10:54:38AM +0900, Masami Hiramatsu wrote: > > On Wed, 10 Mar 2021 19:06:15 -0600 > > Josh Poimboeuf wrote: > > > > > On Thu, Mar 11, 2021 at 09:20:18AM +0900, Masami Hiramatsu wrote: > > > > > > bool

Re: [PATCH -tip 0/5] kprobes: Fix stacktrace in kretprobes

2021-03-11 Thread Josh Poimboeuf
On Thu, Mar 11, 2021 at 10:54:38AM +0900, Masami Hiramatsu wrote: > On Wed, 10 Mar 2021 19:06:15 -0600 > Josh Poimboeuf wrote: > > > On Thu, Mar 11, 2021 at 09:20:18AM +0900, Masami Hiramatsu wrote: > > > > > bool unwind_next_frame(struct unwind_state *state) > > > > > { > > > > >

Re: [PATCH -tip 0/5] kprobes: Fix stacktrace in kretprobes

2021-03-10 Thread Masami Hiramatsu
On Wed, 10 Mar 2021 19:06:15 -0600 Josh Poimboeuf wrote: > On Thu, Mar 11, 2021 at 09:20:18AM +0900, Masami Hiramatsu wrote: > > > > bool unwind_next_frame(struct unwind_state *state) > > > > { > > > > unsigned long ip_p, sp, tmp, orig_ip = state->ip, prev_sp = > > > > state->sp; > >

Re: [PATCH -tip 0/5] kprobes: Fix stacktrace in kretprobes

2021-03-10 Thread Josh Poimboeuf
On Thu, Mar 11, 2021 at 09:20:18AM +0900, Masami Hiramatsu wrote: > > > bool unwind_next_frame(struct unwind_state *state) > > > { > > > unsigned long ip_p, sp, tmp, orig_ip = state->ip, prev_sp = state->sp; > > > @@ -536,6 +561,18 @@ bool unwind_next_frame(struct unwind_state *state) > > >

Re: [PATCH -tip 0/5] kprobes: Fix stacktrace in kretprobes

2021-03-10 Thread Masami Hiramatsu
On Wed, 10 Mar 2021 12:31:13 -0600 Josh Poimboeuf wrote: > On Thu, Mar 11, 2021 at 12:55:09AM +0900, Masami Hiramatsu wrote: > > +#ifdef CONFIG_KRETPROBES > > +static unsigned long orc_kretprobe_correct_ip(struct unwind_state *state) > > +{ > > + return kretprobe_find_ret_addr( > > +

Re: [PATCH -tip 0/5] kprobes: Fix stacktrace in kretprobes

2021-03-10 Thread Daniel Xu
On Thu, Mar 11, 2021 at 12:55:09AM +0900, Masami Hiramatsu wrote: > Hi Josh and Daniel, <...> > commit aa452d999b524b1851f69cc947be3e1a2f3ca1ec > Author: Masami Hiramatsu > Date: Sat Mar 6 08:34:51 2021 +0900 > > x86/unwind/orc: Fixup kretprobe trampoline entry > > Since the

Re: [PATCH -tip 0/5] kprobes: Fix stacktrace in kretprobes

2021-03-10 Thread Josh Poimboeuf
On Thu, Mar 11, 2021 at 12:55:09AM +0900, Masami Hiramatsu wrote: > +#ifdef CONFIG_KRETPROBES > +static unsigned long orc_kretprobe_correct_ip(struct unwind_state *state) > +{ > + return kretprobe_find_ret_addr( > + (unsigned long)kretprobe_trampoline_addr(), > +

Re: [PATCH -tip 0/5] kprobes: Fix stacktrace in kretprobes

2021-03-10 Thread Masami Hiramatsu
Hi Josh and Daniel, On Wed, 10 Mar 2021 09:08:45 -0600 Josh Poimboeuf wrote: > On Wed, Mar 10, 2021 at 06:57:34PM +0900, Masami Hiramatsu wrote: > > > If I understand correctly, for #1 you need an unwind hint which treats > > > the instruction *after* the "pushq %rsp" as the beginning of the >

Re: [PATCH -tip 0/5] kprobes: Fix stacktrace in kretprobes

2021-03-10 Thread Josh Poimboeuf
On Wed, Mar 10, 2021 at 06:57:34PM +0900, Masami Hiramatsu wrote: > > If I understand correctly, for #1 you need an unwind hint which treats > > the instruction *after* the "pushq %rsp" as the beginning of the > > function. > > Thanks for the patch. In that case, should I still change the stack

Re: [PATCH -tip 0/5] kprobes: Fix stacktrace in kretprobes

2021-03-10 Thread Masami Hiramatsu
On Tue, 9 Mar 2021 13:34:42 -0800 Daniel Xu wrote: > Hi Masami, > > Just want to clarify a few points: > > On Mon, Mar 08, 2021 at 11:52:10AM +0900, Masami Hiramatsu wrote: > > On Sun, 7 Mar 2021 13:23:33 -0800 > > Daniel Xu wrote: > > To help your understanding, let me explain. > > > > If

Re: [PATCH -tip 0/5] kprobes: Fix stacktrace in kretprobes

2021-03-10 Thread Masami Hiramatsu
Hi Josh, On Mon, 8 Mar 2021 19:19:45 -0600 Josh Poimboeuf wrote: > On Mon, Mar 08, 2021 at 11:52:10AM +0900, Masami Hiramatsu wrote: > > So at the kretprobe handler, we have 2 issues. > > 1) the return address (caller_func+0x15) is not on the stack. > >this can be solved by searching from

Re: [PATCH -tip 0/5] kprobes: Fix stacktrace in kretprobes

2021-03-09 Thread Daniel Xu
Hi Masami, Just want to clarify a few points: On Mon, Mar 08, 2021 at 11:52:10AM +0900, Masami Hiramatsu wrote: > On Sun, 7 Mar 2021 13:23:33 -0800 > Daniel Xu wrote: > To help your understanding, let me explain. > > If we have a code here > > caller_func: > 0x00 add sp, 0x20 /* 0x20

Re: [PATCH -tip 0/5] kprobes: Fix stacktrace in kretprobes

2021-03-08 Thread Josh Poimboeuf
On Mon, Mar 08, 2021 at 11:52:10AM +0900, Masami Hiramatsu wrote: > So at the kretprobe handler, we have 2 issues. > 1) the return address (caller_func+0x15) is not on the stack. >this can be solved by searching from current->kretprobe_instances. > 2) the stack frame size of

Re: [PATCH -tip 0/5] kprobes: Fix stacktrace in kretprobes

2021-03-08 Thread Masami Hiramatsu
On Mon, 8 Mar 2021 11:52:10 +0900 Masami Hiramatsu wrote: > So, here is my idea; > > 1) Change the trampline code to prepare stack frame at first and save >registers on it, instead of "push". This will makes ORC easy to setup >stackframe information for this code. > 2) change the return

Re: [PATCH -tip 0/5] kprobes: Fix stacktrace in kretprobes

2021-03-07 Thread Masami Hiramatsu
On Sun, 7 Mar 2021 13:23:33 -0800 Daniel Xu wrote: > > kretprobe replaces the real return address with kretprobe_trampoline > > and kretprobe_trampoline *calls* trampoline_handler (this part depends > > on architecture implementation). > > Thus, if kretprobe_trampoline has no stack frame

Re: [PATCH -tip 0/5] kprobes: Fix stacktrace in kretprobes

2021-03-07 Thread Daniel Xu
On Sat, Mar 06, 2021 at 10:13:57AM +0900, Masami Hiramatsu wrote: > On Fri, 5 Mar 2021 11:16:45 -0800 > Daniel Xu wrote: > > > Hi Masami, > > > > On Sat, Mar 06, 2021 at 12:38:57AM +0900, Masami Hiramatsu wrote: > > > Hello, > > > > > > Here is a series of patches for kprobes and stacktracer

Re: [PATCH -tip 0/5] kprobes: Fix stacktrace in kretprobes

2021-03-05 Thread Masami Hiramatsu
On Fri, 5 Mar 2021 11:16:45 -0800 Daniel Xu wrote: > Hi Masami, > > On Sat, Mar 06, 2021 at 12:38:57AM +0900, Masami Hiramatsu wrote: > > Hello, > > > > Here is a series of patches for kprobes and stacktracer to fix the kretprobe > > entries in the kernel stack. This was reported by Daniel Xu.

Re: [PATCH -tip 0/5] kprobes: Fix stacktrace in kretprobes

2021-03-05 Thread Daniel Xu
Hi Masami, On Sat, Mar 06, 2021 at 12:38:57AM +0900, Masami Hiramatsu wrote: > Hello, > > Here is a series of patches for kprobes and stacktracer to fix the kretprobe > entries in the kernel stack. This was reported by Daniel Xu. I thought that > was in the bpftrace, but it is actually more

[PATCH -tip 0/5] kprobes: Fix stacktrace in kretprobes

2021-03-05 Thread Masami Hiramatsu
Hello, Here is a series of patches for kprobes and stacktracer to fix the kretprobe entries in the kernel stack. This was reported by Daniel Xu. I thought that was in the bpftrace, but it is actually more generic issue. So I decided to fix the issue in arch independent part. While fixing the