lkml.org 
[lkml]   [2022]   [May]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH v2 20/21] x86: Add support for CONFIG_CFI_CLANG
On Tue, May 17, 2022 at 10:05:17AM +0200, Peter Zijlstra wrote:
> On Mon, May 16, 2022 at 03:59:41PM -0700, Kees Cook wrote:
>
> > I'm still not convinced about this, but I'm on the fence.
> >
> > Cons:
> > - FineIBT does callee-based hash verification, which means any
> > attacker-constructed memory region just has to have an endbr and nops at
> > "shellcode - 9". KCFI would need the region to have the hash at
> > "shellcode - 6" and an endbr at "shellcode". However, that hash is well
> > known, so it's not much protection.
>
> How would you get the ENDBR there anyway? If you can write code it's
> game over.
>
> > - Potential performance hit due to making an additional "call" outside
> > the cache lines of both caller and callee.
>
> That was all an effort to shrink and simplify, all this CFI stuff is
> massive bloat :/
>
> If we use %eax instead of %r10d for the hash transfer (as per Joao), and
> use int3 instead of ud2, then we can shrink the fineibt sequence to:
>
> __cfi_\func:
> endbr # 4
> xorl $0x12345678, %eax # 5
> jz 1f # 2
> int3 # 1
> \func:
> ...
>
> Which is 12 bytes, and needs a larger preamble (up from 9 in the current
> proposal).

On all that; perhaps it would be good to have a compiler option to
specify the preamble size. It can enforce the minimum at 7 to have at
least the required:

movl $0x12345678, %eax
int3
int3

but any larger number will just increase the preamble with int3 padding
at the top.

That can go right along with the option to supress endbr when preamble
:-)

\
 
 \ /
  Last update: 2022-05-17 10:42    [W:2.590 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site