lkml.org 
[lkml]   [2021]   [Nov]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] static_call,x86: Robustify trampoline patching
On Sat, Oct 30, 2021 at 10:16:31AM +0200, Peter Zijlstra wrote:
> foo.cfi:
> endbr
> xorl $0xdeadbeef, %r10d
> jz foo
> ud2
> nop # make it an even 16 bytes
> foo:
> # actual function text
>
>
> Then have the address of foo, be the address of foo, like any normal
> sane person would expect. Have direct calls to foo, go to foo, again, as
> expected.
>
> When doing an indirect call (to r11, as clang does), then, and only
> then, do:
>
> movl $0xdeadbeef, %r10d
> subq $0x10, %r11
> call *%r11
>
> # if the r11 lives, add:
> addq $0x10, %r11
>
>
> Then only when caller and callee agree 0xdeadbeef is the password, does
> the indirect call go through.
>
> Why isn't this a suitable CFI scheme even without IBT?

The trouble is that the callee is doing the verification. There's no
protection against calling into a callee that doesn't perform a check
(e.g. BPF JIT, or otherwise constructed executable memory, etc). The
caller needs to do the verification that what they're calling into is
safe before it makes the call.

--
Kees Cook

\
 
 \ /
  Last update: 2021-11-02 18:36    [W:0.185 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site