Messages in this thread | | | From | Marios Pomonis <> | Date | Fri, 29 Oct 2021 11:19:49 -0700 | Subject | Re: [PATCH] x86/unwind/orc: Handle kretprobes_trampoline |
| |
On Thu, Oct 21, 2021 at 8:13 AM Masami Hiramatsu <mhiramat@kernel.org> wrote: > > On Thu, 14 Oct 2021 19:16:43 +0900 > Masami Hiramatsu <mhiramat@kernel.org> wrote: > > > On Wed, 13 Oct 2021 21:52:36 -0700 > > Kees Cook <keescook@chromium.org> wrote: > > > > > On Wed, Oct 13, 2021 at 06:41:01PM -0700, Josh Poimboeuf wrote: > > > > On Mon, Oct 11, 2021 at 02:03:26PM -0700, Kees Cook wrote: > > > > > On Thu, Sep 02, 2021 at 07:13:26PM -0700, Kees Cook wrote: > > > > > > From: Marios Pomonis <pomonis@google.com> > > > > > > > > > > > > Fix a bug in the ORC unwinder when kretprobes has replaced a return > > > > > > address with the address of `kretprobes_trampoline'. ORC mistakenly > > > > > > assumes that the address in the stack is a return address and decrements > > > > > > it by 1 in order to find the proper depth of the next frame. > > > > Hmm, with my fixes[1], the kretprobe_trampoline address in the stack will be > > replaced with the correct return address. In that case, that behavior > > sounds correct. > > > > [1] https://lore.kernel.org/all/163163030719.489837.2236069935502195491.stgit@devnote2/ > > Here is the code which I applied this on my series. > > /* Find IP, SP and possibly regs: */ > switch (orc->type) { > case UNWIND_HINT_TYPE_CALL: > ip_p = sp - sizeof(long); > > if (!deref_stack_reg(state, ip_p, &state->ip)) > goto err; > > state->ip = unwind_recover_ret_addr(state, state->ip, > (unsigned long *)ip_p); > state->sp = sp; > state->regs = NULL; > state->prev_regs = NULL; > state->signal = is_kretprobe_trampoline(state->ip); > break; > > Actually, this cause a build issue because I introduced more generic is_kretprobe_trampoline(). > Anyway, after calling unwind_recover_ret_addr(), the state->ip should be fixed. > This means that the is_kretprobe_trampoline(state->ip) always be false, and > that is correct because state->ip is recovered with the correct return address > which is call instruction + 5. > > So this patch seems not needed, hmm... > > Thank you, > > -- > Masami Hiramatsu <mhiramat@kernel.org>
You're right, I made a mistake when testing this code; this is what happens when you create patches with debugging changes and then forget to remove them. I re-checked and your patch does solve the issue, so the cover mail fix is not needed (I had created it against the then-linux-next branch which didn't include your patch).
Thanks for catching this and I apologize for the (very) late response!
| |