From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41A04414A2A; Fri, 4 Sep 2026 05:39:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788500401; cv=none; b=kENGHS6wZwyWkbraWoq+yyEhgw+5sc6MmGpSZwVEYTjwb4zsfcD9qM7KjQ07yOxpbqvIYsDfAFfKM12lRsyOJSl6JG7cVwctVRuucqI6Ewygt+jWpUSmqxtpZbW80xmq6Uw04H4cmjAe0Y23u02wM1FSxvO3yl5lUrSkA3JZU7k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788500401; c=relaxed/simple; bh=nmjZZV2fS9T6f5sb2V4fYUxRNXUV08979rsamIFryQg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ij0CIcCe9tXtGfkB28h6uRiPw827R7CDnxb7LP6s2YmNQZqqun0WZnKCGDw6N4nf8O3Xtz/F083h/Vi9JQyh6aefpF/zdwE3pj9+AV3jzAuxtatdptXwL9EFVABTNMOh5w8h9ZokMUwajorDeWqeladq4dK2btLr9A3Wz1Pj/l0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=InCRT3MG; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="InCRT3MG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 586F01F00A3D; Fri, 4 Sep 2026 05:39:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788500399; bh=xd/E79ko92LKDFfscRwa4OFHDCUfbaUfPBBVwd7EO6g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=InCRT3MGTHmFV9fkwYKW5RiqR5VyS4yHKvyUxzTUwGFQZq9p7+xg10c2dXsDHY6hO 1+8sweTf7iBSvzbwZwb4Jt8Z5SDSQjFULxM4gofrDw/v7Fi0S93oVIbZ7AML2b+6+9 7xOwcmi3iyXb0xu+LSE96u544gTAndqX1eF9YqPE= 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 Subject: [PATCH 6.18 026/552] rust: cfi: disable function merging if CFI is enabled Date: Fri, 4 Sep 2026 06:53:03 +0200 Message-ID: <20260904045748.419705389@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260904045747.813364717@linuxfoundation.org> References: <20260904045747.813364717@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: 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 commit 29b03d1de967a177176d12811d970cac7882afcf upstream. 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: Greg Kroah-Hartman --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- 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