[PATCH 2/2] DONOTMERGE: arm64: module: Test module for BTI veneers
Ard Biesheuvel <[email protected]>
| Newsgroups | org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
This module has a tiny .text section with a static function, which is called by the module init hook, which is placed in a ~128M init code section, which is therefore guaranteed to be place out of direct branching range when CONFIG_RANDOMIZE_MODULE_REGION_FULL is disabled. When CONFIG_ARM64_BTI_KERNEL is enabled, this forces the use of a BTI veneer, as recent GCCs and Clangs will elide BTI landing pads for static functions that never have their address taken, even in the presence of cross-section calls to those functions. Signed-off-by: Ard Biesheuvel <[email protected]> --- arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/bti_veneer_test.c | 26 ++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index d2690c3ec528..b74e2dbd2d5f 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -72,6 +72,7 @@ obj-$(CONFIG_ARM64_MPAM) += mpam.o obj-$(CONFIG_ARM64_MTE) += mte.o obj-y += vdso-wrap.o obj-$(CONFIG_COMPAT_VDSO) += vdso32-wrap.o +obj-m += bti_veneer_test.o # Force dependency (vdso*-wrap.S includes vdso.so through incbin) $(obj)/vdso-wrap.o: $(obj)/vdso/vdso.so diff --git a/arch/arm64/kernel/bti_veneer_test.c b/arch/arm64/kernel/bti_veneer_test.c new file mode 100644 index 000000000000..62c20e960d8d --- /dev/null +++ b/arch/arm64/kernel/bti_veneer_test.c @@ -0,0 +1,26 @@ + +#include <linux/init.h> +#include <linux/module.h> +#include <linux/types.h> + +static int noinline static_noninit_function(void) +{ + static volatile int ret; + return ret; +} + +static int __init bti_veneer_test_init(void) +{ + return static_noninit_function(); +} +module_init(bti_veneer_test_init); + +static void bti_veneer_test_exit(void) +{ +} +module_exit(bti_veneer_test_exit); + +/* Make the init code region too big to fit in 128M 'near' module region */ +asm(".section .init.padding, \"ax\", %progbits; .space (128 << 20) - 64; .previous"); + +MODULE_LICENSE("GPL"); -- 2.47.3