mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Kees Cook <keescook@chromium.org>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	Marios Pomonis <pomonis@google.com>,
	Alexander Lobakin <alexandr.lobakin@intel.com>,
	Kristen C Accardi <kristen.c.accardi@intel.com>,
	Sami Tolvanen <samitolvanen@google.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ivan Babrou <ivan@cloudflare.com>,
	Jiri Slaby <jirislaby@kernel.org>,
	Julien Thierry <jthierry@redhat.com>,
	linux-kernel@vger.kernel.org, x86@kernel.org,
	linux-hardening@vger.kernel.org,
	Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH] x86/unwind/orc: Handle kretprobes_trampoline
Date: Fri, 22 Oct 2021 00:13:47 +0900	[thread overview]
Message-ID: <20211022001347.6da975173bc8c797595630e6@kernel.org> (raw)
In-Reply-To: <20211014191643.6c7ca819a732dd6479329a6b@kernel.org>

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>

  reply	other threads:[~2021-10-21 15:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-03  2:13 Kees Cook
2021-09-04 17:55 ` Josh Poimboeuf
2021-09-05  7:57   ` Masami Hiramatsu
2021-09-24 17:17     ` Marios Pomonis
2021-10-11 21:03 ` Kees Cook
2021-10-14  1:41   ` Josh Poimboeuf
2021-10-14  4:52     ` Kees Cook
2021-10-14 10:16       ` Masami Hiramatsu
2021-10-21 15:13         ` Masami Hiramatsu [this message]
2021-10-29 18:19           ` Marios Pomonis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211022001347.6da975173bc8c797595630e6@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=alexandr.lobakin@intel.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=ivan@cloudflare.com \
    --cc=jirislaby@kernel.org \
    --cc=jpoimboe@redhat.com \
    --cc=jthierry@redhat.com \
    --cc=keescook@chromium.org \
    --cc=kristen.c.accardi@intel.com \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=pomonis@google.com \
    --cc=rostedt@goodmis.org \
    --cc=samitolvanen@google.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome