[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211022001347.6da975173bc8c797595630e6@kernel.org>
Date: Fri, 22 Oct 2021 00:13:47 +0900
From: Masami Hiramatsu <mhiramat@...nel.org>
To: Masami Hiramatsu <mhiramat@...nel.org>
Cc: Kees Cook <keescook@...omium.org>,
Josh Poimboeuf <jpoimboe@...hat.com>,
Marios Pomonis <pomonis@...gle.com>,
Alexander Lobakin <alexandr.lobakin@...el.com>,
Kristen C Accardi <kristen.c.accardi@...el.com>,
Sami Tolvanen <samitolvanen@...gle.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
"H. Peter Anvin" <hpa@...or.com>,
Peter Zijlstra <peterz@...radead.org>,
Ivan Babrou <ivan@...udflare.com>,
Jiri Slaby <jirislaby@...nel.org>,
Julien Thierry <jthierry@...hat.com>,
linux-kernel@...r.kernel.org, x86@...nel.org,
linux-hardening@...r.kernel.org,
Steven Rostedt <rostedt@...dmis.org>
Subject: Re: [PATCH] x86/unwind/orc: Handle kretprobes_trampoline
On Thu, 14 Oct 2021 19:16:43 +0900
Masami Hiramatsu <mhiramat@...nel.org> wrote:
> On Wed, 13 Oct 2021 21:52:36 -0700
> Kees Cook <keescook@...omium.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@...gle.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@...nel.org>
Powered by blists - more mailing lists