[clang] [llvm] [X86] Enhance kCFI type IDs with a 3-bit arity indicator. (PR #117121)

Sami Tolvanen via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 26 03:24:18 PST 2024


samitolvanen wrote:

> Sami, I'm guessing you're mainly talking about rustc and clang needing to use llvm versions that agree on the kCFI implementation in use?

Correct. Both compilers must use the same hashing scheme for cross-language indirect calls to work, so unconditionally changing how X86 type hashes are calculated in Clang breaks compatibility with current versions of rustc. Using compiler versions to figure out which scheme is being used is tedious, so we should have a better way to figure this out in Kconfig.

> Either way, it would be nice to have some way to set the hashing method being used, or at least, a way to query which hashing strategy is used. We are going to want logic in Kconfig to ensure that rustc and clang use the same strategy, or at least a way to detect when they don't so we can fail the build with a good error message.

Exactly. I would prefer to have a command line option for this, perhaps something similar to [-fsanitize-cfi-icall-experimental-normalize-integers](https://clang.llvm.org/docs/ControlFlowIntegrity.html#fsanitize-cfi-icall-experimental-normalize-integers), or even a flag that accepts the scheme to use as an argument. As long as we default to the original scheme to avoid breaking compatibility with other KCFI implementations.

https://github.com/llvm/llvm-project/pull/117121


More information about the cfe-commits mailing list