Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rust: arm64: set uwtable llvm module flag for CONFIG_UNWIND_TABLES
@ 2026-05-27 18:18 Alice Ryhl
  2026-05-27 18:30 ` Alice Ryhl
  2026-05-28  5:26 ` Miguel Ojeda
  0 siblings, 2 replies; 8+ messages in thread
From: Alice Ryhl @ 2026-05-27 18:18 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Miguel Ojeda, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Danilo Krummrich, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt
  Cc: linux-arm-kernel, linux-kernel, rust-for-linux, llvm, stable,
	Bo Ye, Isaac Manjarres, Sami Tolvanen, Alice Ryhl

Due to a rustc bug [1] the -Cforce-unwind-tables=y flag only emits the
uwtable annotation for functions, but not for the module. This means
that compiler-generated functions such as 'asan.module_ctor' do not
receive the uwtable annotation.

When CONFIG_UNWIND_PATCH_PAC_INTO_SCS is enabled, this leads to boot
failures because the dwarf information emitted for the kasan
constructors is wrong, which causes the SCS boot patching code to
patch the constructor in an illegal manner. Specifically, the paciasp
instruction is patched, but the autiasp instruction is not. This
mismatch leads to a crash when the constructor is called during boot.

	==================================================================
	BUG: KASAN: global-out-of-bounds in do_basic_setup+0x4c/0x90
	Read of size 8 at addr ffffffe3cc7eb488 by task swapper/0/1

Specifically the faulting instruction is the (*fn)() to invoke the
constructor in do_ctors() of the init/main.c file.

Once the fix lands in rustc, this flag can be made conditional on the
rustc version. Note that passing the flag on a rustc with the fix
present has no effect.

Fixes: d077242d68a3 ("rust: support for shadow call stack sanitizer")
Cc: stable@kernel.org
Link: https://github.com/rust-lang/rust/pull/156980 [1]
Reported-by: Bo Ye <bo.ye@mediatek.com>
Debugged-by: Isaac Manjarres <isaacmanjarres@google.com>
Debugged-by: Sami Tolvanen <samitolvanen@google.com>
Tested-by: Isaac Manjarres <isaacmanjarres@google.com>
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
---
 arch/arm64/Makefile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 73a10f65ce8b..5b21941b5c8d 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -63,6 +63,9 @@ else
 KBUILD_CFLAGS	+= -fasynchronous-unwind-tables
 KBUILD_AFLAGS	+= -fasynchronous-unwind-tables
 KBUILD_RUSTFLAGS += -Cforce-unwind-tables=y -Zuse-sync-unwind=n
+# Work around rustc bug on compilers without below change:
+# https://github.com/rust-lang/rust/pull/156973
+KBUILD_RUSTFLAGS += -Zllvm_module_flag=uwtable:u32:2:max
 endif
 
 ifeq ($(CONFIG_STACKPROTECTOR_PER_TASK),y)

---
base-commit: 7fd2df204f342fc17d1a0bfcd474b24232fb0f32
change-id: 20260527-uwtable-module-flag-6a0595bf0e97

Best regards,
-- 
Alice Ryhl <aliceryhl@google.com>



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-05-29 15:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-27 18:18 [PATCH] rust: arm64: set uwtable llvm module flag for CONFIG_UNWIND_TABLES Alice Ryhl
2026-05-27 18:30 ` Alice Ryhl
2026-05-28  5:26 ` Miguel Ojeda
2026-05-28  5:56   ` Alice Ryhl
2026-05-29  6:32   ` Alice Ryhl
2026-05-29 14:29     ` Miguel Ojeda
2026-05-29 14:45       ` Alice Ryhl
2026-05-29 15:15       ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox