Re: [tip: x86/core] x86/ibt: Implement FineIBT-BHI mitigation

Peter Zijlstra
2025-02-26T19:53:12Z

On Wed, Feb 26, 2025 at 12:54:35PM -0000, tip-bot2 for Peter Zijlstra wrote:

> diff --git a/Makefile b/Makefile
> index 96407c1..f19431f 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1014,6 +1014,9 @@ CC_FLAGS_CFI := -fsanitize=kcfi
> ifdef CONFIG_CFI_ICALL_NORMALIZE_INTEGERS
> CC_FLAGS_CFI += -fsanitize-cfi-icall-experimental-normalize-integers
> endif
> +ifdef CONFIG_FINEIBT_BHI
> + CC_FLAGS_CFI += -fsanitize-kcfi-arity
> +endif
> ifdef CONFIG_RUST
> # Always pass -Zsanitizer-cfi-normalize-integers as CONFIG_RUST selects
> # CONFIG_CFI_ICALL_NORMALIZE_INTEGERS.
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index c4175f4..5c27726 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -2473,6 +2473,10 @@ config CC_HAS_RETURN_THUNK
> config CC_HAS_ENTRY_PADDING
> def_bool $(cc-option,-fpatchable-function-entry=16,16)
>
> +config CC_HAS_KCFI_ARITY
> + def_bool $(cc-option,-fsanitize=kcfi -fsanitize-kcfi-arity)
> + depends on CC_IS_CLANG && !RUST
> +

Miguel, can we work on fixing that !RUST dep?

> config FUNCTION_PADDING_CFI
> int
> default 59 if FUNCTION_ALIGNMENT_64B
> @@ -2498,6 +2502,10 @@ config FINEIBT
> depends on X86_KERNEL_IBT && CFI_CLANG && MITIGATION_RETPOLINE
> select CALL_PADDING
>
> +config FINEIBT_BHI
> + def_bool y
> + depends on FINEIBT && CC_HAS_KCFI_ARITY
> +
> config HAVE_CALL_THUNKS
> def_bool y
> depends on CC_HAS_ENTRY_PADDING && MITIGATION_RETHUNK && OBJTOOL