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]
Date:   Tue, 2 Nov 2021 18:44:56 +0100
From:   Ard Biesheuvel <ardb@...nel.org>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     Sami Tolvanen <samitolvanen@...gle.com>,
        Mark Rutland <mark.rutland@....com>, X86 ML <x86@...nel.org>,
        Kees Cook <keescook@...omium.org>,
        Josh Poimboeuf <jpoimboe@...hat.com>,
        Nathan Chancellor <nathan@...nel.org>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        Sedat Dilek <sedat.dilek@...il.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        linux-hardening@...r.kernel.org,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        llvm@...ts.linux.dev, joao@...rdrivepizza.com
Subject: Re: [PATCH] static_call,x86: Robustify trampoline patching

On Tue, 2 Nov 2021 at 16:15, Peter Zijlstra <peterz@...radead.org> wrote:
>
> On Tue, Nov 02, 2021 at 01:57:44PM +0100, Peter Zijlstra wrote:
>
> > So how insane is something like this, have each function:
> >
> > foo.cfi:
> >       endbr64
> >       xorl $0xdeadbeef, %r10d
> >       jz foo
> >       ud2
> >       nop     # make it 16 bytes
> > foo:
> >       # actual function text goes here
> >
> >
> > And for each hash have two thunks:
> >
> >
> >       # arg: r11
> >       # clobbers: r10, r11
> > __x86_indirect_cfi_deadbeef:
> >       movl -9(%r11), %r10             # immediate in foo.cfi
> >       xorl $0xdeadbeef, %r10          # our immediate
> >       jz 1f
> >       ud2
> > 1:    ALTERNATIVE_2   "jmp *%r11",
> >                       "jmp __x86_indirect_thunk_r11", X86_FEATURE_RETPOLINE
> >                       "lfence; jmp *%r11", X86_FEATURE_RETPOLINE_AMD
> >

So are these supposed to go into the jump tables? If so, there still
needs to be a check against the boundary of the table at the call
site, to ensure that we are not calling something that we shouldn't.

If they are not going into the jump tables, I don't see the point of
having them, as only happy flow/uncomprised code would bother to use
them.


> >
> >
> >       # arg: r11
> >       # clobbers: r10, r11
> > __x86_indirect_ibt_deadbeef:
> >       movl $0xdeadbeef, %r10
> >       subq $0x10, %r11
> >       ALTERNATIVE "", "lfence", X86_FEATURE_RETPOLINE
> >       jmp *%r11
> >
>
> These two thunks could of course be one big alternative.
>
> > And have the actual indirect callsite look like:
> >
> >       # r11 - &foo
> >       ALTERNATIVE_2   "cs call __x86_indirect_thunk_r11",
> >                       "cs call __x86_indirect_cfi_deadbeef", X86_FEATURE_CFI
> >                       "cs call __x86_indirect_ibt_deadbeef", X86_FEATURE_IBT
>
> Also simplifying this.
>
> > Although if the compiler were to emit:
> >
> >       cs call __x86_indirect_cfi_deadbeef
> >
> > we could probaly fix it up from there.
> >
> >
> > Then we can at runtime decide between:
> >
> >   {!cfi, cfi, ibt} x {!retpoline, retpoline, retpoline-amd}
> >

Powered by blists - more mailing lists