From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D355A390212 for ; Wed, 12 Aug 2026 16:21:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786551682; cv=none; b=PoPe0AptC0Bh028pd1KQHBwL+Q4sDTi5ME7YD1e6M01G7MnjxdMqkCOtKoiru8+2AQkO2CIqyhv6B37m1XKV363eu9V6eXX+PR8hRSi6O8i4tDg7aaQMQOsqmy8YunsSXn7hQeXueWCzjkB8GYA88qI6lBbFsZmqOMoK34IXBkY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786551682; c=relaxed/simple; bh=U9VKnlWYWUqNYLV5LzPacBbOScKTY/QnXgi2fcEyVDE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iDZNqDI3VnDvcNYvMYGwnFtwetaxXDeTQ27KLMJgA06nZsT9Bg847m01Q2g797uGMzqVHuG3RX/cyyceEk8XaiRFIEiX2Miq4XCs+gtlnrUZPi6revA2yXPMT5BFP497G58bHASAuY563gD+lhW1sh+Rf8ppf8RoSNIibxYfsts= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=F/onrWzq; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="F/onrWzq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA03D1F000E9; Wed, 12 Aug 2026 16:21:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786551680; bh=IBI5WI/lAJafFgJ7Sy0DqBFi6pgrnyhinmb89eE1GpY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=F/onrWzqRC4xvmRq69jeVZIr9nMHor+y/MIcRRA00ZMKaNYP8M3jxBtpC3BRCbMVq D6hwGMwpR3P1+DVN3cLqPXJdUK9dDYXJVnoqJSz30nkdBkh69scq1CFPTqQbPlJSNh d6182f2VJ5T9x4bR+fzSJE/PQSmPXMdR5I2811lZUjftFvRAMaZC0rgAhyrL3GqdUZ pCELQX9noOq39Jf2JLZVIC8gBbA9hkbOJYMJpc7QI6s0zsGfuvVLuw0v5wercUxsUK J/0Xj/qLin6jk20Tyl7iNtwi0cDj7CO9yw/G5efCJmOl7oGk0TdqirXoYwTELOPn6D uDwEmjtxb9Oeg== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, Ard Biesheuvel , Mark Brown , Josh Poimboeuf , Nick Desaulniers Subject: [PATCH 2/2] DONOTMERGE: arm64: module: Test module for BTI veneers Date: Wed, 12 Aug 2026 18:21:01 +0200 Message-ID: <20260812162058.612202-6-ardb@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260812162058.612202-4-ardb@kernel.org> References: <20260812162058.612202-4-ardb@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2072; i=ardb@kernel.org; h=from:subject; bh=U9VKnlWYWUqNYLV5LzPacBbOScKTY/QnXgi2fcEyVDE=; b=owGbwMvMwCVmkMcZplerG8N4Wi2JIatmbv5Opml7uNO+Orx3XVMvZCc29duU/B/rftxsSi+6p eAluLqko5SFQYyLQVZMkUVg9t93O09PlKp1niULM4eVCWQIAxenAEyk/xgjw6Ons6c2ndG0Pmpf bHLF6yTvnJUNW5wYfz+zmb5z2rQDck6MDEvj1GWT1yhVXVu7r/bJSo1NMrExsiY5/nKOj26+Dlr ByQEA X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 Content-Transfer-Encoding: 8bit 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 --- 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 +#include +#include + +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