[PATCH v2] arm64: implement support for static call trampolines
Quentin Perret
qperret at google.com
Mon Nov 16 07:05:27 EST 2020
On Monday 16 Nov 2020 at 11:31:10 (+0100), Ard Biesheuvel wrote:
> OK, so that would suggest that having at least the out-of-line
> trampoline would help with CFI, but only because the indirect call is
> decorated with CFI checks, not because the indirect call itself is any
> slower.
Right. By disabling CFI checks in Android we get something that is more
comparable to the inline static-call implementation as we get a 'raw'
indirect call. But yes, it's very likely that even an out-of-line static
call is going be much faster than a CFI-enabled indirect call, so
definitely worth a try.
> So that suggests that something like
>
> bti c
> ldr x16, 0f
> br x16
> 0:.quad <target>
>
> may well be sufficient in the arm64 case - it is hidden from the
> assembler, so we don't get the CFI overhead, and since it is emitted
> as .text (and therefore requires code patching to be updated), it does
> not need the same level of protection that CFI offers elsewhere when
> it comes to indirect calls.
Agreed. I'm thinking the static-call infrastructure itself could perhaps
do the CFI target validation before actually patching the text. But I
suppose we probably have bigger problems if we can't trust whoever
initiated the static-call patching, so ...
Thanks,
Quentin
More information about the linux-arm-kernel
mailing list