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 6F48A331EA4; Thu, 20 Aug 2026 13:57:51 +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=1787234272; cv=none; b=mkDPtGp1Vd2aFMxdMaLRC4+zwR4zoj87yyhLh1cm67jSN5qpo0m9zlUxMjEGsiz7jPNFFAOVCZa+15FN4qxaa2q9YjU3x/bUXxyreo0uZY9vdgGbg6aMNoKzajkyvsi22dGYRHUnGaHJ9n3ttXae9cHrSrdf5Z5/a33p0GBiUvs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787234272; c=relaxed/simple; bh=iVGtER76EzmyS10nHVwOMDdtU/MC7WnGS6Cm1iam6ko=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Z5r50GyFezE+cfj8oYycvE1kQop4JIeLptFYNgK0XhZ+pEhlRvTh0Mv19BDeXr3//NLIV3N7OAfCOK52ngLqcjdXvYpylY6njZ3fBUcQscUqsVgih0Gllp0FBRKoPBJpxq4ADRfpqrM8fROO8fPUOkVeh4z3OOG1dVGaIRdJicw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=E9jU6otl; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="E9jU6otl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 518B11F000E9; Thu, 20 Aug 2026 13:57:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787234271; bh=m3DnabEhGjUWzQ3HU8pKJDqgpb9y/qdMXoHcrC/IV6M=; h=From:To:Cc:Subject:Date:Reply-To; b=E9jU6otloA3NZ6t45DsD1cMe/xarkd8XfXQCBKE6FG1vC51wwOPC3AMUdvC+BTew8 aURsFQTeowDAs90CU9aCdinAL7+ciOrWa3OX3o0YaFMKZncyyhb81PqSD7Btemqj2a naMZTgjJ0aquG6ARfF40qRWZSguq9yjXMUI2f8K8wmcfBtfClOuzM77eydsFZtz81V tFS4OkJg11bfMHLSA7aKpGuzK2N43Qjby0d/CGiOJnw7eHOni4FHM6EGff4NjP70pr O2yumjOZCVRc5otGmrkEHQ2lYTh0CZATEHK34sZhvdbc4pSFErCRZW4RQSV0G9AZOY 2zyBUcbonlyTg== From: Gary Guo To: Nathan Chancellor , Nicolas Schier , Miguel Ojeda , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Daniel Almeida , Tamir Duberstein , Alexandre Courbot , =?UTF-8?q?Onur=20=C3=96zkan?= , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: kernel test robot , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] rust: cfi: disable function merging if CFI is enabled Date: Thu, 20 Aug 2026 14:57:32 +0100 Message-ID: <20260820135733.37121-1-gary@kernel.org> X-Mailer: git-send-email 2.54.0 Reply-To: Gary Guo Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Gary Guo 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 generates function that produces zero. LKP test robot reports a `Flags::zeroed` instance; my local reproduction has a `Bounded::new::<0>`. LLVM's MergeFunctionsPass incorrectly merge functions with the same KCFI type, causing `__module_firmware_test_init` being merged into one of the zero-returning function. As module init is invoked via indirect function call, KCFI is checked and this produces a KCFI failure. I've reported this bug to upstream LLVM [1]; in the mean time, 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. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202608201017.100a4511-lkp@intel.com Link: https://github.com/llvm/llvm-project/issues/217629 [1] Signed-off-by: Gary Guo --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4fee5ee9e9f4..0dd9a6eda739 100644 --- a/Makefile +++ b/Makefile @@ -1118,7 +1118,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 merge functions with the same KCFI type. + RUSTC_FLAGS_CFI := -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers -Zmerge-functions=disabled KBUILD_RUSTFLAGS += $(RUSTC_FLAGS_CFI) export RUSTC_FLAGS_CFI endif base-commit: e6664f2b33db9b6811eb4cec109f06cb2b4f458d -- 2.54.0