[clang] [Clang][attr] Add 'cfi_salt' attribute (PR #141846)

Kees Cook via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 8 15:18:02 PDT 2025


================
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fsyntax-only -fsanitize=kcfi -verify %s
+
+#define __cfi_salt(S) __attribute__((cfi_salt(S)))
+
+int bad1() __cfi_salt(); // expected-error{{'cfi_salt' attribute takes one argument}}
+int bad2() __cfi_salt(42); // expected-error{{expected string literal as argument of 'cfi_salt' attribute}}
+int bad3() __attribute__((cfi_salt("a", "b", "c"))); // expected-error{{'cfi_salt' attribute takes one argument}}
----------------
kees wrote:

> I think non-null ASCII characters would be good

Agreed: It can both be included in the existing mangle string -> hash step, and I expect this to be a "meaningful" string for authors to use (e.g. "sched" or "kvm") etc.

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


More information about the cfe-commits mailing list