Skip to contentSkip to conversation

FAILED: patch "[PATCH] rust: kasan: KASAN+RUST requires clang" failed to apply to 6.18-stable tree

PATCH Applied [email protected] 4 participants 4 messages Jul 9 – Jul 10 Stable branch

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 6.18-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y
git checkout FETCH_HEAD
git cherry-pick -x 5b271543d0f08e9733d4732721e960e285f6448f
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026070939-ranged-unmapped-3ab9@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..'

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 5b271543d0f08e9733d4732721e960e285f6448f Mon Sep 17 00:00:00 2001
From: Alice Ryhl <[email protected]>
Date: Wed, 8 Apr 2026 08:32:16 +0000
Subject: [PATCH] rust: kasan: KASAN+RUST requires clang

Kernel KASAN involves passing various llvm/gcc specific arguments to the C and Rust compiler. Since these arguments differ between llvm and gcc, it's not safe to mix an llvm-based rustc with a gcc build when kasan is enabled.

init/Kconfig +1 -0
index 2937c4d308ae..826a7d768ca3 100644
@@ -2198,6 +2198,7 @@ config RUST
 	depends on !DEBUG_INFO_BTF || (PAHOLE_HAS_LANG_EXCLUDE && !LTO)
 	depends on !CFI || HAVE_CFI_ICALL_NORMALIZE_INTEGERS_RUSTC
 	select CFI_ICALL_NORMALIZE_INTEGERS if CFI
+	depends on !KASAN || CC_IS_CLANG
 	depends on !KASAN_SW_TAGS
 	help
 	  Enables Rust support in the kernel.
#1 lore raw

PATCH 1/1 rust: kasan: KASAN+RUST requires clang

From: Alice Ryhl <[email protected]>

Kernel KASAN involves passing various llvm/gcc specific arguments to the C and Rust compiler. Since these arguments differ between llvm and gcc, it's not safe to mix an llvm-based rustc with a gcc build when kasan is enabled.

Fixes e3117404b411 ("kbuild: rust: Enable KASAN support")
(cherry picked from commit 5b271543d0f08e9733d4732721e960e285f6448f)
---
 init/Kconfig | 1 +
 1 file changed, 1 insertion(+)
init/Kconfig +1 -0
index cab3ad28ca49..0c25e78e10f4 100644
@@ -2096,6 +2096,7 @@ config RUST
 	depends on !CFI || HAVE_CFI_ICALL_NORMALIZE_INTEGERS_RUSTC
 	select CFI_ICALL_NORMALIZE_INTEGERS if CFI
 	depends on !CALL_PADDING || RUSTC_VERSION >= 108100
+	depends on !KASAN || CC_IS_CLANG
 	depends on !KASAN_SW_TAGS
 	depends on !(MITIGATION_RETHUNK && KASAN) || RUSTC_VERSION >= 108300
 	help
Signature · 1 line
2.55.0
#3 lore raw
In reply to [email protected]
Quoted 6 lines · On Thu, Jul 9, 2026 at 7:36 PM <[email protected]> wrote:

The patch below does not apply to the 6.18-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

Quoted 8 lines

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y
git checkout FETCH_HEAD
git cherry-pick -x 5b271543d0f08e9733d4732721e960e285f6448f
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026070939-ranged-unmapped-3ab9@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..'

Done -- by the way, I assume Google uses

72d33b8bfeac ("rust: kasan: add support for Software Tag-Based KASAN")

as well. It is not a bug fix, but if Google is using it and it works, then it guess it could be added too.

Cheers,
Miguel

maintainer Applied
#2 lore raw

Re: [PATCH 6.18.y] rust: kasan: KASAN+RUST requires clang

In reply to Miguel Ojeda
Quoted 4 lines · Miguel Ojeda

Kernel KASAN involves passing various llvm/gcc specific arguments to the C and Rust compiler. Since these arguments differ between llvm and gcc, it's not safe to mix an llvm-based rustc with a gcc build when kasan is enabled.

Queued for 6.18, thanks.

Signature · 2 lines
Thanks,
Sasha