[llvm] [X86][KCFI] Do not emit a type prefix for nocf_check functions (PR #158133)

Kees Cook via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 15 09:41:47 PDT 2025


kees wrote:

> > I see this is only testing the IR level, but not the front-end.
> 
> Correct, this doesn't change the behavior of `nocf_check` in Clang.
> 
> > Do you want `-fsanitize=kcfi` to work with `nocf_check` regardless of `-fcf-protection`? I think it should -- there may actually be some value in being able to remove preambles for a function regardless of `-fcf-protection`. (This is the logic I'm implementing in the GCC KCFI.)
> 
> That sounds reasonable to me. Out of curiosity, `nocf_check` is currently limited to X86 only in Clang. Does your GCC KCFI implementation support `nocf_check` on other architectures too?

I modified the `nocf_check` attribute handler to check for either `-cf-protection` or `-fsanitize=kcfi` being enabled.

> > That way we won't get these kinds of errors if someone tries to use `nocf_check`:
> > ```
> > kcfi-runtime.c:17:16: warning: 'nocf_check' attribute ignored; use -fcf-protection to enable the
> >       attribute [-Wignored-attributes]
> >    17 | __attribute__((nocf_check))
> >       |                ^
> > ```
> 
> I think this isn't actually a problem in the kernel though, as `nocf_check` is only used with `CONFIG_X86_KERNEL_IBT`.

Correct. In the future we could modify the `nocf_check` Linux macro to become enabled under either config.

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


More information about the llvm-commits mailing list