Re: [PATCH] rust: kasan/kbuild: fix rustc-option when cross-compiling

From: Alice Ryhl

Date: Tue May 05 2026 - 08:02:26 EST


On Mon, May 04, 2026 at 12:57:37PM +0000, Alice Ryhl wrote:
> The above scenario actually also fails without -Zfixed-x18 since the
> SW_TAGS sanitizer itself is aarch64-specific. But it's a problem with
> normal KASAN too because of -Zfixed-x18.

Correction: No, this is not actually the case. Despite being
aarch64-specific, the SW_TAGS option does work correctly here.

When rustc-option is invoked by Makefile.kasan, the
-Zsanitizer=kernel-hwaddress flag is present only in RUSTFLAGS_KASAN and
not in KBUILD_RUSTFLAGS, so it does not get included in the RUSTC
invocation. Therefore, even though KASAN_SW_TAGS is aarch64-specific, it
will correctly check the -Cllvm-args flags.

I got this wrong because when checking it because I disabled -Zfixed-x18
but not CONFIG_ARM64_BTI_KERNEL, which adds -Zbranch-protection. This
option causes the same problem.

Alice