Skip to content

arm64: Implement support for BTI veneers

Ard Biesheuvel linux-arm-kernel linux-hardening lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest2 patches 5 repliesIn review

Changes in v2 from the cover letter

- make HAVE_LIVE_PATCH depend on !ARM64_BTI_KERNEL, as live patch has other cases where landing pads may go missing

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2arm64: module: Emit BTI veneers for cross-section callsarch/arm64/Kconfig arch/arm64/include/asm/module.h arch/arm64/include/asm/module.lds.h +1 more+140 -104 replies
2/2DONOTMERGE: arm64: module: Test module for BTI veneersarch/arm64/kernel/Makefile arch/arm64/kernel/bti_veneer_test.c+27 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/2] arm64: Implement support for BTI veneers

From: Ard Biesheuvel <[email protected]>

[ Resending this with minimal changes even though some other approaches
were proposed as well. [1][2] Neither of those are appropriate for backporting, while this series can reasonably be applied to older kernels. ]

Recent toolchains will omit BTI landing pads from functions with static linkage that never have their address taken. If a landing pad is needed nonetheless, it is up to the static linker to emit a BTI veneer withing direct branching range of the target, and direct the call to the veneer instead.

Modules are partially linked objects, and so there is no static linker that can do this for us. Instead, the module loader must see to this.

So implement this for the arm64 module loader. Patch #2 contains a test module that was used to validate the approach.

Changes since v1:
- make HAVE_LIVE_PATCH depend on !ARM64_BTI_KERNEL, as live patch has other cases where landing pads may go missing

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/

Cc Mark Brown <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Nick Desaulniers <[email protected]>

Ard Biesheuvel (2):
arm64: module: Emit BTI veneers for cross-section calls
DONOTMERGE: arm64: module: Test module for BTI veneers

 arch/arm64/Kconfig                  |   7 +-
 arch/arm64/include/asm/module.h     |  12 ++
 arch/arm64/include/asm/module.lds.h |   3 +
 arch/arm64/kernel/Makefile          |   1 +
 arch/arm64/kernel/bti_veneer_test.c |  26 ++++
 arch/arm64/kernel/module-plts.c     | 128 +++++++++++++++++++-
 6 files changed, 167 insertions(+), 10 deletions(-)
 create mode 100644 arch/arm64/kernel/bti_veneer_test.c
Signature · 1 line
2.56.0.rc1.315.gc6ed9934b7-goog