lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211014191643.6c7ca819a732dd6479329a6b@kernel.org>
Date:   Thu, 14 Oct 2021 19:16:43 +0900
From:   Masami Hiramatsu <mhiramat@...nel.org>
To:     Kees Cook <keescook@...omium.org>
Cc:     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,
        Masami Hiramatsu <mhiramat@...nel.org>,
        Steven Rostedt <rostedt@...dmis.org>
Subject: Re: [PATCH] x86/unwind/orc: Handle kretprobes_trampoline

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/

> > > > 
> > > > This issue was discovered while testing the FG-KASLR series[0][1] and
> > > > running the live patching test[2] that was originally failing[3].
> > > > 
> > > > [0] https://lore.kernel.org/kernel-hardening/20200923173905.11219-1-kristen@linux.intel.com/
> > > > [1] https://github.com/KSPP/linux/issues/132
> > > > [2] https://github.com/lpechacek/qa_test_klp
> > > > [3] https://lore.kernel.org/lkml/alpine.LSU.2.21.2009251450260.13615@pobox.suse.cz/
> > > > 
> > > > Fixes: ee9f8fce9964 ("x86/unwind: Add the ORC unwinder")
> > > > Signed-off-by: Marios Pomonis <pomonis@...gle.com>
> > > > Cc: Josh Poimboeuf <jpoimboe@...hat.com>
> > > > Cc: Alexander Lobakin <alexandr.lobakin@...el.com>
> > > > Cc: Kristen C Accardi <kristen.c.accardi@...el.com>
> > > > Cc: Sami Tolvanen <samitolvanen@...gle.com>
> > > > Signed-off-by: Kees Cook <keescook@...omium.org>
> > > 
> > > Ping again; Josh can you take this please?
> > 
> > I'm confused how this still fixes anything after Masami's patch set,
> > which is now in linux-next.
> > 
> > After those patches, for a CALL-type ORC entry, the unwinder sets
> > state->ip to the address returned by unwind_recover_ret_addr().  In the
> > case of a kretprobe, that means that state->ip will no longer point to
> > kretprobes_trampoline() -- making the above patch description incorrect.
> > 
> > Instead, state->ip will then contain the original call return address
> > which was replaced by kretpobes.  So it looks to the unwinder like a
> > normal call return address, and 'state->signal' should remain false.
> > 
> > Am I missing something?
> 
> I'll let Marios answer in more detail, but my understanding is that
> Masami's patch set didn't solve the FGKASLR-vs-kretprobes issue[1].
> I don't understand _why_ yet, though.

My another question is that this fix still works correctly on my series,
because it's already merged via Steve's tree. Isn't this break anything?

I also need to know how (from where) the failed test uses stacktrace.
Does it call stacktrace from outside of kretprobe?

Thank you,

> 
> -Kees
> 
> [1] https://lore.kernel.org/all/CAKXAmdgS3SL_qyjzjY32_DXe3WVTN+O=wYwJ9vkUXKhjmt87fA@mail.gmail.com/
> 
> -- 
> Kees Cook


-- 
Masami Hiramatsu <mhiramat@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ