From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793831193; b=ce1xqlmW+fI3A50k1g8zyJ8gw22oYsrARLxuXPMRyir4GX74lMah+/jnlFVG1qW3DsUv d2xrDZwAucYa7GvnjENFN8/PpGMQJ5Fnc9dcRVeRmL/Jg6bmodMmTsLRYofNibTBxaTbk s14i3EB/POTuTYSI41nHZkkQQzt2zelsVJ5JTr92lLoktwYqPI6UA2HZcw2O3k1aaQVif eJfTGR+7xuUIfu0qy9MBfY53yqguBRANMC2RlnvDa34yL84ishyZPxKuZ5AH4LDNq6ILV w1MBrGnkL+hXM4wMd1AISqvC3mVRgiXI/4akPxSaZRupqiEHmVTKYOCwv/nqbQRXekA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793831193; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=jmaX1XlL9rHzoX/OKUDK3OVAcUOlpTdRzfV/shJCWJE=; b=haS9vdiwflSYd1weTJg6kvjh+G06VcZB4W9R01nVQfupXwgpcH9xqM4yc9juuF00zUI8 oJCL8D8oR1esNUU0ozVCYVkiYGfaxffTEfDClM9oCwDau8xqljmljbs3C29LmUIPeLUy1 abpdqayrW0SLYe6JuHDdieJcp8aNSYTFziUrZjtVbO370DTC1ZxxQmrZFzToREi9u/Grw 640n1GMPENUvFM0uUDMHGA1noqGKM2Ti0E5B5JqgKs1MeJmt4GvRp2DaRPTHIFQbibHPY NvQxYBVc3fJ7bshZqbxHizYAQvX+/oghUZ+vlPuRHK/UcfsG3Dj+wm4guv5qF6WMfUQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=imrerlID; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B5BF606A85A; Wed, 4 Nov 2026 22:26:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=imrerlID Received: by smtp.kernel.org (Postfix) with ESMTPSA id C75EE1F0093A; Wed, 4 Nov 2026 22:26:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1793831193; bh=jmaX1XlL9rHzoX/OKUDK3OVAcUOlpTdRzfV/shJCWJE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=imrerlIDbQtXJtXnEhVhKhgksusaLexJS9kLANUmL4czBm0lfurehsppwaKDgrBGx kszjdUzcY8TDcwh+B786KfARKU5R1HUxsbFdWWHhd19FoPD7oIS5mftUXW+3mgDSKS ArxtvD7uWrn/j3FlHSjAVZN5pQD2P48k52R7fb9Q= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, kernel test robot , Gary Guo , Sami Tolvanen , Miguel Ojeda , Sasha Levin Subject: [PATCH 6.18 0556/1005] rust: cfi: disable function merging if CFI is enabled Date: Wed, 4 Nov 2026 16:04:49 -0500 Message-ID: <20261104211059.468090514@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261104211043.516122098@linuxfoundation.org> References: <20261104211043.516122098@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Gary Guo [ Upstream commit 29b03d1de967a177176d12811d970cac7882afcf ] In Rust doc tests, there is a dummy `__module_firmware_test_init` function generated by the example in `module_firmware!`'s documentation, which just returns zero. Many other documentation examples generate functions that produce zero. LKP test robot reports [1] a `Flags::zeroed` instance; my local reproduction has a `Bounded::new::<0>`. LLVM's MergeFunctionsPass incorrectly merges functions with different KCFI types, causing `__module_firmware_test_init` to be merged into one of the zero-returning functions. As module init is invoked via an indirect function call, KCFI is checked and this produces a KCFI failure. I've reported this bug to upstream LLVM [2]; in the meantime, disable function merging if CFI is enabled. No separate treatment is needed for CONFIG_RUST_INLINE_HELPERS, as Clang does not enable function merging by default. [ LLVM already has a pending PR: https://github.com/llvm/llvm-project/pull/217665 which solves the issue. In addition, I asked upstream Rust if the unstable `-Zmerge-functions=disabled` flag will remain around: https://rust-lang.zulipchat.com/#narrow/channel/425075-rust-for-linux/topic/.60-Zmerge-functions.3Ddisabled.60/ and it does indeed look like that will be the case. - Miguel ] Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202608201017.100a4511-lkp@intel.com [1] Link: https://github.com/llvm/llvm-project/issues/217629 [2] Signed-off-by: Gary Guo Cc: stable@vger.kernel.org Fixes: ca627e636551 ("rust: cfi: add support for CFI_CLANG with Rust") Reviewed-by: Sami Tolvanen Link: https://patch.msgid.link/20260820135733.37121-1-gary@kernel.org [ Fixed typos as discussed. Reworded slightly for other typos. - Miguel ] Signed-off-by: Miguel Ojeda Signed-off-by: Sasha Levin --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7c698d401dd54..08be8b2cd2447 100644 --- a/Makefile +++ b/Makefile @@ -1037,7 +1037,8 @@ endif ifdef CONFIG_RUST # Always pass -Zsanitizer-cfi-normalize-integers as CONFIG_RUST selects # CONFIG_CFI_ICALL_NORMALIZE_INTEGERS. - RUSTC_FLAGS_CFI := -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers + # Disable function merging as LLVM incorrectly merges functions with different KCFI types. + RUSTC_FLAGS_CFI := -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers -Zmerge-functions=disabled KBUILD_RUSTFLAGS += $(RUSTC_FLAGS_CFI) export RUSTC_FLAGS_CFI endif -- 2.53.0