[all-commits] [llvm/llvm-project] fd5e26: [ModuleUtils][KCFI] Set patchable-function-prefix ...
Sami Tolvanen via All-commits
all-commits at lists.llvm.org
Wed Jan 11 16:00:58 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: fd5e2627066075f3d15ef774ef368e08735a9ac9
https://github.com/llvm/llvm-project/commit/fd5e2627066075f3d15ef774ef368e08735a9ac9
Author: Sami Tolvanen <samitolvanen at google.com>
Date: 2023-01-11 (Wed, 11 Jan 2023)
Changed paths:
M clang/lib/CodeGen/CodeGenModule.cpp
M clang/test/CodeGen/kcfi.c
M llvm/lib/Transforms/Utils/ModuleUtils.cpp
A llvm/test/Instrumentation/AddressSanitizer/kcfi-offset.ll
Log Message:
-----------
[ModuleUtils][KCFI] Set patchable-function-prefix for synthesized functions
When -fpatchable-function-entry is used to emit prefix nops
before functions, KCFI assumes all indirectly called functions
have the same number of prefix nops, because the nops are emitted
between the KCFI type hash and the function entry. However, as
patchable-function-prefix is a function attribute set by Clang,
functions later synthesized by LLVM don't inherit this attribute
and end up not having prefix nops. One of these functions
is asan.module_ctor, which the Linux kernel ends up calling
indirectly when KASAN is enabled.
In order to avoid tripping KCFI, save the expected prefix offset
to a module flag, and use it when we're setting KCFI type for the
relevant synthesized functions.
Link: https://github.com/ClangBuiltLinux/linux/issues/1742
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D141172
More information about the All-commits
mailing list