Skip to content

Commit c0a454b

Browse files
brooniewilldeacon
authored andcommitted
arm64/bti: Disable in kernel BTI when cross section thunks are broken
GCC does not insert a `bti c` instruction at the beginning of a function when it believes that all callers reach the function through a direct branch[1]. Unfortunately the logic it uses to determine this is not sufficiently robust, for example not taking account of functions being placed in different sections which may be loaded separately, so we may still see thunks being generated to these functions. If that happens, the first instruction in the callee function will result in a Branch Target Exception due to the missing landing pad. While this has currently only been observed in the case of modules having their main code loaded sufficiently far from their init section to require thunks it could potentially happen for other cases so the safest thing is to disable BTI for the kernel when building with an affected toolchain. [1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106671 Reported-by: D Scott Phillips <[email protected]> [Bits of the commit message are lifted from his report & workaround] Signed-off-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: <[email protected]> # v5.10+ Signed-off-by: Will Deacon <[email protected]>
1 parent 5fbc49c commit c0a454b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

arch/arm64/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,6 +1887,8 @@ config ARM64_BTI_KERNEL
18871887
depends on CC_HAS_BRANCH_PROT_PAC_RET_BTI
18881888
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94697
18891889
depends on !CC_IS_GCC || GCC_VERSION >= 100100
1890+
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106671
1891+
depends on !CC_IS_GCC
18901892
# https://github.com/llvm/llvm-project/commit/a88c722e687e6780dcd6a58718350dc76fcc4cc9
18911893
depends on !CC_IS_CLANG || CLANG_VERSION >= 120000
18921894
depends on (!FUNCTION_GRAPH_TRACER || DYNAMIC_FTRACE_WITH_REGS)

0 commit comments

Comments
 (0)