This is an archive of the discontinued LLVM Phabricator instance.

[ModuleUtils][KCFI] Set !kcfi_type metadata for sanitizer constructors
ClosedPublic

Authored by samitolvanen on Nov 29 2022, 1:07 PM.

Details

Summary

Set KCFI type metadata for the sanitizer constructors to prevent
runtime failures when these functions are indirectly called in
instrumented code. This fixes a compatibility issue with KASAN and
-fsanitize=kcfi in the Linux kernel.

Link: https://github.com/ClangBuiltLinux/linux/issues/1742

Diff Detail

Event Timeline

samitolvanen created this revision.Nov 29 2022, 1:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 29 2022, 1:07 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
samitolvanen requested review of this revision.Nov 29 2022, 1:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 29 2022, 1:07 PM

Added a test.

nickdesaulniers accepted this revision.Dec 2 2022, 1:13 PM
This revision is now accepted and ready to land.Dec 2 2022, 1:13 PM
MaskRay accepted this revision.Dec 2 2022, 4:25 PM

LGTM.

llvm/lib/Transforms/Utils/ModuleUtils.cpp
121

Add a comment that this matches CodeGenModule::CreateKCFITypeId in Clang.

llvm/test/Instrumentation/AddressSanitizer/kcfi.ll
2
13

delete trailing blank line

remove excess indentation

samitolvanen marked 3 inline comments as done.

Addressed feedback.

MaskRay accepted this revision.Dec 2 2022, 4:37 PM
MaskRay added inline comments.
llvm/test/Instrumentation/AddressSanitizer/kcfi.ll
11

fix the next line as well

Really fix the indentation this time...

samitolvanen marked an inline comment as done.Dec 2 2022, 5:25 PM
This revision was landed with ongoing or failed builds.Dec 8 2022, 4:27 PM
This revision was automatically updated to reflect the committed changes.