Messages in this thread | | | Date | Tue, 2 Nov 2021 19:15:58 +0100 | From | Peter Zijlstra <> | Subject | Re: [PATCH] static_call,x86: Robustify trampoline patching |
| |
On Tue, Nov 02, 2021 at 10:35:30AM -0700, Kees Cook wrote: > 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.
Right, Ard said the same, see new crackpot scheme here:
https://lkml.kernel.org/r/YYE1yPClPMHvyvIt@hirez.programming.kicks-ass.net
| |