Re: [RFC PATCH 2/2] x86/kprobes: Prohibit probing on compiler generated CFI checking code
From: Peter Zijlstra
Date: Tue Jul 11 2023 - 03:05:03 EST
On Tue, Jul 11, 2023 at 08:58:37AM +0900, Masami Hiramatsu wrote:
> Oh, is FineIBT different from kCFI? I thought those are same. But anyway
> for kCFI=y && FineIBT=n case, I think this code still needed.
Yeah, FineIBT relies on kCFI and IBT (and selects CALL_PADDING) and
dynamically re-writes the kCFI infrastructure.
All the gory details are in arch/x86/kernel/alternative.c, search for
CONFIG_FINEIBT, I've tried to write a big comment, but please let me
know if something isn't clear and I'll write some actual words :-).
But basically kCFI is a pure software solution and does the check before
the indirect control transfer (it has to). While FineIBT relies on the
IBT hardware in order to do the check after.
As such, FineIBT can do the CFI check without memory loads, which is
good for performance. Another useful property of FineIBT is that it is a
speculation barrier.