[PATCH] rust: KASAN+RETHUNK requires rustc 1.83.0
From: Alice Ryhl
Date: Thu Sep 26 2024 - 05:39:13 EST
When enabling both KASAN and RETHUNK, objtool emits the following
warnings:
rust/core.o: warning: objtool: asan.module_ctor+0x13: 'naked' return found in MITIGATION_RETHUNK build
rust/core.o: warning: objtool: asan.module_dtor+0x13: 'naked' return found in MITIGATION_RETHUNK build
This is caused by the -Zfunction-return=thunk-extern flag in rustc not
properly informing LLVM about the mitigation, which means that the KASAN
functions asan.module_ctor and asan.module_dtor are generated without
the rethunk mitigation.
The other mitigations that we enabled for Rust (SLS, RETPOLINE) do not
have the same bug, as they're being applied through the target-feature
functionality instead.
This is being fixed for rustc 1.83.0, so update Kconfig to reject this
configuration on older compilers.
Link: https://github.com/rust-lang/rust/pull/130824
Fixes: d7868550d573 ("x86/rust: support MITIGATION_RETHUNK")
Reported-by: Miguel Ojeda <ojeda@xxxxxxxxxx>
Closes: https://lore.kernel.org/all/CANiq72myZL4_poCMuNFevtpYYc0V0embjSuKb7y=C+m3vVA_8g@xxxxxxxxxxxxxx/
Signed-off-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
---
init/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/init/Kconfig b/init/Kconfig
index fa734a144589..9a2bcba426c5 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1950,6 +1950,7 @@ config RUST
select CFI_ICALL_NORMALIZE_INTEGERS if CFI_CLANG
depends on !CALL_PADDING || RUSTC_VERSION >= 108100
depends on !KASAN_SW_TAGS
+ depends on !(MITIGATION_RETHUNK && KASAN) || RUSTC_VERSION >= 108300
help
Enables Rust support in the kernel.
--
2.46.0.792.g87dc391469-goog